Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
#include <config.h> |
20 |
#include <config.h> |
21 |
#include <arch/linux.h> |
21 |
#include <arch/linux.h> |
22 |
|
22 |
#include <linux/blkpg.h> |
23 |
#include <parted/parted.h> |
23 |
#include <parted/parted.h> |
24 |
#include <parted/debug.h> |
24 |
#include <parted/debug.h> |
25 |
#if defined __s390__ || defined __s390x__ |
25 |
#if defined __s390__ || defined __s390x__ |
Lines 249-259
Link Here
|
249 |
#define UBD_MAJOR 98 |
249 |
#define UBD_MAJOR 98 |
250 |
#define DASD_MAJOR 94 |
250 |
#define DASD_MAJOR 94 |
251 |
#define VIODASD_MAJOR 112 |
251 |
#define VIODASD_MAJOR 112 |
|
|
252 |
#define AOE_MAJOR 152 |
252 |
#define SX8_MAJOR1 160 |
253 |
#define SX8_MAJOR1 160 |
253 |
#define SX8_MAJOR2 161 |
254 |
#define SX8_MAJOR2 161 |
254 |
#define XVD_MAJOR 202 |
255 |
#define XVD_MAJOR 202 |
255 |
#define SDMMC_MAJOR 179 |
256 |
#define SDMMC_MAJOR 179 |
256 |
#define LOOP_MAJOR 7 |
257 |
#define LOOP_MAJOR 7 |
|
|
258 |
#define MD_MAJOR 9 |
257 |
|
259 |
|
258 |
#define SCSI_BLK_MAJOR(M) ( \ |
260 |
#define SCSI_BLK_MAJOR(M) ( \ |
259 |
(M) == SCSI_DISK0_MAJOR \ |
261 |
(M) == SCSI_DISK0_MAJOR \ |
Lines 540-545
Link Here
|
540 |
dev->type = PED_DEVICE_DAC960; |
542 |
dev->type = PED_DEVICE_DAC960; |
541 |
} else if (dev_major == ATARAID_MAJOR && (dev_minor % 0x10 == 0)) { |
543 |
} else if (dev_major == ATARAID_MAJOR && (dev_minor % 0x10 == 0)) { |
542 |
dev->type = PED_DEVICE_ATARAID; |
544 |
dev->type = PED_DEVICE_ATARAID; |
|
|
545 |
} else if (dev_major == AOE_MAJOR && (dev_minor % 0x10 == 0)) { |
546 |
dev->type = PED_DEVICE_AOE; |
543 |
} else if (dev_major == DASD_MAJOR && (dev_minor % 0x4 == 0)) { |
547 |
} else if (dev_major == DASD_MAJOR && (dev_minor % 0x4 == 0)) { |
544 |
dev->type = PED_DEVICE_DASD; |
548 |
dev->type = PED_DEVICE_DASD; |
545 |
} else if (dev_major == VIODASD_MAJOR && (dev_minor % 0x8 == 0)) { |
549 |
} else if (dev_major == VIODASD_MAJOR && (dev_minor % 0x8 == 0)) { |
Lines 571-576
Link Here
|
571 |
dev->type = PED_DEVICE_VIRTBLK; |
575 |
dev->type = PED_DEVICE_VIRTBLK; |
572 |
} else if (dev_major == LOOP_MAJOR) { |
576 |
} else if (dev_major == LOOP_MAJOR) { |
573 |
dev->type = PED_DEVICE_FILE; |
577 |
dev->type = PED_DEVICE_FILE; |
|
|
578 |
} else if (dev_major == MD_MAJOR) { |
579 |
dev->type = PED_DEVICE_MD; |
574 |
} else { |
580 |
} else { |
575 |
dev->type = PED_DEVICE_UNKNOWN; |
581 |
dev->type = PED_DEVICE_UNKNOWN; |
576 |
} |
582 |
} |
Lines 684-699
Link Here
|
684 |
dev->sector_size = PED_SECTOR_SIZE_DEFAULT; |
690 |
dev->sector_size = PED_SECTOR_SIZE_DEFAULT; |
685 |
} |
691 |
} |
686 |
#endif |
692 |
#endif |
687 |
|
|
|
688 |
if (dev->sector_size != PED_SECTOR_SIZE_DEFAULT) { |
689 |
ped_exception_throw ( |
690 |
PED_EXCEPTION_WARNING, |
691 |
PED_EXCEPTION_OK, |
692 |
_("Device %s has a logical sector size of %lld. Not " |
693 |
"all parts of GNU Parted support this at the moment, " |
694 |
"and the working code is HIGHLY EXPERIMENTAL.\n"), |
695 |
dev->path, dev->sector_size); |
696 |
} |
697 |
} |
693 |
} |
698 |
|
694 |
|
699 |
static int |
695 |
static int |
Lines 1313-1318
Link Here
|
1313 |
goto error_free_arch_specific; |
1309 |
goto error_free_arch_specific; |
1314 |
break; |
1310 |
break; |
1315 |
|
1311 |
|
|
|
1312 |
case PED_DEVICE_AOE: |
1313 |
if (!init_generic (dev, _("ATA over Ethernet Device"))) |
1314 |
goto error_free_arch_specific; |
1315 |
break; |
1316 |
|
1316 |
#if defined __s390__ || defined __s390x__ |
1317 |
#if defined __s390__ || defined __s390x__ |
1317 |
case PED_DEVICE_DASD: |
1318 |
case PED_DEVICE_DASD: |
1318 |
if (!init_dasd (dev, _("IBM S390 DASD drive"))) |
1319 |
if (!init_dasd (dev, _("IBM S390 DASD drive"))) |
Lines 1383-1388
Link Here
|
1383 |
goto error_free_arch_specific; |
1384 |
goto error_free_arch_specific; |
1384 |
break; |
1385 |
break; |
1385 |
|
1386 |
|
|
|
1387 |
case PED_DEVICE_MD: |
1388 |
if (!init_generic(dev, _("Linux Software RAID Array"))) |
1389 |
goto error_free_arch_specific; |
1390 |
break; |
1391 |
|
1386 |
default: |
1392 |
default: |
1387 |
ped_exception_throw (PED_EXCEPTION_NO_FEATURE, |
1393 |
ped_exception_throw (PED_EXCEPTION_NO_FEATURE, |
1388 |
PED_EXCEPTION_CANCEL, |
1394 |
PED_EXCEPTION_CANCEL, |
Lines 2299-2304
Link Here
|
2299 |
return 0; |
2305 |
return 0; |
2300 |
} |
2306 |
} |
2301 |
|
2307 |
|
|
|
2308 |
static int |
2309 |
_blkpg_part_command (PedDevice* dev, struct blkpg_partition* part, int op) |
2310 |
{ |
2311 |
LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev); |
2312 |
struct blkpg_ioctl_arg ioctl_arg; |
2313 |
|
2314 |
ioctl_arg.op = op; |
2315 |
ioctl_arg.flags = 0; |
2316 |
ioctl_arg.datalen = sizeof (struct blkpg_partition); |
2317 |
ioctl_arg.data = (void*) part; |
2318 |
|
2319 |
return ioctl (arch_specific->fd, BLKPG, &ioctl_arg) == 0; |
2320 |
} |
2321 |
|
2322 |
static int |
2323 |
_blkpg_add_partition (PedDisk* disk, const PedPartition *part) |
2324 |
{ |
2325 |
struct blkpg_partition linux_part; |
2326 |
const char* vol_name; |
2327 |
char* dev_name; |
2328 |
|
2329 |
PED_ASSERT(disk != NULL, return 0); |
2330 |
PED_ASSERT(disk->dev->sector_size % PED_SECTOR_SIZE_DEFAULT == 0, |
2331 |
return 0); |
2332 |
|
2333 |
if (!_has_partitions (disk)) |
2334 |
return 0; |
2335 |
|
2336 |
if (ped_disk_type_check_feature (disk->type, |
2337 |
PED_DISK_TYPE_PARTITION_NAME)) |
2338 |
vol_name = ped_partition_get_name (part); |
2339 |
else |
2340 |
vol_name = NULL; |
2341 |
|
2342 |
dev_name = _device_get_part_path (disk->dev, part->num); |
2343 |
if (!dev_name) |
2344 |
return 0; |
2345 |
|
2346 |
memset (&linux_part, 0, sizeof (linux_part)); |
2347 |
linux_part.start = part->geom.start * disk->dev->sector_size; |
2348 |
/* see fs/partitions/msdos.c:msdos_partition(): "leave room for LILO" */ |
2349 |
if (part->type & PED_PARTITION_EXTENDED) |
2350 |
linux_part.length = part->geom.length == 1 ? 512 : 1024; |
2351 |
else |
2352 |
linux_part.length = part->geom.length * disk->dev->sector_size; |
2353 |
linux_part.pno = part->num; |
2354 |
strncpy (linux_part.devname, dev_name, BLKPG_DEVNAMELTH); |
2355 |
if (vol_name) |
2356 |
strncpy (linux_part.volname, vol_name, BLKPG_VOLNAMELTH); |
2357 |
|
2358 |
free (dev_name); |
2359 |
|
2360 |
if (!_blkpg_part_command (disk->dev, &linux_part, |
2361 |
BLKPG_ADD_PARTITION)) { |
2362 |
return ped_exception_throw ( |
2363 |
PED_EXCEPTION_ERROR, |
2364 |
PED_EXCEPTION_IGNORE_CANCEL, |
2365 |
_("Error informing the kernel about modifications to " |
2366 |
"partition %s -- %s. This means Linux won't know " |
2367 |
"about any changes you made to %s until you reboot " |
2368 |
"-- so you shouldn't mount it or use it in any way " |
2369 |
"before rebooting."), |
2370 |
linux_part.devname, |
2371 |
strerror (errno), |
2372 |
linux_part.devname) |
2373 |
== PED_EXCEPTION_IGNORE; |
2374 |
} |
2375 |
|
2376 |
return 1; |
2377 |
} |
2378 |
|
2379 |
static int |
2380 |
_blkpg_remove_partition (PedDisk* disk, int n) |
2381 |
{ |
2382 |
struct blkpg_partition linux_part; |
2383 |
|
2384 |
if (!_has_partitions (disk)) |
2385 |
return 0; |
2386 |
|
2387 |
memset (&linux_part, 0, sizeof (linux_part)); |
2388 |
linux_part.pno = n; |
2389 |
return _blkpg_part_command (disk->dev, &linux_part, |
2390 |
BLKPG_DEL_PARTITION); |
2391 |
} |
2392 |
|
2393 |
/* |
2394 |
* The number of partitions that a device can have depends on the kernel. |
2395 |
* If we don't find this value in /sys/block/DEV/range, we will use our own |
2396 |
* value. |
2397 |
*/ |
2398 |
static unsigned int |
2399 |
_device_get_partition_range(PedDevice* dev) |
2400 |
{ |
2401 |
int range, r; |
2402 |
char path[128]; |
2403 |
FILE* fp; |
2404 |
bool ok; |
2405 |
|
2406 |
r = snprintf(path, sizeof(path), "/sys/block/%s/range", |
2407 |
last_component(dev->path)); |
2408 |
if (r < 0 || r >= sizeof(path)) |
2409 |
return MAX_NUM_PARTS; |
2410 |
|
2411 |
fp = fopen(path, "r"); |
2412 |
if (!fp) |
2413 |
return MAX_NUM_PARTS; |
2414 |
|
2415 |
ok = fscanf(fp, "%d", &range) == 1; |
2416 |
fclose(fp); |
2417 |
|
2418 |
/* (range <= 0) is none sense.*/ |
2419 |
return ok && range > 0 ? range : MAX_NUM_PARTS; |
2420 |
} |
2421 |
|
2422 |
/* |
2423 |
* Sync the partition table in two step process: |
2424 |
* 1. Remove all of the partitions from the kernel's tables, but do not attempt |
2425 |
* removal of any partition for which the corresponding ioctl call fails. |
2426 |
* 2. Add all the partitions that we hold in disk, throwing a warning |
2427 |
* if we cannot because step 1 failed to remove it and it is not being |
2428 |
* added back with the same start and length. |
2429 |
* |
2430 |
* To achieve this two step process we must calculate the minimum number of |
2431 |
* maximum possible partitions between what linux supports and what the label |
2432 |
* type supports. EX: |
2433 |
* |
2434 |
* number=MIN(max_parts_supported_in_linux,max_parts_supported_in_msdos_tables) |
2435 |
*/ |
2436 |
static int |
2437 |
_disk_sync_part_table (PedDisk* disk) |
2438 |
{ |
2439 |
PED_ASSERT(disk != NULL, return 0); |
2440 |
PED_ASSERT(disk->dev != NULL, return 0); |
2441 |
int lpn; |
2442 |
|
2443 |
/* lpn = largest partition number. */ |
2444 |
if (ped_disk_get_max_supported_partition_count(disk, &lpn)) |
2445 |
lpn = PED_MIN(lpn, _device_get_partition_range(disk->dev)); |
2446 |
else |
2447 |
lpn = _device_get_partition_range(disk->dev); |
2448 |
|
2449 |
/* Its not possible to support largest_partnum < 0. |
2450 |
* largest_partnum == 0 would mean does not support partitions. |
2451 |
* */ |
2452 |
if (lpn < 0) |
2453 |
return 0; |
2454 |
int ret = 0; |
2455 |
int *ok = calloc (lpn, sizeof *ok); |
2456 |
if (!ok) |
2457 |
return 0; |
2458 |
int *errnums = ped_malloc(sizeof(int) * lpn); |
2459 |
if (!errnums) |
2460 |
goto cleanup; |
2461 |
|
2462 |
/* Attempt to remove each and every partition, retrying for |
2463 |
up to max_sleep_seconds upon any failure due to EBUSY. */ |
2464 |
unsigned int sleep_microseconds = 10000; |
2465 |
unsigned int max_sleep_seconds = 1; |
2466 |
unsigned int n_sleep = (max_sleep_seconds |
2467 |
* 1000000 / sleep_microseconds); |
2468 |
int i; |
2469 |
for (i = 0; i < n_sleep; i++) { |
2470 |
if (i) |
2471 |
usleep (sleep_microseconds); |
2472 |
bool busy = false; |
2473 |
int j; |
2474 |
for (j = 0; j < lpn; j++) { |
2475 |
if (!ok[j]) { |
2476 |
ok[j] = _blkpg_remove_partition (disk, j + 1); |
2477 |
errnums[j] = errno; |
2478 |
if (!ok[j] && errnums[j] == EBUSY) |
2479 |
busy = true; |
2480 |
} |
2481 |
} |
2482 |
if (!busy) |
2483 |
break; |
2484 |
} |
2485 |
|
2486 |
for (i = 1; i <= lpn; i++) { |
2487 |
const PedPartition *part = ped_disk_get_partition (disk, i); |
2488 |
if (part) { |
2489 |
if (!ok[i - 1] && errnums[i - 1] == EBUSY) { |
2490 |
struct hd_geometry geom; |
2491 |
unsigned long long length = 0; |
2492 |
/* get start and length of existing partition */ |
2493 |
char *dev_name = _device_get_part_path (disk->dev, i); |
2494 |
if (!dev_name) |
2495 |
goto cleanup; |
2496 |
int fd = open (dev_name, O_RDONLY); |
2497 |
if (fd == -1 |
2498 |
|| ioctl (fd, HDIO_GETGEO, &geom) |
2499 |
|| ioctl (fd, BLKGETSIZE64, &length)) { |
2500 |
ped_exception_throw ( |
2501 |
PED_EXCEPTION_BUG, |
2502 |
PED_EXCEPTION_CANCEL, |
2503 |
_("Unable to determine the size and length of %s."), |
2504 |
dev_name); |
2505 |
if (fd != -1) |
2506 |
close (fd); |
2507 |
free (dev_name); |
2508 |
goto cleanup; |
2509 |
} |
2510 |
free (dev_name); |
2511 |
length /= disk->dev->sector_size; |
2512 |
close (fd); |
2513 |
if (geom.start == part->geom.start |
2514 |
&& length == part->geom.length) |
2515 |
ok[i - 1] = 1; |
2516 |
/* If the new partition is unchanged and the |
2517 |
existing one was not removed because it was |
2518 |
in use, then reset the error flag and do not |
2519 |
try to add it since it is already there. */ |
2520 |
continue; |
2521 |
} |
2522 |
|
2523 |
/* add the (possibly modified or new) partition */ |
2524 |
if (!_blkpg_add_partition (disk, part)) { |
2525 |
ped_exception_throw ( |
2526 |
PED_EXCEPTION_ERROR, |
2527 |
PED_EXCEPTION_RETRY_CANCEL, |
2528 |
_("Failed to add partition %d (%s)"), |
2529 |
i, strerror (errno)); |
2530 |
goto cleanup; |
2531 |
} |
2532 |
} |
2533 |
} |
2534 |
|
2535 |
char *bad_part_list = NULL; |
2536 |
/* now warn about any errors */ |
2537 |
for (i = 1; i <= lpn; i++) { |
2538 |
if (ok[i - 1] || errnums[i - 1] == ENXIO) |
2539 |
continue; |
2540 |
if (bad_part_list == NULL) { |
2541 |
bad_part_list = malloc (lpn * 5); |
2542 |
if (!bad_part_list) |
2543 |
goto cleanup; |
2544 |
bad_part_list[0] = 0; |
2545 |
} |
2546 |
sprintf (bad_part_list + strlen (bad_part_list), "%d, ", i); |
2547 |
} |
2548 |
if (bad_part_list == NULL) |
2549 |
ret = 1; |
2550 |
else { |
2551 |
bad_part_list[strlen (bad_part_list) - 2] = 0; |
2552 |
if (ped_exception_throw ( |
2553 |
PED_EXCEPTION_ERROR, |
2554 |
PED_EXCEPTION_IGNORE_CANCEL, |
2555 |
_("Partition(s) %s on %s have been written, but we have " |
2556 |
"been unable to inform the kernel of the change, " |
2557 |
"probably because it/they are in use. As a result, " |
2558 |
"the old partition(s) will remain in use. You " |
2559 |
"should reboot now before making further changes."), |
2560 |
bad_part_list, disk->dev->path) == PED_EXCEPTION_IGNORE) |
2561 |
ret = 1; |
2562 |
free (bad_part_list); |
2563 |
} |
2564 |
cleanup: |
2565 |
free (errnums); |
2566 |
free (ok); |
2567 |
return ret; |
2568 |
} |
2569 |
|
2302 |
#ifdef ENABLE_DEVICE_MAPPER |
2570 |
#ifdef ENABLE_DEVICE_MAPPER |
2303 |
static int |
2571 |
static int |
2304 |
_dm_remove_map_name(char *name) |
2572 |
_dm_remove_map_name(char *name) |
Lines 2315-2321
Link Here
|
2315 |
rc = dm_task_run(task); |
2583 |
rc = dm_task_run(task); |
2316 |
dm_task_update_nodes(); |
2584 |
dm_task_update_nodes(); |
2317 |
dm_task_destroy(task); |
2585 |
dm_task_destroy(task); |
2318 |
if (rc < 0) |
2586 |
if (!rc) |
2319 |
return 1; |
2587 |
return 1; |
2320 |
|
2588 |
|
2321 |
return 0; |
2589 |
return 0; |
Lines 2335-2346
Link Here
|
2335 |
return 0; |
2603 |
return 0; |
2336 |
|
2604 |
|
2337 |
dm_task_set_name(task, name); |
2605 |
dm_task_set_name(task, name); |
2338 |
rc = dm_task_run(task); |
2606 |
if (!dm_task_run(task)) |
2339 |
if (rc < 0) { |
|
|
2340 |
rc = 0; |
2341 |
goto err; |
2607 |
goto err; |
2342 |
} |
|
|
2343 |
rc = 0; |
2344 |
|
2608 |
|
2345 |
memset(info, '\0', sizeof *info); |
2609 |
memset(info, '\0', sizeof *info); |
2346 |
dm_task_get_info(task, info); |
2610 |
dm_task_get_info(task, info); |
Lines 2351-2357
Link Here
|
2351 |
if (!deps) |
2615 |
if (!deps) |
2352 |
goto err; |
2616 |
goto err; |
2353 |
|
2617 |
|
2354 |
rc = 0; |
|
|
2355 |
for (i = 0; i < deps->count; i++) { |
2618 |
for (i = 0; i < deps->count; i++) { |
2356 |
unsigned int ma = major(deps->device[i]), |
2619 |
unsigned int ma = major(deps->device[i]), |
2357 |
mi = minor(deps->device[i]); |
2620 |
mi = minor(deps->device[i]); |
Lines 2383-2390
Link Here
|
2383 |
arch_specific->minor, 0)) |
2646 |
arch_specific->minor, 0)) |
2384 |
goto err; |
2647 |
goto err; |
2385 |
|
2648 |
|
2386 |
rc = dm_task_run(task); |
2649 |
if (!dm_task_run(task)) |
2387 |
if (rc < 0) |
|
|
2388 |
goto err; |
2650 |
goto err; |
2389 |
|
2651 |
|
2390 |
memset(info, '\0', sizeof *info); |
2652 |
memset(info, '\0', sizeof *info); |
Lines 2426-2432
Link Here
|
2426 |
static int |
2688 |
static int |
2427 |
_dm_add_partition (PedDisk* disk, PedPartition* part) |
2689 |
_dm_add_partition (PedDisk* disk, PedPartition* part) |
2428 |
{ |
2690 |
{ |
2429 |
int rc; |
|
|
2430 |
char* vol_name = NULL; |
2691 |
char* vol_name = NULL; |
2431 |
const char* dev_name = NULL; |
2692 |
const char* dev_name = NULL; |
2432 |
char* params = NULL; |
2693 |
char* params = NULL; |
Lines 2444-2451
Link Here
|
2444 |
arch_specific->minor, 0)) |
2705 |
arch_specific->minor, 0)) |
2445 |
goto err; |
2706 |
goto err; |
2446 |
|
2707 |
|
2447 |
rc = dm_task_run(task); |
2708 |
if (!dm_task_run(task)) |
2448 |
if (rc < 0) |
|
|
2449 |
goto err; |
2709 |
goto err; |
2450 |
|
2710 |
|
2451 |
dev_name = dm_task_get_name (task); |
2711 |
dev_name = dm_task_get_name (task); |
Lines 2468-2475
Link Here
|
2468 |
dm_task_set_name (task, vol_name); |
2728 |
dm_task_set_name (task, vol_name); |
2469 |
dm_task_add_target (task, 0, part->geom.length, |
2729 |
dm_task_add_target (task, 0, part->geom.length, |
2470 |
"linear", params); |
2730 |
"linear", params); |
2471 |
rc = dm_task_run (task); |
2731 |
if (dm_task_run (task)) { |
2472 |
if (rc >= 0) { |
|
|
2473 |
//printf("0 %ld linear %s\n", part->geom.length, params); |
2732 |
//printf("0 %ld linear %s\n", part->geom.length, params); |
2474 |
dm_task_update_nodes(); |
2733 |
dm_task_update_nodes(); |
2475 |
dm_task_destroy(task); |
2734 |
dm_task_destroy(task); |
Lines 2518-2569
Link Here
|
2518 |
#endif |
2777 |
#endif |
2519 |
|
2778 |
|
2520 |
static int |
2779 |
static int |
2521 |
_kernel_reread_part_table (PedDevice* dev) |
2780 |
_have_blkpg () |
2522 |
{ |
2781 |
{ |
2523 |
LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev); |
2782 |
static int have_blkpg = -1; |
2524 |
int retry_count = 9; |
2783 |
int kver; |
2525 |
|
|
|
2526 |
sync(); |
2527 |
while (ioctl (arch_specific->fd, BLKRRPART)) { |
2528 |
retry_count--; |
2529 |
sync(); |
2530 |
if (retry_count == 3) |
2531 |
sleep(1); /* Pause to allow system to settle */ |
2532 |
|
2784 |
|
2533 |
if (!retry_count) { |
2785 |
if (have_blkpg != -1) |
2534 |
ped_exception_throw ( |
2786 |
return have_blkpg; |
2535 |
PED_EXCEPTION_WARNING, |
|
|
2536 |
PED_EXCEPTION_IGNORE, |
2537 |
_("WARNING: the kernel failed to re-read the partition " |
2538 |
"table on %s (%s). As a result, it may not " |
2539 |
"reflect all of your changes until after reboot."), |
2540 |
dev->path, strerror (errno)); |
2541 |
return 0; |
2542 |
} |
2543 |
} |
2544 |
|
2787 |
|
2545 |
return 1; |
2788 |
kver = _get_linux_version(); |
|
|
2789 |
return have_blkpg = kver >= KERNEL_VERSION (2,4,0) ? 1 : 0; |
2546 |
} |
2790 |
} |
2547 |
|
2791 |
|
|
|
2792 |
/* Return nonzero upon success, 0 if something fails. */ |
2548 |
static int |
2793 |
static int |
2549 |
linux_disk_commit (PedDisk* disk) |
2794 |
linux_disk_commit (PedDisk* disk) |
2550 |
{ |
2795 |
{ |
2551 |
if (!_has_partitions (disk)) |
2796 |
if (!_has_partitions (disk)) |
2552 |
return 1; |
2797 |
return 1; |
2553 |
|
2798 |
|
2554 |
#ifdef ENABLE_DEVICE_MAPPER |
2799 |
#ifdef ENABLE_DEVICE_MAPPER |
2555 |
if (disk->dev->type == PED_DEVICE_DM) |
2800 |
if (disk->dev->type == PED_DEVICE_DM) |
2556 |
return _dm_reread_part_table (disk); |
2801 |
return _dm_reread_part_table (disk); |
2557 |
#endif |
2802 |
#endif |
2558 |
if (disk->dev->type != PED_DEVICE_FILE) { |
2803 |
if (disk->dev->type != PED_DEVICE_FILE) { |
2559 |
return _kernel_reread_part_table (disk->dev); |
2804 |
/* The ioctl() command BLKPG_ADD_PARTITION does not notify |
|
|
2805 |
* the devfs system; consequently, /proc/partitions will not |
2806 |
* be up to date, and the proper links in /dev are not |
2807 |
* created. Therefore, if using DevFS, we must get the kernel |
2808 |
* to re-read and grok the partition table. |
2809 |
*/ |
2810 |
/* Work around kernel dasd problem so we really do BLKRRPART */ |
2811 |
int ok = 1; |
2812 |
if (disk->dev->type != PED_DEVICE_DASD && _have_blkpg ()) { |
2813 |
if (!_disk_sync_part_table (disk)) |
2814 |
ok = 0; |
2815 |
} |
2816 |
|
2817 |
return ok; |
2560 |
} |
2818 |
} |
2561 |
|
2819 |
|
2562 |
return 1; |
2820 |
return 1; |
2563 |
} |
2821 |
} |
2564 |
|
2822 |
|
2565 |
#if USE_BLKID |
2823 |
#if USE_BLKID |
2566 |
PedAlignment* |
2824 |
static PedAlignment* |
2567 |
linux_get_minimum_alignment(const PedDevice *dev) |
2825 |
linux_get_minimum_alignment(const PedDevice *dev) |
2568 |
{ |
2826 |
{ |
2569 |
blkid_topology tp = LINUX_SPECIFIC(dev)->topology; |
2827 |
blkid_topology tp = LINUX_SPECIFIC(dev)->topology; |
Lines 2581-2587
Link Here
|
2581 |
blkid_topology_get_minimum_io_size(tp) / dev->sector_size); |
2839 |
blkid_topology_get_minimum_io_size(tp) / dev->sector_size); |
2582 |
} |
2840 |
} |
2583 |
|
2841 |
|
2584 |
PedAlignment* |
2842 |
static PedAlignment* |
2585 |
linux_get_optimum_alignment(const PedDevice *dev) |
2843 |
linux_get_optimum_alignment(const PedDevice *dev) |
2586 |
{ |
2844 |
{ |
2587 |
blkid_topology tp = LINUX_SPECIFIC(dev)->topology; |
2845 |
blkid_topology tp = LINUX_SPECIFIC(dev)->topology; |