4 * Originally written by Alain Knaff, <alknaff@innet.lu>.
6 * Cleaned up by Theodore Ts'o, <tytso@mit.edu>.
10 #include <sys/types.h>
14 #include <linux/hdreg.h>
18 void print_error(char *operation, int error, char *device)
20 fprintf(stderr, "%s failed for %s: %s\n", operation, device,
24 int main(int argc, char **argv)
26 struct hd_geometry loc;
31 fprintf(stderr, "Usage: %s <dev1> <dev2> <dev3>\n\n"
32 "This program prints out the partition information "
33 "for a set of devices\n"
34 "A common way to use this progrma is:\n\n\t"
35 "%s /dev/hda?\n\n", argv[0], argv[0]);
39 for (i=1; i < argc; i++) {
40 fd = open(argv[i], O_RDONLY);
43 print_error("open", errno, argv[1]);
47 if (ioctl(fd, HDIO_GETGEO, &loc) < 0) {
48 print_error("HDIO_GETGEO ioctl", errno, argv[1]);
54 if (ioctl(fd, BLKGETSIZE, &size) < 0) {
55 print_error("BLKGETSIZE ioctl", errno, argv[1]);
60 printf("%s: h=%3d s=%3d c=%4d start=%8d size=%8d end=%8d\n",
62 loc.heads, (int)loc.sectors, loc.cylinders,
63 (int)loc.start, size, (int) loc.start + size -1);