hi Thomas,
On Nov 8, 8:09am, Thomas Graichen wrote:
> Subject: Re: TAKE - xfs_admin
> ...
> maybe just put it onto the oss.sgi.com xfs ftp space - i would be
> interested in this - because it should nicely integrate into redhat
> 7.0 (mounting via label) i think - right?
>
The mount-by-uuid/label has been in mount for some time now I
believe - it exists in my Redhat 6.2 installation for example,
and the changelog at the head of mount_by_label.c dates back
to Feb '99.
I've attached the patch to util-linux-2.10p (I don't have a
login on oss - perhaps some other kind soul could put a copy
there for me?).
cheers.
--
Nathan
diff -Naur util-linux-2.10p/mount/README.mount util-linux/mount/README.mount
--- util-linux-2.10p/mount/README.mount Fri Jul 9 12:56:39 1999
+++ util-linux/mount/README.mount Tue Nov 7 12:14:01 2000
@@ -6,5 +6,5 @@
Stephen Tweedie <sct@xxxxxxxxxxxx>.
Presently maintained by Andries Brouwer <aeb@xxxxxx>.
-Ftp site: ftp.win.tue.nl:/pub/linux/util .
+Ftp site: ftp.win.tue.nl:/pub/linux/utils/util-linux
diff -Naur util-linux-2.10p/mount/linux_fs.h util-linux/mount/linux_fs.h
--- util-linux-2.10p/mount/linux_fs.h Sun Apr 16 22:23:38 2000
+++ util-linux/mount/linux_fs.h Tue Nov 7 14:07:58 2000
@@ -100,3 +100,13 @@
u_char s_label2[11]; /* for Windows? */
u_char s_fs2[8]; /* garbage or "FAT32 " */
};
+
+#define XFS_SUPER_MAGIC "XFSB"
+#define XFS_SUPER_MAGIC2 "BSFX"
+struct xfs_super_block {
+ u_char s_magic[4];
+ u_char s_dummy[28];
+ u_char s_uuid[16];
+ u_char s_dummy2[60];
+ u_char s_fname[12];
+};
diff -Naur util-linux-2.10p/mount/mount_by_label.c
util-linux/mount/mount_by_label.c
--- util-linux-2.10p/mount/mount_by_label.c Thu Oct 5 11:32:24 2000
+++ util-linux/mount/mount_by_label.c Tue Nov 7 15:35:28 2000
@@ -7,6 +7,8 @@
* - Added error message if /proc/partitions cannot be opened
* 2000-05-09 Erik Troan <ewt@xxxxxxxxxx>
* - Added cache for UUID and disk labels
+ * 2000-11-07 Nathan Scott <nathans@xxxxxxx>
+ * - Added XFS support
*/
#include <stdio.h>
@@ -29,35 +31,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
diff -Naur util-linux-2.10p/mount/mount_guess_fstype.c
util-linux/mount/mount_guess_fstype.c
--- util-linux-2.10p/mount/mount_guess_fstype.c Mon May 15 22:34:43 2000
+++ util-linux/mount/mount_guess_fstype.c Tue Nov 7 11:40:34 2000
@@ -131,11 +131,11 @@
union {
struct xiafs_super_block xiasb;
char romfs_magic[8];
- char xfs_magic[4];
char qnx4fs_magic[10]; /* ignore first 4 bytes */
long bfs_magic;
struct ntfs_super_block ntfssb;
struct fat_super_block fatsb;
+ struct xfs_super_block xfsb;
} xsb;
struct ufs_super_block ufssb;
union {
@@ -179,8 +179,8 @@
type = "xiafs";
else if(!strncmp(xsb.romfs_magic, "-rom1fs-", 8))
type = "romfs";
- else if(!strncmp(xsb.xfs_magic, "XFSB", 4) ||
- !strncmp(xsb.xfs_magic, "BSFX", 4))
+ else if(!strncmp(xsb.xfsb.s_magic, XFS_SUPER_MAGIC, 4) ||
+ !strncmp(xsb.xfsb.s_magic, XFS_SUPER_MAGIC2, 4))
type = "xfs";
else if(!strncmp(xsb.qnx4fs_magic+4, "QNX4FS", 6))
type = "qnx4fs";
diff -Naur util-linux-2.10p/mount/umount.c util-linux/mount/umount.c
--- util-linux-2.10p/mount/umount.c Wed Sep 20 00:54:41 2000
+++ util-linux/mount/umount.c Tue Nov 7 11:08:47 2000
@@ -24,6 +24,7 @@
* - Differentiate "user" and "users" key words in fstab
*/
+#include <stdio.h>
#include <unistd.h>
#include <getopt.h>
#include <string.h>
|