4 * Originally written by Alain Knaff, <alknaff@innet.lu>.
6 * Cleaned up by Theodore Ts'o, <tytso@mit.edu>.
10 #include <sys/types.h>
12 #ifdef HAVE_SYS_IOCTL_H
13 #include <sys/ioctl.h>
16 #include <linux/hdreg.h>
20 #include "nls-enable.h"
22 #if defined(__linux__) && defined(_IO) && !defined(BLKGETSIZE)
23 #define BLKGETSIZE _IO(0x12,96) /* return device size */
26 int main(int argc, char **argv)
28 struct hd_geometry loc;
33 setlocale(LC_MESSAGES, "");
34 setlocale(LC_CTYPE, "");
35 bindtextdomain(NLS_CAT_NAME, LOCALEDIR);
36 textdomain(NLS_CAT_NAME);
39 fprintf(stderr, _("Usage: %s device...\n\nPrints out the "
40 "partition information for each given device.\n"
41 "For example: %s /dev/hda\n\n"), argv[0], argv[0]);
45 for (i=1; i < argc; i++) {
46 fd = open(argv[i], O_RDONLY);
49 fprintf(stderr, _("Cannot open %s: %s"),
50 argv[i], strerror(errno));
54 if (ioctl(fd, HDIO_GETGEO, &loc) < 0) {
55 fprintf(stderr, _("Cannot get geometry of %s: %s"),
56 argv[i], strerror(errno));
62 if (ioctl(fd, BLKGETSIZE, &size) < 0) {
63 fprintf(stderr, _("Cannot get size of %s: %s"),
64 argv[i], strerror(errno));
69 printf(_("%s: h=%3d s=%3d c=%4d start=%8d size=%8lu end=%8d\n"),
71 loc.heads, (int)loc.sectors, loc.cylinders,
72 (int)loc.start, size, (int) loc.start + size -1);