1997-11-28 17:45:09 +03:00
|
|
|
/*
|
|
|
|
* partinfo.c
|
|
|
|
*
|
|
|
|
* Originally written by Alain Knaff, <alknaff@innet.lu>.
|
|
|
|
*
|
|
|
|
* Cleaned up by Theodore Ts'o, <tytso@mit.edu>.
|
2008-08-28 07:07:54 +04:00
|
|
|
*
|
1997-11-28 17:45:09 +03:00
|
|
|
*/
|
|
|
|
|
2011-09-19 01:34:37 +04:00
|
|
|
#include "config.h"
|
1997-11-28 17:45:09 +03:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <fcntl.h>
|
2005-06-20 16:35:27 +04:00
|
|
|
#ifdef HAVE_SYS_IOCTL_H
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#endif
|
1997-11-28 17:45:09 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <linux/hdreg.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdlib.h>
|
1999-09-15 00:11:19 +04:00
|
|
|
#include <errno.h>
|
Many files:
badblocks.c, chattr.c, dumpe2fs.c, e2label.c, findsuper.c, fsck.c,
get_device_by_label.c, lsattr.c, mke2fs.c, mklost+found.c,
nls-enable.h, partinfo.c, tune2fs.c, uuidgen.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-08 03:47:55 +03:00
|
|
|
#include "nls-enable.h"
|
1997-11-28 17:45:09 +03:00
|
|
|
|
2005-06-20 16:35:27 +04:00
|
|
|
#if defined(__linux__) && defined(_IO) && !defined(BLKGETSIZE)
|
|
|
|
#define BLKGETSIZE _IO(0x12,96) /* return device size */
|
|
|
|
#endif
|
|
|
|
|
1997-11-28 17:45:09 +03:00
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
struct hd_geometry loc;
|
1998-03-09 06:23:51 +03:00
|
|
|
int fd, i;
|
2001-05-24 02:29:22 +04:00
|
|
|
unsigned long size;
|
1997-11-28 17:45:09 +03:00
|
|
|
|
Many files:
badblocks.c, chattr.c, dumpe2fs.c, e2label.c, findsuper.c, fsck.c,
get_device_by_label.c, lsattr.c, mke2fs.c, mklost+found.c,
nls-enable.h, partinfo.c, tune2fs.c, uuidgen.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-08 03:47:55 +03:00
|
|
|
#ifdef ENABLE_NLS
|
|
|
|
setlocale(LC_MESSAGES, "");
|
2002-03-05 11:26:52 +03:00
|
|
|
setlocale(LC_CTYPE, "");
|
Many files:
badblocks.c, chattr.c, dumpe2fs.c, e2label.c, findsuper.c, fsck.c,
get_device_by_label.c, lsattr.c, mke2fs.c, mklost+found.c,
nls-enable.h, partinfo.c, tune2fs.c, uuidgen.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-08 03:47:55 +03:00
|
|
|
bindtextdomain(NLS_CAT_NAME, LOCALEDIR);
|
|
|
|
textdomain(NLS_CAT_NAME);
|
2011-10-05 09:00:30 +04:00
|
|
|
set_com_err_gettext(gettext);
|
Many files:
badblocks.c, chattr.c, dumpe2fs.c, e2label.c, findsuper.c, fsck.c,
get_device_by_label.c, lsattr.c, mke2fs.c, mklost+found.c,
nls-enable.h, partinfo.c, tune2fs.c, uuidgen.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-08 03:47:55 +03:00
|
|
|
#endif
|
1997-11-28 17:45:09 +03:00
|
|
|
if (argc == 1) {
|
2008-07-17 18:50:26 +04:00
|
|
|
fprintf(stderr, _("Usage: %s device...\n\nPrints out the "
|
2008-07-24 00:50:04 +04:00
|
|
|
"partition information for each given device.\n"
|
|
|
|
"For example: %s /dev/hda\n\n"), argv[0], argv[0]);
|
1997-11-28 17:45:09 +03:00
|
|
|
exit(1);
|
|
|
|
}
|
2008-08-28 07:07:54 +04:00
|
|
|
|
1997-11-28 17:45:09 +03:00
|
|
|
for (i=1; i < argc; i++) {
|
|
|
|
fd = open(argv[i], O_RDONLY);
|
|
|
|
|
|
|
|
if (fd < 0) {
|
2008-07-18 01:46:49 +04:00
|
|
|
fprintf(stderr, _("Cannot open %s: %s"),
|
|
|
|
argv[i], strerror(errno));
|
1997-11-28 17:45:09 +03:00
|
|
|
continue;
|
|
|
|
}
|
2008-08-28 07:07:54 +04:00
|
|
|
|
1997-11-28 17:45:09 +03:00
|
|
|
if (ioctl(fd, HDIO_GETGEO, &loc) < 0) {
|
2008-07-18 01:46:49 +04:00
|
|
|
fprintf(stderr, _("Cannot get geometry of %s: %s"),
|
|
|
|
argv[i], strerror(errno));
|
1997-11-28 17:45:09 +03:00
|
|
|
close(fd);
|
|
|
|
continue;
|
|
|
|
}
|
2008-08-28 07:07:54 +04:00
|
|
|
|
|
|
|
|
1997-11-28 17:45:09 +03:00
|
|
|
if (ioctl(fd, BLKGETSIZE, &size) < 0) {
|
2008-07-18 01:46:49 +04:00
|
|
|
fprintf(stderr, _("Cannot get size of %s: %s"),
|
|
|
|
argv[i], strerror(errno));
|
1997-11-28 17:45:09 +03:00
|
|
|
close(fd);
|
|
|
|
continue;
|
|
|
|
}
|
2008-08-28 07:07:54 +04:00
|
|
|
|
2008-07-18 01:46:49 +04:00
|
|
|
printf(_("%s: h=%3d s=%3d c=%4d start=%8d size=%8lu end=%8d\n"),
|
2008-08-28 07:07:54 +04:00
|
|
|
argv[i],
|
1997-11-28 17:45:09 +03:00
|
|
|
loc.heads, (int)loc.sectors, loc.cylinders,
|
|
|
|
(int)loc.start, size, (int) loc.start + size -1);
|
|
|
|
close(fd);
|
|
|
|
}
|
|
|
|
exit(0);
|
|
|
|
}
|