aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-04-11 19:17:59 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-04-11 19:17:59 +0200
commitac47a00e2ec398b04c3141cd3434a6e4b95740b1 (patch)
treef209d50c984c9ed59b9ebaf114119076ef65412a
parent1bc0bd13b5bdeb352db5261c1eec229fe4eb1651 (diff)
downloadbusybox-w32-ac47a00e2ec398b04c3141cd3434a6e4b95740b1.tar.gz
busybox-w32-ac47a00e2ec398b04c3141cd3434a6e4b95740b1.tar.bz2
busybox-w32-ac47a00e2ec398b04c3141cd3434a6e4b95740b1.zip
partprobe: new applet
function old new delta partprobe_main - 79 +79 packed_usage 31485 31511 +26 applet_names 2608 2618 +10 applet_main 1512 1516 +4 applet_install_loc 189 190 +1 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 4/0 up/down: 120/0) Total: 120 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--miscutils/partprobe.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/miscutils/partprobe.c b/miscutils/partprobe.c
new file mode 100644
index 000000000..38831598d
--- /dev/null
+++ b/miscutils/partprobe.c
@@ -0,0 +1,56 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * Copyright (C) 2017 Denys Vlasenko <vda.linux@googlemail.com>
4 *
5 * Licensed under GPLv2, see file LICENSE in this source tree.
6 */
7//config:config PARTPROBE
8//config: bool "partprobe"
9//config: default y
10//config: select PLATFORM_LINUX
11//config: help
12//config: Ask kernel to rescan partition table.
13
14//applet:IF_PARTPROBE(APPLET(partprobe, BB_DIR_USR_SBIN, BB_SUID_DROP))
15
16//kbuild:lib-$(CONFIG_PARTPROBE) += partprobe.o
17
18#include <linux/fs.h>
19#include "libbb.h"
20#ifndef BLKRRPART
21# define BLKRRPART _IO(0x12,95)
22#endif
23
24//usage:#define partprobe_trivial_usage
25//usage: "DEVICE..."
26//usage:#define partprobe_full_usage "\n\n"
27//usage: "Ask kernel to rescan partition table"
28//
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
32
33int partprobe_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
34int partprobe_main(int argc UNUSED_PARAM, char **argv)
35{
36 getopt32(argv, "");
37 argv += optind;
38
39 /* "partprobe" with no arguments just does nothing */
40
41 while (*argv) {
42 int fd = xopen(*argv, O_RDONLY);
43 /*
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:
49 */
50 ioctl_or_perror_and_die(fd, BLKRRPART, NULL, "%s", *argv);
51 close(fd);
52 argv++;
53 }
54
55 return EXIT_SUCCESS;
56}