X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=compile%2Freread_partition_table.c;fp=compile%2Freread_partition_table.c;h=0000000000000000000000000000000000000000;hb=cdbec268696c1a0f91ed02d42ec56abbe3ef78e9;hp=90f83a21939bef87ae6ef4c192443feddb57a50c;hpb=80e422b789147a8706e450722c6e45bd42b3a5d1;p=grml-scripts-core.git 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 ****************************************************************/