From a400ab258c1ff9eee8f0e32dcd2ee7020e221d02 Mon Sep 17 00:00:00 2001 From: Nathan Scott Date: Mon, 23 Jun 2003 01:22:03 +0000 Subject: [PATCH] Update libdisk driver detection code to work for devices with multiple majors --- VERSION | 2 +- debian/changelog | 4 ++-- doc/CHANGES | 5 +++++ include/volume.h | 4 ++-- libdisk/drivers.c | 23 ++++++++++++----------- libdisk/evms.c | 7 +++---- libdisk/lvm.c | 9 ++++----- libdisk/md.c | 7 +++---- libdisk/xvm.c | 10 +++++----- 9 files changed, 37 insertions(+), 34 deletions(-) diff --git a/VERSION b/VERSION index 8dff1c94b..370cc02c4 100644 --- a/VERSION +++ b/VERSION @@ -3,5 +3,5 @@ # PKG_MAJOR=2 PKG_MINOR=5 -PKG_REVISION=0 +PKG_REVISION=1 PKG_BUILD=0 diff --git a/debian/changelog b/debian/changelog index 9c1bc8479..92e56124d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,11 +1,11 @@ -xfsprogs (2.5.0-1) unstable; urgency=low +xfsprogs (2.5.1-1) unstable; urgency=low * New upstream release * Changed mkfs.xfs default log size scaling algorithm slightly, to create larger logs at smaller filesystem sizes by default * Enable support for sector sizes larger than 512 bytes - -- Nathan Scott Wed, 18 Jun 2003 12:56:16 +1000 + -- Nathan Scott Mon, 23 Jun 2003 11:15:06 +1000 xfsprogs (2.4.12-1) unstable; urgency=low diff --git a/doc/CHANGES b/doc/CHANGES index e93d5fded..8f9894187 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,3 +1,8 @@ +xfsprogs-2.5.1 (23 June 2003) + - Fix libdisk device driver (volume managers) detection code + used by mkfs, so that drivers with multiple majors are not + incorrectly processed. + xfsprogs-2.5.0 (18 June 2003) - Fix libdisk (and hence mkfs) code which warns on MD devices with the clean flag not set, apparently this is not so wise. diff --git a/include/volume.h b/include/volume.h index e93e0533e..ff66d7e99 100644 --- a/include/volume.h +++ b/include/volume.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. + * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as @@ -61,6 +61,6 @@ typedef enum sv_type_e { } sv_type_t; extern void get_subvol_stripe_wrapper (char *, sv_type_t, int *, int *); -extern int get_driver_block_major (const char *); +extern int get_driver_block_major (const char *, int); #endif /* __VOLUME_H__ */ diff --git a/libdisk/drivers.c b/libdisk/drivers.c index bd16067ab..9bfb75174 100644 --- a/libdisk/drivers.c +++ b/libdisk/drivers.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. + * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as @@ -58,29 +58,30 @@ get_subvol_stripe_wrapper(char *dev, sv_type_t type, int *sunit, int *swidth) /* ... add new device drivers here */ } +#define DEVICES "/proc/devices" + /* * General purpose routine which dredges through procfs trying to * match up device driver names with the associated major numbers * being used in the running kernel. */ int -get_driver_block_major(const char *driver) +get_driver_block_major(const char *driver, int major) { FILE *f; char buf[64], puf[64]; - int major = -1; + int dmajor, match = 0; - if ((f = fopen("/proc/devices", "r")) == NULL) - return major; + if ((f = fopen(DEVICES, "r")) == NULL) + return match; while (fgets(buf, sizeof(buf), f)) /* skip to block dev section */ if (strncmp("Block devices:\n", buf, sizeof(buf)) == 0) break; while (fgets(buf, sizeof(buf), f)) - if ((sscanf(buf, "%u %s\n", &major, puf) == 2) && - (strncmp(puf, driver, sizeof(puf)) == 0)) - goto found; - major = -1; -found: + if ((sscanf(buf, "%u %s\n", &dmajor, puf) == 2) && + (strncmp(puf, driver, sizeof(puf)) == 0) && + (dmajor == major)) + match = 1; fclose(f); - return major; + return match; } diff --git a/libdisk/evms.c b/libdisk/evms.c index 62f937379..a41e62a83 100644 --- a/libdisk/evms.c +++ b/libdisk/evms.c @@ -26,13 +26,12 @@ #include "evms.h" int -mnt_is_evms_subvol(dev_t dev) +mnt_is_evms_subvol( + dev_t dev) { if (major(dev) == EVMS_MAJOR) return 1; - if (major(dev) == get_driver_block_major("evms")) - return 1; - return 0; + return get_driver_block_major("evms", major(dev)); } int diff --git a/libdisk/lvm.c b/libdisk/lvm.c index 226ca2c75..ad5e6c104 100644 --- a/libdisk/lvm.c +++ b/libdisk/lvm.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. + * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as @@ -37,13 +37,12 @@ #endif int -mnt_is_lvm_subvol(dev_t dev) +mnt_is_lvm_subvol( + dev_t dev) { if (major(dev) == LVM_BLK_MAJOR) return 1; - if (major(dev) == get_driver_block_major("lvm")) - return 1; - return 0; + return get_driver_block_major("lvm", major(dev)); } int diff --git a/libdisk/md.c b/libdisk/md.c index a6a5d0043..36f9d91fb 100644 --- a/libdisk/md.c +++ b/libdisk/md.c @@ -34,13 +34,12 @@ #include "md.h" int -mnt_is_md_subvol(dev_t dev) +mnt_is_md_subvol( + dev_t dev) { if (major(dev) == MD_MAJOR) return 1; - if (major(dev) == get_driver_block_major("md")) - return 1; - return 0; + return get_driver_block_major("md", major(dev)); } int diff --git a/libdisk/xvm.c b/libdisk/xvm.c index 05c44a77d..451cac6a7 100644 --- a/libdisk/xvm.c +++ b/libdisk/xvm.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. + * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -39,11 +40,10 @@ #include "xvm.h" int -mnt_is_xvm_subvol(dev_t dev) +mnt_is_xvm_subvol( + dev_t dev) { - if (major(dev) == get_driver_block_major("xvm")) - return 1; - return 0; + return get_driver_block_major("xvm", major(dev)); } /* -- 2.47.2