Lines Matching refs:drive
51 static int GptSetEntryAttributes(struct drive *drive, in GptSetEntryAttributes() argument
56 entry = GetEntry(&drive->gpt, PRIMARY, index); in GptSetEntryAttributes()
83 static int SetEntryAttributes(struct drive *drive, in SetEntryAttributes() argument
87 SetRaw(drive, PRIMARY, index, params->raw_value); in SetEntryAttributes()
90 SetErrorCounter(drive, PRIMARY, index, params->error_counter); in SetEntryAttributes()
92 SetSuccessful(drive, PRIMARY, index, params->successful); in SetEntryAttributes()
94 SetTries(drive, PRIMARY, index, params->tries); in SetEntryAttributes()
96 SetPriority(drive, PRIMARY, index, params->priority); in SetEntryAttributes()
98 SetLegacyBoot(drive, PRIMARY, index, params->legacy_boot); in SetEntryAttributes()
100 SetRequired(drive, PRIMARY, index, params->required); in SetEntryAttributes()
104 if (IsUnused(drive, PRIMARY, index)) { in SetEntryAttributes()
118 static int CgptCheckAddValidity(struct drive *drive) { in CgptCheckAddValidity() argument
120 if (GPT_SUCCESS != (gpt_retval = GptValidityCheck(&drive->gpt))) { in CgptCheckAddValidity()
126 if (CGPT_OK != CheckValid(drive)) { in CgptCheckAddValidity()
134 static int CgptGetUnusedPartition(struct drive *drive, uint32_t *index, in CgptGetUnusedPartition() argument
137 uint32_t max_part = GetNumberOfEntries(drive); in CgptGetUnusedPartition()
148 if (IsUnused(drive, PRIMARY, i)) { in CgptGetUnusedPartition()
160 struct drive drive; in CgptSetAttributes() local
165 if (CGPT_OK != DriveOpen(params->drive_name, &drive, O_RDWR, in CgptSetAttributes()
169 if (CgptCheckAddValidity(&drive)) { in CgptSetAttributes()
174 params->partition >= GetNumberOfEntries(&drive)) { in CgptSetAttributes()
179 SetEntryAttributes(&drive, params->partition - 1, params); in CgptSetAttributes()
181 UpdateAllEntries(&drive); in CgptSetAttributes()
184 return DriveClose(&drive, 1); in CgptSetAttributes()
187 DriveClose(&drive, 0); in CgptSetAttributes()
196 struct drive drive; in CgptGetPartitionDetails() local
203 if (CGPT_OK != DriveOpen(params->drive_name, &drive, O_RDONLY, in CgptGetPartitionDetails()
207 if (CgptCheckAddValidity(&drive)) { in CgptGetPartitionDetails()
211 int max_part = GetNumberOfEntries(&drive); in CgptGetPartitionDetails()
223 GptEntry *entry = GetEntry(&drive.gpt, PRIMARY, index); in CgptGetPartitionDetails()
237 GptEntry *entry = GetEntry(&drive.gpt, PRIMARY, index); in CgptGetPartitionDetails()
244 params->error_counter = GetErrorCounter(&drive, PRIMARY, index); in CgptGetPartitionDetails()
245 params->successful = GetSuccessful(&drive, PRIMARY, index); in CgptGetPartitionDetails()
246 params->tries = GetTries(&drive, PRIMARY, index); in CgptGetPartitionDetails()
247 params->priority = GetPriority(&drive, PRIMARY, index); in CgptGetPartitionDetails()
251 DriveClose(&drive, 0); in CgptGetPartitionDetails()
255 static int GptAdd(struct drive *drive, CgptAddParams *params, uint32_t index) { in GptAdd() argument
259 entry = GetEntry(&drive->gpt, PRIMARY, index); in GptAdd()
262 if (SetEntryAttributes(drive, index, params) || in GptAdd()
263 GptSetEntryAttributes(drive, index, params)) { in GptAdd()
268 UpdateAllEntries(drive); in GptAdd()
270 rv = CheckEntries((GptEntry*)drive->gpt.primary_entries, in GptAdd()
271 (GptHeader*)drive->gpt.primary_header); in GptAdd()
286 struct drive drive; in CgptAdd() local
292 if (CGPT_OK != DriveOpen(params->drive_name, &drive, O_RDWR, in CgptAdd()
296 if (CgptCheckAddValidity(&drive)) { in CgptAdd()
300 if (CgptGetUnusedPartition(&drive, &index, params)) { in CgptAdd()
304 if (GptAdd(&drive, params, index)) in CgptAdd()
308 return DriveClose(&drive, 1); in CgptAdd()
311 DriveClose(&drive, 0); in CgptAdd()