summaryrefslogtreecommitdiffstats
path: root/fdisk
diff options
context:
space:
mode:
authorKarel Zak2006-12-07 00:25:52 +0100
committerKarel Zak2006-12-07 00:25:52 +0100
commit612721dba838fe37af543421278416bb7acf770c (patch)
treec9e54454cd39b2c26604446ee1a91fb2e9443ed4 /fdisk
parentImported from util-linux-2.11m tarball. (diff)
downloadkernel-qcow2-util-linux-612721dba838fe37af543421278416bb7acf770c.tar.gz
kernel-qcow2-util-linux-612721dba838fe37af543421278416bb7acf770c.tar.xz
kernel-qcow2-util-linux-612721dba838fe37af543421278416bb7acf770c.zip
Imported from util-linux-2.11n tarball.
Diffstat (limited to 'fdisk')
-rw-r--r--fdisk/cfdisk.84
-rw-r--r--fdisk/cfdisk.c160
-rw-r--r--fdisk/fdisk.84
-rw-r--r--fdisk/sfdisk.87
4 files changed, 113 insertions, 62 deletions
diff --git a/fdisk/cfdisk.8 b/fdisk/cfdisk.8
index 09dd54701..fc956d575 100644
--- a/fdisk/cfdisk.8
+++ b/fdisk/cfdisk.8
@@ -418,7 +418,9 @@ command (above) for more information on the print formats.
0: No errors; 1: Invocation error; 2: I/O error;
3: cannot get geometry; 4: bad partition table on disk.
.SH "SEE ALSO"
-fdisk(8)
+.BR fdisk (8),
+.BR parted (8),
+.BR sfdisk (8)
.SH BUGS
The current version does not support multiple disks.
.SH AUTHOR
diff --git a/fdisk/cfdisk.c b/fdisk/cfdisk.c
index f39fec619..656b1aea0 100644
--- a/fdisk/cfdisk.c
+++ b/fdisk/cfdisk.c
@@ -49,6 +49,8 @@
* Terabyte-sized disks.
* Sat Jun 30 05:23:19 EST 2001 <nathans@sgi.com>
* XFS label recognition.
+ * Thu Nov 22 15:42:56 CET 2001 <flavio.stanchina@tin.it>
+ * ext3 and ReiserFS recognition.
*
****************************************************************************/
@@ -399,8 +401,12 @@ partition_type_text(int i) {
else if (p_info[i].id == LINUX) {
if (!strcmp(p_info[i].fstype, "ext2"))
return _("Linux ext2");
+ else if (!strcmp(p_info[i].fstype, "ext3"))
+ return _("Linux ext3");
else if (!strcmp(p_info[i].fstype, "xfs"))
return _("Linux XFS");
+ else if (!strcmp(p_info[i].fstype, "reiserfs"))
+ return _("Linux ReiserFS");
else
return _("Linux");
} else if (p_info[i].id == OS2_OR_NTFS) {
@@ -593,84 +599,116 @@ dos_copy_to_info(char *to, int tosz, char *from, int fromsz) {
static void
get_dos_label(int i) {
- char sector[128];
+ char sector[128];
#define DOS_OSTYPE_OFFSET 3
#define DOS_LABEL_OFFSET 43
#define DOS_FSTYPE_OFFSET 54
#define DOS_OSTYPE_SZ 8
#define DOS_LABEL_SZ 11
#define DOS_FSTYPE_SZ 8
- ext2_loff_t offset;
-
- offset = ((ext2_loff_t) p_info[i].first_sector + p_info[i].offset)
- * SECTOR_SIZE;
- if (ext2_llseek(fd, offset, SEEK_SET) == offset
- && read(fd, &sector, sizeof(sector)) == sizeof(sector)) {
- dos_copy_to_info(p_info[i].ostype, OSTYPESZ,
- sector+DOS_OSTYPE_OFFSET, DOS_OSTYPE_SZ);
- dos_copy_to_info(p_info[i].volume_label, LABELSZ,
- sector+DOS_LABEL_OFFSET, DOS_LABEL_SZ);
- dos_copy_to_info(p_info[i].fstype, FSTYPESZ,
- sector+DOS_FSTYPE_OFFSET, DOS_FSTYPE_SZ);
- }
+ ext2_loff_t offset;
+
+ offset = ((ext2_loff_t) p_info[i].first_sector + p_info[i].offset)
+ * SECTOR_SIZE;
+ if (ext2_llseek(fd, offset, SEEK_SET) == offset
+ && read(fd, &sector, sizeof(sector)) == sizeof(sector)) {
+ dos_copy_to_info(p_info[i].ostype, OSTYPESZ,
+ sector+DOS_OSTYPE_OFFSET, DOS_OSTYPE_SZ);
+ dos_copy_to_info(p_info[i].volume_label, LABELSZ,
+ sector+DOS_LABEL_OFFSET, DOS_LABEL_SZ);
+ dos_copy_to_info(p_info[i].fstype, FSTYPESZ,
+ sector+DOS_FSTYPE_OFFSET, DOS_FSTYPE_SZ);
+ }
+}
+
+#define REISERFS_SUPER_MAGIC_STRING "ReIsErFs"
+#define REISER2FS_SUPER_MAGIC_STRING "ReIsEr2Fs"
+struct reiserfs_super_block {
+ char s_dummy0[ 52];
+ char s_magic [ 12];
+ char s_dummy1[140];
+};
+
+static int
+is_reiserfs_magic_string(const struct reiserfs_super_block *rs) {
+ return (!strncmp(rs->s_magic, REISERFS_SUPER_MAGIC_STRING,
+ strlen(REISERFS_SUPER_MAGIC_STRING)) ||
+ !strncmp(rs->s_magic, REISER2FS_SUPER_MAGIC_STRING,
+ strlen(REISER2FS_SUPER_MAGIC_STRING)));
}
static void
get_linux_label(int i) {
-#define EXT2_SUPER_MAGIC 0xEF53
#define EXT2LABELSZ 16
- struct ext2_super_block {
- char s_dummy0[56];
- unsigned char s_magic[2];
- char s_dummy1[62];
- char s_volume_name[EXT2LABELSZ];
- char s_last_mounted[64];
- char s_dummy2[824];
- } e2fsb;
+#define EXT2_SUPER_MAGIC 0xEF53
+#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
+ struct ext2_super_block {
+ char s_dummy0[56];
+ unsigned char s_magic[2];
+ char s_dummy1[34];
+ unsigned char s_feature_compat[4];
+ char s_dummy2[24];
+ char s_volume_name[EXT2LABELSZ];
+ char s_last_mounted[64];
+ char s_dummy3[824];
+ } e2fsb;
+
+#define REISERFS_DISK_OFFSET_IN_BYTES (64 * 1024)
+ struct reiserfs_super_block reiserfsb;
#define XFS_SUPER_MAGIC "XFSB"
#define XFSLABELSZ 12
- struct xfs_super_block {
- unsigned char s_magic[4];
- unsigned char s_dummy0[104];
- unsigned char s_fname[XFSLABELSZ];
- unsigned char s_dummy1[904];
- } xfsb;
-
- char *label;
- ext2_loff_t offset;
- int j;
+ struct xfs_super_block {
+ unsigned char s_magic[4];
+ unsigned char s_dummy0[104];
+ unsigned char s_fname[XFSLABELSZ];
+ unsigned char s_dummy1[904];
+ } xfsb;
+
+ char *label;
+ ext2_loff_t offset;
+ int j;
+
+ offset = ((ext2_loff_t) p_info[i].first_sector + p_info[i].offset)
+ * SECTOR_SIZE + 1024;
+ if (ext2_llseek(fd, offset, SEEK_SET) == offset
+ && read(fd, &e2fsb, sizeof(e2fsb)) == sizeof(e2fsb)
+ && e2fsb.s_magic[0] + (e2fsb.s_magic[1]<<8) == EXT2_SUPER_MAGIC) {
+ label = e2fsb.s_volume_name;
+ for(j=0; j<EXT2LABELSZ && j<LABELSZ && isprint(label[j]); j++)
+ p_info[i].volume_label[j] = label[j];
+ p_info[i].volume_label[j] = 0;
+ /* ext2 or ext3? */
+ if (e2fsb.s_feature_compat[0]&EXT3_FEATURE_COMPAT_HAS_JOURNAL)
+ strncpy(p_info[i].fstype, "ext3", FSTYPESZ);
+ else
+ strncpy(p_info[i].fstype, "ext2", FSTYPESZ);
+ return;
+ }
- offset = ((ext2_loff_t) p_info[i].first_sector + p_info[i].offset)
- * SECTOR_SIZE + 1024;
- if (ext2_llseek(fd, offset, SEEK_SET) == offset
- && read(fd, &e2fsb, sizeof(e2fsb)) == sizeof(e2fsb)
- && e2fsb.s_magic[0] + 256*e2fsb.s_magic[1] == EXT2_SUPER_MAGIC) {
- label = e2fsb.s_volume_name;
- for(j=0; j<EXT2LABELSZ; j++)
- if(!isprint(label[j]))
- label[j] = 0;
- label[EXT2LABELSZ] = 0;
- strncpy(p_info[i].volume_label, label, LABELSZ);
- strncpy(p_info[i].fstype, "ext2", FSTYPESZ);
- return;
- }
+ offset = ((ext2_loff_t) p_info[i].first_sector + p_info[i].offset)
+ * SECTOR_SIZE + 0;
+ if (ext2_llseek(fd, offset, SEEK_SET) == offset
+ && read(fd, &xfsb, sizeof(xfsb)) == sizeof(xfsb)
+ && !strcmp(xfsb.s_magic, XFS_SUPER_MAGIC)) {
+ label = xfsb.s_fname;
+ for(j=0; j<XFSLABELSZ && j<LABELSZ && isprint(label[j]); j++)
+ p_info[i].volume_label[j] = label[j];
+ p_info[i].volume_label[j] = 0;
+ strncpy(p_info[i].fstype, "xfs", FSTYPESZ);
+ return;
+ }
- offset = ((ext2_loff_t) p_info[i].first_sector + p_info[i].offset)
- * SECTOR_SIZE + 0;
- if (ext2_llseek(fd, offset, SEEK_SET) == offset
- && read(fd, &xfsb, sizeof(xfsb)) == sizeof(xfsb)
- && !strcmp(xfsb.s_magic, XFS_SUPER_MAGIC)) {
- label = xfsb.s_fname;
- for(j=0; j<XFSLABELSZ; j++)
- if(!isprint(label[j]))
- label[j] = 0;
- label[XFSLABELSZ] = 0;
- strncpy(p_info[i].volume_label, label, LABELSZ);
- strncpy(p_info[i].fstype, "xfs", FSTYPESZ);
- return;
- }
+ /* reiserfs? */
+ offset = ((ext2_loff_t) p_info[i].first_sector + p_info[i].offset)
+ * SECTOR_SIZE + REISERFS_DISK_OFFSET_IN_BYTES;
+ if (ext2_llseek(fd, offset, SEEK_SET) == offset
+ && read(fd, &reiserfsb, 1024) == 1024
+ && is_reiserfs_magic_string(&reiserfsb)) {
+ strncpy(p_info[i].fstype, "reiserfs", FSTYPESZ);
+ return;
+ }
}
static void
diff --git a/fdisk/fdisk.8 b/fdisk/fdisk.8
index aad93987b..fda58057c 100644
--- a/fdisk/fdisk.8
+++ b/fdisk/fdisk.8
@@ -225,3 +225,7 @@ The option `dump partition table to file' is missing.
.\" Jakub Jelinek (jj@sunsite.mff.cuni.cz)
.\" Andreas Neuper (ANeuper@GUUG.de)
.\" and many others.
+.SH "SEE ALSO"
+.BR cfdisk (8),
+.BR parted (8),
+.BR sfdisk (8)
diff --git a/fdisk/sfdisk.8 b/fdisk/sfdisk.8
index 0c62c2e96..c7b152e74 100644
--- a/fdisk/sfdisk.8
+++ b/fdisk/sfdisk.8
@@ -512,6 +512,13 @@ A corresponding interactive
(with curses interface) is still lacking.
.LP
There are too many options.
+.LP
+There is no support for non-DOS partition types.
.SH AUTHOR
A. E. Brouwer (aeb@cwi.nl)
+
+.SH "SEE ALSO"
+.BR cfdisk (8),
+.BR fdisk (8),
+.BR parted (8)