4 * Originally written by Alain Knaff, <alknaff@innet.lu>.
6 * Cleaned up by Theodore Ts'o, <tytso@mit.edu>.
10 #include <sys/types.h>
13 #include <linux/hdreg.h>
17 #include "nls-enable.h"
19 void print_error(char *operation, int error, char *device)
21 fprintf(stderr, _("%s failed for %s: %s\n"), operation, device,
25 int main(int argc, char **argv)
27 struct hd_geometry loc;
32 setlocale(LC_MESSAGES, "");
33 setlocale(LC_CTYPE, "");
34 bindtextdomain(NLS_CAT_NAME, LOCALEDIR);
35 textdomain(NLS_CAT_NAME);
38 fprintf(stderr, _("Usage: %s <dev1> <dev2> <dev3>\n\n"
39 "This program prints out the partition information "
40 "for a set of devices\n"
41 "A common way to use this program is:\n\n\t"
42 "%s /dev/hda?\n\n"), argv[0], argv[0]);
46 for (i=1; i < argc; i++) {
47 fd = open(argv[i], O_RDONLY);
50 print_error("open", errno, argv[i]);
54 if (ioctl(fd, HDIO_GETGEO, &loc) < 0) {
55 print_error(_("HDIO_GETGEO ioctl"), errno, argv[i]);
61 if (ioctl(fd, BLKGETSIZE, &size) < 0) {
62 print_error(_("BLKGETSIZE ioctl"), errno, argv[i]);
67 printf("%s: h=%3d s=%3d c=%4d start=%8d size=%8lu end=%8d\n",
69 loc.heads, (int)loc.sectors, loc.cylinders,
70 (int)loc.start, size, (int) loc.start + size -1);