#include #include #include #include #include #include #include #include #include #include #include #include main() { int i, error, fd=open("/dev/sda", O_RDWR); printf("The partition table has been altered!\n\n"); printf("Calling ioctl() to re-read partition table.\n"); sync(); sleep(2); if (i = ioctl(fd, BLKRRPART)) { error = errno; } else { /* some kernel versions (1.2.x) seem to have trouble rereading the partition table, but if asked to do it twice, the second time works. - biro@yggdrasil.com */ sync(); sleep(2); if(i = ioctl(fd, BLKRRPART)) error = errno; } close(fd); printf("Syncing disks.\n"); sync(); sleep(4); /* for sync() */ return error; }