1 /* vi: set sw=4 ts=4: */
3 * Copyright (C) 2017 Denys Vlasenko <vda.linux@googlemail.com>
5 * Licensed under GPLv2, see file LICENSE in this source tree.
7 //config:config PARTPROBE
8 //config: bool "partprobe"
10 //config: select PLATFORM_LINUX
12 //config: Ask kernel to rescan partition table.
14 //applet:IF_PARTPROBE(APPLET(partprobe, BB_DIR_USR_SBIN, BB_SUID_DROP))
16 //kbuild:lib-$(CONFIG_PARTPROBE) += partprobe.o
21 # define BLKRRPART _IO(0x12,95)
24 //usage:#define partprobe_trivial_usage
26 //usage:#define partprobe_full_usage "\n\n"
27 //usage: "Ask kernel to rescan partition table"
29 // partprobe (GNU parted) 3.2:
30 // -d, --dry-run Don't update the kernel
31 // -s, --summary Show a summary of devices and their partitions
33 int partprobe_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
34 int partprobe_main(int argc UNUSED_PARAM, char **argv)
39 /* "partprobe" with no arguments just does nothing */
42 int fd = xopen(*argv, O_RDONLY);
44 * Newer versions of parted scan partition tables themselves and
45 * use BLKPG ioctl (BLKPG_DEL_PARTITION / BLKPG_ADD_PARTITION)
46 * since this way kernel does not need to know
47 * partition table formats.
48 * We use good old BLKRRPART:
50 ioctl_or_perror_and_die(fd, BLKRRPART, NULL, "%s", *argv);