summaryrefslogtreecommitdiffstats
path: root/fdisk
diff options
context:
space:
mode:
authorKarel Zak2006-12-07 00:26:30 +0100
committerKarel Zak2006-12-07 00:26:30 +0100
commita47f2e66141271cde40ee5190acf93d7878bc93d (patch)
treef41145d1e432fdb55aabcf600fb9311b7d83d75c /fdisk
parentImported from util-linux-2.12l tarball. (diff)
downloadkernel-qcow2-util-linux-a47f2e66141271cde40ee5190acf93d7878bc93d.tar.gz
kernel-qcow2-util-linux-a47f2e66141271cde40ee5190acf93d7878bc93d.tar.xz
kernel-qcow2-util-linux-a47f2e66141271cde40ee5190acf93d7878bc93d.zip
Imported from util-linux-2.12m tarball.
Diffstat (limited to 'fdisk')
-rw-r--r--fdisk/cfdisk.c71
-rw-r--r--fdisk/fdisk.c8
-rw-r--r--fdisk/i386_sys_types.c1
3 files changed, 68 insertions, 12 deletions
diff --git a/fdisk/cfdisk.c b/fdisk/cfdisk.c
index 149ee7619..9c0e7875c 100644
--- a/fdisk/cfdisk.c
+++ b/fdisk/cfdisk.c
@@ -51,6 +51,8 @@
* XFS label recognition.
* Thu Nov 22 15:42:56 CET 2001 <flavio.stanchina@tin.it>
* ext3 and ReiserFS recognition.
+ * Sun Oct 12 17:43:43 CEST 2003 <flavio.stanchina@tin.it>
+ * JFS recognition; ReiserFS label recognition.
*
****************************************************************************/
@@ -377,6 +379,8 @@ partition_type_text(int i) {
return _("Linux ext3");
else if (!strcmp(p_info[i].fstype, "xfs"))
return _("Linux XFS");
+ else if (!strcmp(p_info[i].fstype, "jfs"))
+ return _("Linux JFS");
else if (!strcmp(p_info[i].fstype, "reiserfs"))
return _("Linux ReiserFS");
else
@@ -595,17 +599,26 @@ get_dos_label(int i) {
#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];
+ char s_dummy0[52];
+ char s_magic [10];
+ char s_dummy1[38];
+ u_char s_label[16];
};
+#define REISERFSLABELSZ sizeof(reiserfsb.s_label)
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)));
+has_reiserfs_magic_string(const struct reiserfs_super_block *rs, int *is_3_6) {
+ if (!strncmp(rs->s_magic, REISERFS_SUPER_MAGIC_STRING,
+ strlen(REISERFS_SUPER_MAGIC_STRING))) {
+ *is_3_6 = 0;
+ return 1;
+ }
+ if (!strncmp(rs->s_magic, REISER2FS_SUPER_MAGIC_STRING,
+ strlen(REISER2FS_SUPER_MAGIC_STRING))) {
+ *is_3_6 = 1;
+ return 1;
+ }
+ return 0;
}
static void
@@ -627,6 +640,20 @@ get_linux_label(int i) {
#define REISERFS_DISK_OFFSET_IN_BYTES (64 * 1024)
struct reiserfs_super_block reiserfsb;
+ int reiserfs_is_3_6;
+
+#define JFS_SUPER1_OFF 0x8000
+#define JFS_MAGIC "JFS1"
+#define JFSLABELSZ 16
+ struct jfs_super_block {
+ char s_magic[4];
+ u_char s_version[4];
+ u_char s_dummy1[93];
+ char s_fpack[11];
+ u_char s_dummy2[24];
+ u_char s_uuid[16];
+ char s_label[JFSLABELSZ];
+ } jfsb;
#define XFS_SUPER_MAGIC "XFSB"
#define XFSLABELSZ 12
@@ -661,7 +688,7 @@ get_linux_label(int i) {
offset = (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)) {
+ && !strncmp(xfsb.s_magic, XFS_SUPER_MAGIC, 4)) {
label = xfsb.s_fname;
for(j=0; j<XFSLABELSZ && j<LABELSZ && isprint(label[j]); j++)
p_info[i].volume_label[j] = label[j];
@@ -670,12 +697,34 @@ get_linux_label(int i) {
return;
}
+ /* jfs? */
+ offset = (p_info[i].first_sector + p_info[i].offset) * SECTOR_SIZE
+ + JFS_SUPER1_OFF;
+ if (ext2_llseek(fd, offset, SEEK_SET) == offset
+ && read(fd, &jfsb, sizeof(jfsb)) == sizeof(jfsb)
+ && !strncmp(jfsb.s_magic, JFS_MAGIC, strlen(JFS_MAGIC))) {
+ label = jfsb.s_label;
+ for(j=0; j<JFSLABELSZ && 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, "jfs", FSTYPESZ);
+ return;
+ }
+
/* reiserfs? */
offset = (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)) {
+ && has_reiserfs_magic_string(&reiserfsb, &reiserfs_is_3_6)) {
+ if (reiserfs_is_3_6) {
+ /* label only on version 3.6 onward */
+ label = reiserfsb.s_label;
+ for(j=0; j<REISERFSLABELSZ && 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, "reiserfs", FSTYPESZ);
return;
}
@@ -2917,7 +2966,7 @@ main(int argc, char **argv)
break;
default:
usage(argv[0]);
- break;
+ exit(1);
}
}
break;
diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c
index a8385420c..1aafdd286 100644
--- a/fdisk/fdisk.c
+++ b/fdisk/fdisk.c
@@ -580,6 +580,9 @@ static int
warn_geometry(void) {
char *m = NULL;
int prev = 0;
+
+ if (sgi_label) /* cannot set cylinders etc anyway */
+ return 0;
if (!heads)
prev = test_c(&m, _("heads"));
if (!sectors)
@@ -2190,7 +2193,10 @@ reread_partition_table(int leave) {
"information.\n"));
if (leave) {
- close(fd);
+ if (fsync(fd) || close(fd)) {
+ fprintf(stderr, _("\nError closing file\n"));
+ exit(1);
+ }
printf(_("Syncing disks.\n"));
sync();
diff --git a/fdisk/i386_sys_types.c b/fdisk/i386_sys_types.c
index fb70b0851..e08a9b2a5 100644
--- a/fdisk/i386_sys_types.c
+++ b/fdisk/i386_sys_types.c
@@ -59,6 +59,7 @@ struct systypes i386_sys_types[] = {
{0x85, N_("Linux extended")},
{0x86, N_("NTFS volume set")},
{0x87, N_("NTFS volume set")},
+ {0x88, N_("Linux plaintext")},
{0x8e, N_("Linux LVM")},
{0x93, N_("Amoeba")},
{0x94, N_("Amoeba BBT")}, /* (bad block table) */