Received: (from majordomo@localhost) by oss.sgi.com (8.11.2/8.11.3) id f5TLsxD25836 for linux-xfs-outgoing; Fri, 29 Jun 2001 14:54:59 -0700 Received: from sgi.com (sgi.SGI.COM [192.48.153.1]) by oss.sgi.com (8.11.2/8.11.3) with SMTP id f5TLsvV25833 for ; Fri, 29 Jun 2001 14:54:57 -0700 Received: from larry.melbourne.sgi.com (larry.melbourne.sgi.com [134.14.52.130]) by sgi.com (980327.SGI.8.8.8-aspam/980304.SGI-aspam: SGI does not authorize the use of its proprietary systems or networks for unsolicited or bulk email from the Internet.) via SMTP id OAA08421 for ; Fri, 29 Jun 2001 14:54:55 -0700 (PDT) mail_from (nathans@wobbly.melbourne.sgi.com) Received: from wobbly.melbourne.sgi.com (wobbly.melbourne.sgi.com [134.14.55.135]) by larry.melbourne.sgi.com (950413.SGI.8.6.12/950213.SGI.AUTOCF) via ESMTP id HAA04291; Sat, 30 Jun 2001 07:53:39 +1000 Received: (from nathans@localhost) by wobbly.melbourne.sgi.com (SGI-8.9.3/8.9.3) id HAA82626; Sat, 30 Jun 2001 07:53:38 +1000 (EST) Date: Sat, 30 Jun 2001 07:53:37 +1000 From: Nathan Scott To: Roger Moore Cc: linux-xfs@oss.sgi.com Subject: [patch] Re: Label based mounts with fsck Message-ID: <20010630075337.A165960@wobbly.melbourne.sgi.com> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="M9NhX3UHpAaciwkO" X-Mailer: Mutt 1.0us In-Reply-To: ; from rwmoore@fnal.gov on Thu, Jun 28, 2001 at 04:46:02PM -0500 Sender: owner-linux-xfs@oss.sgi.com Precedence: bulk --M9NhX3UHpAaciwkO Content-Type: text/plain; charset=us-ascii hi Roger, On Thu, Jun 28, 2001 at 04:46:02PM -0500, Roger Moore wrote: > Hi, > > We've just updated our cluster to use XFS and have noticed a problem with > using 'LABEL=xxx' in the fstab file. > > The 'mount' command works fine with XFS labels (once you turn off devfs!). > However the problem lies with the fsck command. The RedHat 7.1 system we > have runs 'fsck -A...' at boot time which is needed for the remaining ext2 > partitions. This complains that it cannont find 'LABEL=xxx' for XFS > partitions even when we configure /etc/fstab has f_passno=0 for the XFS > mounts. Is there a patch out there for fsck to fix this problem? > could you try the attached patch and let me know how it goes? I think we're getting bitten by the use of DEFAULT_FSTYPE (ext2) in the fsck_device() routine... this should fix that. > We are currently using e2fsprogs-1.21 from RawHide since it is needed for > the 2.4.5-0.2.9 RawHide kernel which you have patched. > the patch is against e2fsprogs-1.22, but this code doesn't seem to have changed for awhile and should patch cleanly to 1.21 too. if it works, let me know & I'll forward on to Ted. thanks. -- Nathan --M9NhX3UHpAaciwkO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="fsck.patch" diff -Naur e2fsprogs-1.22/misc/get_device_by_label.c e2fsprogs/misc/get_device_by_label.c --- e2fsprogs-1.22/misc/get_device_by_label.c Sat Jun 23 06:25:59 2001 +++ e2fsprogs/misc/get_device_by_label.c Sat Jun 30 01:39:54 2001 @@ -48,6 +48,16 @@ }; #define ext2magic(s) ((unsigned int) s.s_magic[0] + (((unsigned int) s.s_magic[1]) << 8)) +#define XFS_SUPER_MAGIC "XFSB" +#define XFS_SUPER_MAGIC2 "BSFX" +struct xfs_super_block { + unsigned char s_magic[4]; + unsigned char s_dummy[28]; + unsigned char s_uuid[16]; + unsigned char s_dummy2[60]; + unsigned char s_fname[12]; +}; + static struct uuidCache_s { struct uuidCache_s *next; char uuid[16]; @@ -55,35 +65,44 @@ char *device; } *uuidCache = NULL; -/* for now, only ext2 is supported */ +/* for now, only ext2 and xfs are supported */ static int get_label_uuid(const char *device, char **label, char *uuid) { - /* start with a test for ext2, taken from mount_guess_fstype */ + /* start with ext2 and xfs tests, taken from mount_guess_fstype */ /* should merge these later */ int fd; + int rv = 1; + size_t namesize; struct ext2_super_block e2sb; + struct xfs_super_block xfsb; fd = open(device, O_RDONLY); if (fd < 0) - return 1; + return rv; - if (lseek(fd, 1024, SEEK_SET) != 1024 - || read(fd, (char *) &e2sb, sizeof(e2sb)) != sizeof(e2sb) - || (ext2magic(e2sb) != EXT2_SUPER_MAGIC)) { - close(fd); - return 1; + if (lseek(fd, 1024, SEEK_SET) == 1024 + && read(fd, (char *) &e2sb, sizeof(e2sb)) == sizeof(e2sb) + && (ext2magic(e2sb) == EXT2_SUPER_MAGIC)) { + memcpy(uuid, e2sb.s_uuid, sizeof(e2sb.s_uuid)); + namesize = sizeof(e2sb.s_volume_name); + if ((*label = calloc(namesize + 1, 1)) != NULL) + memcpy(*label, e2sb.s_volume_name, namesize); + rv = 0; + } + else if (lseek(fd, 0, SEEK_SET) == 0 + && read(fd, (char *) &xfsb, sizeof(xfsb)) == sizeof(xfsb) + && (strncmp((char *) &xfsb.s_magic, XFS_SUPER_MAGIC, 4) == 0 || + strncmp((char *) &xfsb.s_magic, XFS_SUPER_MAGIC2,4) == 0)) { + memcpy(uuid, xfsb.s_uuid, sizeof(xfsb.s_uuid)); + namesize = sizeof(xfsb.s_fname); + if ((*label = calloc(namesize + 1, 1)) != NULL) + memcpy(*label, xfsb.s_fname, namesize); + rv = 0; } close(fd); - - /* superblock is ext2 - now what is its label? */ - memcpy(uuid, e2sb.s_uuid, sizeof(e2sb.s_uuid)); - - *label = calloc(sizeof(e2sb.s_volume_name) + 1, 1); - memcpy(*label, e2sb.s_volume_name, sizeof(e2sb.s_volume_name)); - - return 0; + return rv; } static void --M9NhX3UHpAaciwkO--