diff options
author | Karel Zak | 2017-06-30 11:24:36 +0200 |
---|---|---|
committer | Karel Zak | 2017-07-14 11:33:30 +0200 |
commit | 6a1889b03ba2f1b8de456c5f59d5a5722b83b295 (patch) | |
tree | e0568889f0edc65c90033bf324128943bf74f2ea /libfdisk/src | |
parent | libblkid: don't use CDROM_GET_CAPABILITY ioctl for DM devices (diff) | |
download | kernel-qcow2-util-linux-6a1889b03ba2f1b8de456c5f59d5a5722b83b295.tar.gz kernel-qcow2-util-linux-6a1889b03ba2f1b8de456c5f59d5a5722b83b295.tar.xz kernel-qcow2-util-linux-6a1889b03ba2f1b8de456c5f59d5a5722b83b295.zip |
libfdisk: move fdisk_reread_partition_table() to another file
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src')
-rw-r--r-- | libfdisk/src/alignment.c | 40 | ||||
-rw-r--r-- | libfdisk/src/context.c | 41 |
2 files changed, 41 insertions, 40 deletions
diff --git a/libfdisk/src/alignment.c b/libfdisk/src/alignment.c index e8393d9f2..6b395b48c 100644 --- a/libfdisk/src/alignment.c +++ b/libfdisk/src/alignment.c @@ -674,43 +674,3 @@ fdisk_sector_t fdisk_cround(struct fdisk_context *cxt, fdisk_sector_t num) (num / fdisk_get_units_per_sector(cxt)) + 1 : num; } -/** - * fdisk_reread_partition_table: - * @cxt: context - * - * Force *kernel* to re-read partition table on block devices. - * - * Returns: 0 on success, < 0 in case of error. - */ -int fdisk_reread_partition_table(struct fdisk_context *cxt) -{ - int i; - struct stat statbuf; - - assert(cxt); - assert(cxt->dev_fd >= 0); - - i = fstat(cxt->dev_fd, &statbuf); - if (i == 0 && S_ISBLK(statbuf.st_mode)) { - DBG(CXT, ul_debugobj(cxt, "calling re-read ioctl")); - sync(); -#ifdef BLKRRPART - fdisk_info(cxt, _("Calling ioctl() to re-read partition table.")); - i = ioctl(cxt->dev_fd, BLKRRPART); -#else - errno = ENOSYS; - i = 1; -#endif - } - - if (i) { - fdisk_warn(cxt, _("Re-reading the partition table failed.")); - fdisk_info(cxt, _( - "The kernel still uses the old table. The " - "new table will be used at the next reboot " - "or after you run partprobe(8) or kpartx(8).")); - return -errno; - } - - return 0; -} diff --git a/libfdisk/src/context.c b/libfdisk/src/context.c index 666ebbba0..9d5492be7 100644 --- a/libfdisk/src/context.c +++ b/libfdisk/src/context.c @@ -692,6 +692,47 @@ int fdisk_reassign_device(struct fdisk_context *cxt) } /** + * fdisk_reread_partition_table: + * @cxt: context + * + * Force *kernel* to re-read partition table on block devices. + * + * Returns: 0 on success, < 0 in case of error. + */ +int fdisk_reread_partition_table(struct fdisk_context *cxt) +{ + int i; + struct stat statbuf; + + assert(cxt); + assert(cxt->dev_fd >= 0); + + i = fstat(cxt->dev_fd, &statbuf); + if (i == 0 && S_ISBLK(statbuf.st_mode)) { + DBG(CXT, ul_debugobj(cxt, "calling re-read ioctl")); + sync(); +#ifdef BLKRRPART + fdisk_info(cxt, _("Calling ioctl() to re-read partition table.")); + i = ioctl(cxt->dev_fd, BLKRRPART); +#else + errno = ENOSYS; + i = 1; +#endif + } + + if (i) { + fdisk_warn(cxt, _("Re-reading the partition table failed.")); + fdisk_info(cxt, _( + "The kernel still uses the old table. The " + "new table will be used at the next reboot " + "or after you run partprobe(8) or kpartx(8).")); + return -errno; + } + + return 0; +} + +/** * fdisk_is_readonly: * @cxt: context * |