annotate toys/other/partprobe.c @ 1746:b11f536bac74 draft

install -D bugfix from David Halls. (I tweaked some comment text while I was there.)
author Rob Landley <rob@landley.net>
date Sat, 21 Mar 2015 15:49:38 -0500
parents 5662f0664060
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1317
94e143a0089f I have attached a patch adding a program that allows re-reading the partition table. This is often used on embedded systems booting from SD/USB devices that need to resize partitions on first boot.
Bertold Van den Bergh <vandenbergh@bertold.org>
parents:
diff changeset
1 /* partprobe.c - Tell the kernel about partition table changes
94e143a0089f I have attached a patch adding a program that allows re-reading the partition table. This is often used on embedded systems booting from SD/USB devices that need to resize partitions on first boot.
Bertold Van den Bergh <vandenbergh@bertold.org>
parents:
diff changeset
2 *
94e143a0089f I have attached a patch adding a program that allows re-reading the partition table. This is often used on embedded systems booting from SD/USB devices that need to resize partitions on first boot.
Bertold Van den Bergh <vandenbergh@bertold.org>
parents:
diff changeset
3 * Copyright 2014 Bertold Van den Bergh <vandenbergh@bertold.org>
94e143a0089f I have attached a patch adding a program that allows re-reading the partition table. This is often used on embedded systems booting from SD/USB devices that need to resize partitions on first boot.
Bertold Van den Bergh <vandenbergh@bertold.org>
parents:
diff changeset
4 *
94e143a0089f I have attached a patch adding a program that allows re-reading the partition table. This is often used on embedded systems booting from SD/USB devices that need to resize partitions on first boot.
Bertold Van den Bergh <vandenbergh@bertold.org>
parents:
diff changeset
5 * see http://man7.org/linux/man-pages/man8/partprobe.8.html
94e143a0089f I have attached a patch adding a program that allows re-reading the partition table. This is often used on embedded systems booting from SD/USB devices that need to resize partitions on first boot.
Bertold Van den Bergh <vandenbergh@bertold.org>
parents:
diff changeset
6
1328
a498d143be72 Cleanup partprobe.
Rob Landley <rob@landley.net>
parents: 1317
diff changeset
7 USE_PARTPROBE(NEWTOY(partprobe, "<1", TOYFLAG_SBIN))
1317
94e143a0089f I have attached a patch adding a program that allows re-reading the partition table. This is often used on embedded systems booting from SD/USB devices that need to resize partitions on first boot.
Bertold Van den Bergh <vandenbergh@bertold.org>
parents:
diff changeset
8
94e143a0089f I have attached a patch adding a program that allows re-reading the partition table. This is often used on embedded systems booting from SD/USB devices that need to resize partitions on first boot.
Bertold Van den Bergh <vandenbergh@bertold.org>
parents:
diff changeset
9 config PARTPROBE
94e143a0089f I have attached a patch adding a program that allows re-reading the partition table. This is often used on embedded systems booting from SD/USB devices that need to resize partitions on first boot.
Bertold Van den Bergh <vandenbergh@bertold.org>
parents:
diff changeset
10 bool "partprobe"
1329
5662f0664060 Promote partprobe.
Rob Landley <rob@landley.net>
parents: 1328
diff changeset
11 default y
1317
94e143a0089f I have attached a patch adding a program that allows re-reading the partition table. This is often used on embedded systems booting from SD/USB devices that need to resize partitions on first boot.
Bertold Van den Bergh <vandenbergh@bertold.org>
parents:
diff changeset
12 help
1328
a498d143be72 Cleanup partprobe.
Rob Landley <rob@landley.net>
parents: 1317
diff changeset
13 usage: partprobe DEVICE...
1317
94e143a0089f I have attached a patch adding a program that allows re-reading the partition table. This is often used on embedded systems booting from SD/USB devices that need to resize partitions on first boot.
Bertold Van den Bergh <vandenbergh@bertold.org>
parents:
diff changeset
14
1328
a498d143be72 Cleanup partprobe.
Rob Landley <rob@landley.net>
parents: 1317
diff changeset
15 Tell the kernel about partition table changes
a498d143be72 Cleanup partprobe.
Rob Landley <rob@landley.net>
parents: 1317
diff changeset
16
a498d143be72 Cleanup partprobe.
Rob Landley <rob@landley.net>
parents: 1317
diff changeset
17 Ask the kernel to re-read the partition table on the specified devices.
1317
94e143a0089f I have attached a patch adding a program that allows re-reading the partition table. This is often used on embedded systems booting from SD/USB devices that need to resize partitions on first boot.
Bertold Van den Bergh <vandenbergh@bertold.org>
parents:
diff changeset
18 */
94e143a0089f I have attached a patch adding a program that allows re-reading the partition table. This is often used on embedded systems booting from SD/USB devices that need to resize partitions on first boot.
Bertold Van den Bergh <vandenbergh@bertold.org>
parents:
diff changeset
19
94e143a0089f I have attached a patch adding a program that allows re-reading the partition table. This is often used on embedded systems booting from SD/USB devices that need to resize partitions on first boot.
Bertold Van den Bergh <vandenbergh@bertold.org>
parents:
diff changeset
20 #include "toys.h"
94e143a0089f I have attached a patch adding a program that allows re-reading the partition table. This is often used on embedded systems booting from SD/USB devices that need to resize partitions on first boot.
Bertold Van den Bergh <vandenbergh@bertold.org>
parents:
diff changeset
21
1328
a498d143be72 Cleanup partprobe.
Rob Landley <rob@landley.net>
parents: 1317
diff changeset
22 static void do_partprobe(int fd, char *name)
1317
94e143a0089f I have attached a patch adding a program that allows re-reading the partition table. This is often used on embedded systems booting from SD/USB devices that need to resize partitions on first boot.
Bertold Van den Bergh <vandenbergh@bertold.org>
parents:
diff changeset
23 {
1328
a498d143be72 Cleanup partprobe.
Rob Landley <rob@landley.net>
parents: 1317
diff changeset
24 if (ioctl(fd, BLKRRPART, 0)) perror_msg("ioctl failed");
1317
94e143a0089f I have attached a patch adding a program that allows re-reading the partition table. This is often used on embedded systems booting from SD/USB devices that need to resize partitions on first boot.
Bertold Van den Bergh <vandenbergh@bertold.org>
parents:
diff changeset
25 }
94e143a0089f I have attached a patch adding a program that allows re-reading the partition table. This is often used on embedded systems booting from SD/USB devices that need to resize partitions on first boot.
Bertold Van den Bergh <vandenbergh@bertold.org>
parents:
diff changeset
26
94e143a0089f I have attached a patch adding a program that allows re-reading the partition table. This is often used on embedded systems booting from SD/USB devices that need to resize partitions on first boot.
Bertold Van den Bergh <vandenbergh@bertold.org>
parents:
diff changeset
27 void partprobe_main(void)
94e143a0089f I have attached a patch adding a program that allows re-reading the partition table. This is often used on embedded systems booting from SD/USB devices that need to resize partitions on first boot.
Bertold Van den Bergh <vandenbergh@bertold.org>
parents:
diff changeset
28 {
1328
a498d143be72 Cleanup partprobe.
Rob Landley <rob@landley.net>
parents: 1317
diff changeset
29 loopfiles(toys.optargs, do_partprobe);
1317
94e143a0089f I have attached a patch adding a program that allows re-reading the partition table. This is often used on embedded systems booting from SD/USB devices that need to resize partitions on first boot.
Bertold Van den Bergh <vandenbergh@bertold.org>
parents:
diff changeset
30 }