X-Git-Url: http://git.grml.org/?p=grml-scripts.git;a=blobdiff_plain;f=compile%2Freread_partition_table.c;fp=compile%2Freread_partition_table.c;h=0000000000000000000000000000000000000000;hp=90f83a21939bef87ae6ef4c192443feddb57a50c;hb=c07e10f95b370c9e59461f6e4369cf6c2eab395e;hpb=5be17a0cbe05caf0a3baeee396ed01f1c7130ca7 diff --git a/compile/reread_partition_table.c b/compile/reread_partition_table.c deleted file mode 100644 index 90f83a2..0000000 --- a/compile/reread_partition_table.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Filename: reread_partition_table.c - * Purpose: re-read partition table on Linux - * Authors: grml-team (grml.org), (c) Michael Prokop - * Bug-Reports: see http://grml.org/bugs/ - * License: This file is licensed under the GPL v2. - *******************************************************************************/ - -// diet gcc -s -Os -o reread_partition_table reread_partition_table.c - -#include -#include -#include -#include -#include -#include -#include -#include - -void usage() -{ - printf("Usage: reread_partition_table \n"); -} - -int reread_partition_table(char *dev) -{ - int fd; - - sync(); - - if ((fd = open(dev, O_RDONLY)) < 0) { - perror("error opening device"); - return(1); - } - - if (ioctl(fd, BLKRRPART) < 0) { - perror("unable to reload partition table"); - return(1); - } - else { - printf("successfully reread partition table\n"); - return(0); - } -} - -int main(int argc, char** argv) -{ - if (getuid() != 0){ - printf("Error: reread_partition_table requires root permissions\n"); - exit(1); - } - - if (argc < 2) { - usage(); - exit(1); - } - else { - if (strncmp(argv[1], "/dev/", 5) != 0) { - printf("Invalid argument.\n"); - usage(); - exit(1); - } - reread_partition_table(argv[1]); - } - return EXIT_SUCCESS; -} - -/* END OF FILE ****************************************************************/