partprobe.c 669 B

123456789101112131415161718192021222324252627282930
  1. /* partprobe.c - Tell the kernel about partition table changes
  2. *
  3. * Copyright 2014 Bertold Van den Bergh <vandenbergh@bertold.org>
  4. *
  5. * see http://man7.org/linux/man-pages/man8/partprobe.8.html
  6. USE_PARTPROBE(NEWTOY(partprobe, "<1", TOYFLAG_SBIN))
  7. config PARTPROBE
  8. bool "partprobe"
  9. default y
  10. help
  11. usage: partprobe DEVICE...
  12. Tell the kernel about partition table changes
  13. Ask the kernel to re-read the partition table on the specified devices.
  14. */
  15. #include "toys.h"
  16. static void do_partprobe(int fd, char *name)
  17. {
  18. if (ioctl(fd, BLKRRPART, 0)) perror_msg("ioctl failed");
  19. }
  20. void partprobe_main(void)
  21. {
  22. loopfiles(toys.optargs, do_partprobe);
  23. }