Received: (from majordomo@localhost) by oss.sgi.com (8.11.2/8.11.3) id f5TMBaI28773 for linux-xfs-outgoing; Fri, 29 Jun 2001 15:11:36 -0700 Received: from deliverator.sgi.com (deliverator.sgi.com [204.94.214.10]) by oss.sgi.com (8.11.2/8.11.3) with SMTP id f5TMBXV28770 for ; Fri, 29 Jun 2001 15:11:34 -0700 Received: from larry.melbourne.sgi.com (larry.melbourne.sgi.com [134.14.52.130]) by deliverator.sgi.com (980309.SGI.8.8.8-aspam-6.2/980310.SGI-aspam) via SMTP id PAA23048 for ; Fri, 29 Jun 2001 15:11:26 -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 IAA04382 for ; Sat, 30 Jun 2001 08:10:16 +1000 Received: (from nathans@localhost) by wobbly.melbourne.sgi.com (SGI-8.9.3/8.9.3) id IAA78613 for linux-xfs@oss.sgi.com; Sat, 30 Jun 2001 08:10:15 +1000 (EST) Date: Sat, 30 Jun 2001 08:10:15 +1000 From: Nathan Scott To: linux-xfs@oss.sgi.com Subject: [patch] cfdisk + xfs labels Message-ID: <20010630081014.B165960@wobbly.melbourne.sgi.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="CdrF4e02JqNVZeln" X-Mailer: Mutt 1.0us Sender: owner-linux-xfs@oss.sgi.com Precedence: bulk --CdrF4e02JqNVZeln Content-Type: text/plain; charset=us-ascii hi, so, I went back and checked the other util-linux tools to see if any of them make use of filesystem labels ... afaict, cfdisk is the only remaining one (mount being the other). this patch lets cfdisk display XFS labels too (in addition to ext2) + has the cute side effect of showing you which partitions hold XFS filesystems - if someone (else) could try it out and let me know how it goes, I'll then forward it on to Andries. note - you need curses installed to build cfdisk, and the patch is against version 2.11f of util-linux (but should apply to any recent version). thanks. -- Nathan --CdrF4e02JqNVZeln Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="cfdisk.patch" diff -Naur util-linux-2.11f/fdisk/cfdisk.c util-linux/fdisk/cfdisk.c --- util-linux-2.11f/fdisk/cfdisk.c Thu Jun 7 15:55:16 2001 +++ util-linux/fdisk/cfdisk.c Sat Jun 30 03:25:09 2001 @@ -47,6 +47,8 @@ * Some more i18n. * Sun Jul 18 03:19:42 MEST 1999 * Terabyte-sized disks. + * Sat Jun 30 05:23:19 EST 2001 + * XFS label recognition. * ****************************************************************************/ @@ -397,6 +399,8 @@ else if (p_info[i].id == LINUX) { if (!strcmp(p_info[i].fstype, "ext2")) return _("Linux ext2"); + else if (!strcmp(p_info[i].fstype, "xfs")) + return _("Linux XFS"); else return _("Linux"); } else if (p_info[i].id == OS2_OR_NTFS) { @@ -612,7 +616,7 @@ } static void -get_ext2_label(int i) { +get_linux_label(int i) { #define EXT2_SUPER_MAGIC 0xEF53 #define EXT2LABELSZ 16 struct ext2_super_block { @@ -622,22 +626,48 @@ char s_volume_name[EXT2LABELSZ]; char s_last_mounted[64]; char s_dummy2[824]; - } sb; - char *label = sb.s_volume_name; + } e2fsb; +#define XFS_SUPER_MAGIC "XFSB" +#define XFS_SUPER_MAGIC2 "BFSX" +#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; 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, &sb, sizeof(sb)) == sizeof(sb) - && sb.s_magic[0] + 256*sb.s_magic[1] == EXT2_SUPER_MAGIC) { + && 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