Lines Matching refs:drive
68 static int GptSetEntryAttributes(struct drive *drive, in GptSetEntryAttributes() argument
73 entry = GetEntry(&drive->gpt, PRIMARY, index); in GptSetEntryAttributes()
100 static int SetEntryAttributes(struct drive *drive, in SetEntryAttributes() argument
104 SetRaw(drive, PRIMARY, index, params->raw_value); in SetEntryAttributes()
107 SetSuccessful(drive, PRIMARY, index, params->successful); in SetEntryAttributes()
109 SetTries(drive, PRIMARY, index, params->tries); in SetEntryAttributes()
111 SetPriority(drive, PRIMARY, index, params->priority); in SetEntryAttributes()
115 if (IsUnused(drive, PRIMARY, index)) { in SetEntryAttributes()
129 static int CgptCheckAddValidity(struct drive *drive) { in CgptCheckAddValidity() argument
131 if (GPT_SUCCESS != (gpt_retval = GptSanityCheck(&drive->gpt))) { in CgptCheckAddValidity()
137 if (((drive->gpt.valid_headers & MASK_BOTH) != MASK_BOTH) || in CgptCheckAddValidity()
138 ((drive->gpt.valid_entries & MASK_BOTH) != MASK_BOTH)) { in CgptCheckAddValidity()
147 static int CgptGetUnusedPartition(struct drive *drive, uint32_t *index, in CgptGetUnusedPartition() argument
150 uint32_t max_part = GetNumberOfEntries(drive); in CgptGetUnusedPartition()
161 if (IsUnused(drive, PRIMARY, i)) { in CgptGetUnusedPartition()
173 struct drive drive; in CgptSetAttributes() local
178 if (CGPT_OK != DriveOpen(params->drive_name, &drive, O_RDWR, in CgptSetAttributes()
182 if (CgptCheckAddValidity(&drive)) { in CgptSetAttributes()
187 params->partition >= GetNumberOfEntries(&drive)) { in CgptSetAttributes()
192 SetEntryAttributes(&drive, params->partition - 1, params); in CgptSetAttributes()
194 UpdateAllEntries(&drive); in CgptSetAttributes()
197 return DriveClose(&drive, 1); in CgptSetAttributes()
200 DriveClose(&drive, 0); in CgptSetAttributes()
209 struct drive drive; in CgptGetPartitionDetails() local
216 if (CGPT_OK != DriveOpen(params->drive_name, &drive, O_RDWR, in CgptGetPartitionDetails()
220 if (CgptCheckAddValidity(&drive)) { in CgptGetPartitionDetails()
224 int max_part = GetNumberOfEntries(&drive); in CgptGetPartitionDetails()
236 GptEntry *entry = GetEntry(&drive.gpt, PRIMARY, index); in CgptGetPartitionDetails()
250 GptEntry *entry = GetEntry(&drive.gpt, PRIMARY, index); in CgptGetPartitionDetails()
257 params->successful = GetSuccessful(&drive, PRIMARY, index); in CgptGetPartitionDetails()
258 params->tries = GetTries(&drive, PRIMARY, index); in CgptGetPartitionDetails()
259 params->priority = GetPriority(&drive, PRIMARY, index); in CgptGetPartitionDetails()
263 DriveClose(&drive, 0); in CgptGetPartitionDetails()
267 static int GptAdd(struct drive *drive, CgptAddParams *params, uint32_t index) { in GptAdd() argument
271 entry = GetEntry(&drive->gpt, PRIMARY, index); in GptAdd()
274 if (SetEntryAttributes(drive, index, params) || in GptAdd()
275 GptSetEntryAttributes(drive, index, params)) { in GptAdd()
280 UpdateAllEntries(drive); in GptAdd()
282 rv = CheckEntries((GptEntry*)drive->gpt.primary_entries, in GptAdd()
283 (GptHeader*)drive->gpt.primary_header); in GptAdd()
297 struct drive drive; in CgptAdd() local
303 if (CGPT_OK != DriveOpen(params->drive_name, &drive, O_RDWR, in CgptAdd()
307 if (CgptCheckAddValidity(&drive)) { in CgptAdd()
311 if (CgptGetUnusedPartition(&drive, &index, params)) { in CgptAdd()
315 if (GptAdd(&drive, params, index)) in CgptAdd()
319 return DriveClose(&drive, 1); in CgptAdd()
322 DriveClose(&drive, 0); in CgptAdd()