1997-11-28 22:45:09 +08:00
|
|
|
/*
|
|
|
|
* partinfo.c
|
|
|
|
*
|
|
|
|
* Originally written by Alain Knaff, <alknaff@innet.lu>.
|
|
|
|
*
|
|
|
|
* Cleaned up by Theodore Ts'o, <tytso@mit.edu>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <linux/hdreg.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdlib.h>
|
1999-09-15 04:11:19 +08: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 08:47:55 +08:00
|
|
|
#include "nls-enable.h"
|
1997-11-28 22:45:09 +08:00
|
|
|
|
|
|
|
void print_error(char *operation, int error, char *device)
|
|
|
|
{
|
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 08:47:55 +08:00
|
|
|
fprintf(stderr, _("%s failed for %s: %s\n"), operation, device,
|
1997-11-28 22:45:09 +08:00
|
|
|
strerror(error));
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
struct hd_geometry loc;
|
1998-03-09 11:23:51 +08:00
|
|
|
int fd, i;
|
2001-05-24 06:29:22 +08:00
|
|
|
unsigned long size;
|
1997-11-28 22:45:09 +08: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 08:47:55 +08:00
|
|
|
#ifdef ENABLE_NLS
|
|
|
|
setlocale(LC_MESSAGES, "");
|
2002-03-05 16:26:52 +08: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 08:47:55 +08:00
|
|
|
bindtextdomain(NLS_CAT_NAME, LOCALEDIR);
|
|
|
|
textdomain(NLS_CAT_NAME);
|
|
|
|
#endif
|
1997-11-28 22:45:09 +08:00
|
|
|
if (argc == 1) {
|
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 08:47:55 +08:00
|
|
|
fprintf(stderr, _("Usage: %s <dev1> <dev2> <dev3>\n\n"
|
1997-11-28 22:45:09 +08:00
|
|
|
"This program prints out the partition information "
|
|
|
|
"for a set of devices\n"
|
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 08:47:55 +08:00
|
|
|
"A common way to use this program is:\n\n\t"
|
|
|
|
"%s /dev/hda?\n\n"), argv[0], argv[0]);
|
1997-11-28 22:45:09 +08:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i=1; i < argc; i++) {
|
|
|
|
fd = open(argv[i], O_RDONLY);
|
|
|
|
|
|
|
|
if (fd < 0) {
|
1999-09-15 04:11:19 +08:00
|
|
|
print_error("open", errno, argv[i]);
|
1997-11-28 22:45:09 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ioctl(fd, HDIO_GETGEO, &loc) < 0) {
|
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 08:47:55 +08:00
|
|
|
print_error(_("HDIO_GETGEO ioctl"), errno, argv[i]);
|
1997-11-28 22:45:09 +08:00
|
|
|
close(fd);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (ioctl(fd, BLKGETSIZE, &size) < 0) {
|
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 08:47:55 +08:00
|
|
|
print_error(_("BLKGETSIZE ioctl"), errno, argv[i]);
|
1997-11-28 22:45:09 +08:00
|
|
|
close(fd);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2001-05-24 06:29:22 +08:00
|
|
|
printf("%s: h=%3d s=%3d c=%4d start=%8d size=%8lu end=%8d\n",
|
1997-11-28 22:45:09 +08:00
|
|
|
argv[i],
|
|
|
|
loc.heads, (int)loc.sectors, loc.cylinders,
|
|
|
|
(int)loc.start, size, (int) loc.start + size -1);
|
|
|
|
close(fd);
|
|
|
|
}
|
|
|
|
exit(0);
|
|
|
|
}
|