view toys/other/partprobe.c @ 1676:cbb1aca81eca draft

Make toy_exec() check if argc is in optargs and deal with it there so we don't need a separate xexec_optargs().
author Rob Landley <rob@landley.net>
date Sat, 07 Feb 2015 16:17:44 -0600
parents 5662f0664060
children
line wrap: on
line source

/* partprobe.c - Tell the kernel about partition table changes
 *
 * Copyright 2014 Bertold Van den Bergh <vandenbergh@bertold.org>
 *
 * see http://man7.org/linux/man-pages/man8/partprobe.8.html

USE_PARTPROBE(NEWTOY(partprobe, "<1", TOYFLAG_SBIN))

config PARTPROBE
  bool "partprobe"
  default y
  help
    usage: partprobe DEVICE...

    Tell the kernel about partition table changes

    Ask the kernel to re-read the partition table on the specified devices.
*/

#include "toys.h"

static void do_partprobe(int fd, char *name)
{
  if (ioctl(fd, BLKRRPART, 0)) perror_msg("ioctl failed");
}

void partprobe_main(void)
{
  loopfiles(toys.optargs, do_partprobe); 
}