aboutsummaryrefslogtreecommitdiff
path: root/toys/pending/partprobe.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2014-05-31 17:59:27 -0500
committerRob Landley <rob@landley.net>2014-05-31 17:59:27 -0500
commit4d22a09d76ef09a169db48a4d6599d8a5fe547ad (patch)
treebcce5f64f50ac79225e90870532ee2f4618d64c1 /toys/pending/partprobe.c
parentd8872c43b48eae5501998a4e5a84337017d8fbe6 (diff)
downloadtoybox-4d22a09d76ef09a169db48a4d6599d8a5fe547ad.tar.gz
Cleanup partprobe.
Diffstat (limited to 'toys/pending/partprobe.c')
-rw-r--r--toys/pending/partprobe.c37
1 files changed, 8 insertions, 29 deletions
diff --git a/toys/pending/partprobe.c b/toys/pending/partprobe.c
index 2fe3bd53..e0beb009 100644
--- a/toys/pending/partprobe.c
+++ b/toys/pending/partprobe.c
@@ -4,48 +4,27 @@
*
* see http://man7.org/linux/man-pages/man8/partprobe.8.html
-USE_PARTPROBE(NEWTOY(partprobe, NULL, TOYFLAG_SBIN))
+USE_PARTPROBE(NEWTOY(partprobe, "<1", TOYFLAG_SBIN))
config PARTPROBE
bool "partprobe"
default n
help
- partprobe - Tell the kernel about partition table changes
-
- usage: partprobe [devices...]
+ usage: partprobe DEVICE...
- Asks the kernel to re-read the partition table on the specified
- devices.
+ Tell the kernel about partition table changes
+
+ Ask the kernel to re-read the partition table on the specified devices.
*/
#include "toys.h"
-void update_device(char* path)
+static void do_partprobe(int fd, char *name)
{
- int sd_fd = open(path, 0);
-
- if(sd_fd < 0){
- perror_msg("Unable to open %s", path);
- return;
- }
-
- if(ioctl(sd_fd, BLKRRPART, NULL) < 0)
- perror_msg("ioctl (BLKRRPART) failed, old layout still used");
-
- close(sd_fd);
+ if (ioctl(fd, BLKRRPART, 0)) perror_msg("ioctl failed");
}
void partprobe_main(void)
{
- char** opt;
- if(*toys.optargs == NULL){
- printf("No devices specified.\n");
- exit(EXIT_FAILURE);
- }
-
- for (opt = toys.optargs; *opt; opt++) {
- update_device(*opt);
- }
-
- exit(EXIT_SUCCESS);
+ loopfiles(toys.optargs, do_partprobe);
}