// NOTE: Changed so format = partitionID,size (used to be partitionID,fpswd,rpswd,size,filesystem) int fioGetInput(const char *arg, input_param *params) { char szBuf[32]; int rv=0; if(params==NULL) return -EINVAL; memset(params, 0, sizeof(input_param)); while(arg[0]==' ') arg++; if(arg[0]==0 || arg[0]==',') return -EINVAL; if((rv=fioInputBreaker(&arg, params->id, APA_IDMAX))!=0) return rv; if((params->id[0]==0) || (arg[0]==0)) return 0; memset(szBuf, 0, sizeof(szBuf)); if((rv=fioInputBreaker(&arg, szBuf, sizeof(szBuf)))!=0) return rv; if((rv=fioPartitionSizeLookUp(szBuf))<0) return rv; params->size=rv; // Filesystem type is fixed to PFS! params->type = APA_TYPE_PFS; return rv; }
static int fioGetInput(const char *arg, apa_params_t *params) { char argBuf[32]; int rv=0, i; static const struct apaFsType fsTypes[]={ {"PFS", APA_TYPE_PFS}, {"CFS", APA_TYPE_CFS}, {"EXT2", APA_TYPE_EXT2}, {"EXT2SWAP", APA_TYPE_EXT2SWAP} }; if(params==NULL) return -EINVAL; memset(params, 0, sizeof(apa_params_t)); while(arg[0]==' ') arg++; if(arg[0]==0 || arg[0]==',') return -EINVAL; if((rv=fioInputBreaker(&arg, params->id, APA_IDMAX))!=0) return rv; if(arg[0] == '\0') // Return if there are no further parameters. return 0; if((rv=fioInputBreaker(&arg, params->fpwd, APA_PASSMAX))!=0) return rv; if(params->fpwd[0] != '\0') apaEncryptPassword(params->id, params->fpwd, params->fpwd); if(arg[0] == '\0') // Return if there are no further parameters. return 0; if((rv=fioInputBreaker(&arg, params->rpwd, APA_PASSMAX))!=0) return rv; if(params->rpwd[0] != '\0') apaEncryptPassword(params->id, params->rpwd, params->rpwd); if(arg[0] == '\0') // Return if there are no further parameters. return 0; memset(argBuf, 0, sizeof(argBuf)); if((rv=fioInputBreaker(&arg, argBuf, sizeof(argBuf)))!=0) return rv; if((rv=fioPartitionSizeLookUp(argBuf))<0) return rv; params->size=rv; memset(argBuf, 0, sizeof(argBuf)); if((rv=fioInputBreaker(&arg, argBuf, sizeof(argBuf)))!=0) return rv; for(i = 0; i < 4; i++) { if(!strcmp(argBuf, fsTypes[i].desc)) { params->type = fsTypes[i].type; break; } } if(i == 4) { printf("hdd: error: Invalid fstype, %s.\n", argBuf); return -EINVAL; } return rv; }