diff options
author | Martin Schlemmer <azarah@gentoo.org> | 2003-12-29 23:09:03 +0000 |
---|---|---|
committer | Martin Schlemmer <azarah@gentoo.org> | 2003-12-29 23:09:03 +0000 |
commit | 60aef83596292127d762fe2351a323f020d1bfc2 (patch) | |
tree | 508e239904fd681e03c410708ee46f76d2b97b74 /sys-apps/util-linux | |
parent | Add support to read fat/fat32 labels, bug #36722 (diff) | |
download | gentoo-2-60aef83596292127d762fe2351a323f020d1bfc2.tar.gz gentoo-2-60aef83596292127d762fe2351a323f020d1bfc2.tar.bz2 gentoo-2-60aef83596292127d762fe2351a323f020d1bfc2.zip |
Add support to read fat/fat32 labels, bug #36722
Diffstat (limited to 'sys-apps/util-linux')
-rw-r--r-- | sys-apps/util-linux/ChangeLog | 8 | ||||
-rw-r--r-- | sys-apps/util-linux/Manifest | 4 | ||||
-rw-r--r-- | sys-apps/util-linux/files/digest-util-linux-2.12-r4 | 2 | ||||
-rw-r--r-- | sys-apps/util-linux/files/util-linux-2.12-fat-LABEL-support.patch | 319 | ||||
-rw-r--r-- | sys-apps/util-linux/util-linux-2.12-r4.ebuild | 133 |
5 files changed, 463 insertions, 3 deletions
diff --git a/sys-apps/util-linux/ChangeLog b/sys-apps/util-linux/ChangeLog index 62fb40c471c5..c3dd7dd976d1 100644 --- a/sys-apps/util-linux/ChangeLog +++ b/sys-apps/util-linux/ChangeLog @@ -1,6 +1,12 @@ # ChangeLog for sys-apps/util-linux # Copyright 2002-2003 Gentoo Technologies, Inc.; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/sys-apps/util-linux/ChangeLog,v 1.63 2003/12/11 21:53:03 vapier Exp $ +# $Header: /var/cvsroot/gentoo-x86/sys-apps/util-linux/ChangeLog,v 1.64 2003/12/29 23:08:45 azarah Exp $ + +*util-linux-2.12-r4 (30 Dec 2003) + + 30 Dec 2003; Martin Schlemmer <azarah@gentoo.org> util-linux-2.12-r4.ebuild, + files/util-linux-2.12-fat-LABEL-support.patch: + Add support to read fat/fat32 labels, bug #36722. 11 Dec 2003; Mike Frysinger <vapier@gentoo.org> util-linux-2.12-r3.ebuild : Add patch to compile against 2.6.x headers #31286. diff --git a/sys-apps/util-linux/Manifest b/sys-apps/util-linux/Manifest index 07507d3d0499..1c790ab5c13a 100644 --- a/sys-apps/util-linux/Manifest +++ b/sys-apps/util-linux/Manifest @@ -1,8 +1,8 @@ MD5 780eb6860abb6d79b37b2bc337a51177 util-linux-2.11z-r8.ebuild 3222 MD5 6d685a28db8eb02c63016d7bcd6679e5 util-linux-2.12-r2.ebuild 3305 MD5 21ff2d3eff4f37417dc584ab48003edf util-linux-2.12-r3.ebuild 3748 -MD5 12edb8b3b2dd9db08c108a079cf9bcea ChangeLog 10596 -MD5 bef91b7d69243ba02e45b7b324bea0ab util-linux-2.12-r4.ebuild 3851 +MD5 f1c0bc14010c2828741022908e35e256 ChangeLog 10812 +MD5 54dfbac7889e61b010667be5c46601c0 util-linux-2.12-r4.ebuild 3849 MD5 9a09f8d531c582e78977dbfd96edc1f2 metadata.xml 164 MD5 56da3847e8af00adfb1c3d9d4e7947d9 util-linux-2.11z-r9.ebuild 3414 MD5 0be8df03dae23c81a0e929e58a4114e0 files/util-linux-2.11z-01-nfsv4.dif 13442 diff --git a/sys-apps/util-linux/files/digest-util-linux-2.12-r4 b/sys-apps/util-linux/files/digest-util-linux-2.12-r4 new file mode 100644 index 000000000000..cedffcb9a126 --- /dev/null +++ b/sys-apps/util-linux/files/digest-util-linux-2.12-r4 @@ -0,0 +1,2 @@ +MD5 997adf78b98d9d1c5db4f37ea982acff util-linux-2.12.tar.gz 1857871 +MD5 1734111e696acfb6d08f52f1e1b3d024 util-linux-2.12-cryptoapi-losetup.patch.bz2 4871 diff --git a/sys-apps/util-linux/files/util-linux-2.12-fat-LABEL-support.patch b/sys-apps/util-linux/files/util-linux-2.12-fat-LABEL-support.patch new file mode 100644 index 000000000000..0099bbf0a864 --- /dev/null +++ b/sys-apps/util-linux/files/util-linux-2.12-fat-LABEL-support.patch @@ -0,0 +1,319 @@ +diff -uNr util-linux-2.12/mount/get_label_uuid.c ../patch/util-linux-2.12/mount/get_label_uuid.c +--- util-linux-2.12/mount/get_label_uuid.c 2002-11-26 12:18:01.000000000 +0100 ++++ ../patch/util-linux-2.12/mount/get_label_uuid.c 2003-10-20 18:27:56.000000000 +0200 +@@ -43,7 +43,139 @@ + #endif + } + +-/* for now, only ext2, ext3, xfs, ocfs are supported */ ++/* Remove trailing spaces */ ++static void remtrailspc(char *label) { ++ char *c; ++ ++ c = strchr(label, 0)-1; ++ while (c >= label && *c == ' ') ++ *(c--) = 0; ++} ++ ++static int handle_fat_dirent(struct fat_dirent *dirent, char **label) { ++ size_t namesize; ++ ++ /* end-of-directory marker */ ++ if (!dirent->s_filename[0]) ++ return -1; ++ ++ /* valid volume label */ ++ if ((dirent->s_attr == 0x08 || dirent->s_attr == 0x28) && dirent->s_filename[0] != 0xe5) { ++ ++ /* sanity check */ ++ if (dirent->s_size[0] || dirent->s_size[1] || dirent->s_size[2] || dirent->s_size[3] || ++ dirent->s_cluster[0] || dirent->s_cluster[1]) ++ return -1; ++ ++ namesize = sizeof(dirent->s_filename); ++ if (!(*label = calloc(namesize + 1, 1))) ++ return -1; ++ memcpy(*label, dirent->s_filename, namesize); ++ (*label)[namesize] = 0; ++ remtrailspc(*label); ++ ++ return 0; ++ } ++ ++ return 1; ++} ++ ++static int read_volume_label_fat(int fd, struct fat_super_block *fatsb, char **label) { ++ unsigned i, m; ++ off_t o; ++ ++ m = assemble2le(fatsb->s_dirents); /* root directory entries */ ++ ++ o = (off_t) assemble2le(fatsb->s_ssec) * /* bytes per sector */ ++ ((off_t) assemble2le(fatsb->s_rsecs) + /* reserved sectors */ ++ (off_t) assemble2le(fatsb->s_spfat) * /* sectors per fat */ ++ (off_t) fatsb->s_nfats); /* number of fats */ ++ ++ for (i = 0; i < m; i++) { ++ struct fat_dirent dirent; ++ int rv; ++ ++ if (lseek(fd, o, SEEK_SET) != o || ++ read(fd, &dirent, sizeof(dirent)) != sizeof(dirent)) ++ return -1; ++ ++ if ((rv = handle_fat_dirent(&dirent, label)) != 1) ++ return rv; ++ ++ o += sizeof(dirent); ++ } ++ ++ return -1; ++} ++ ++static int read_volume_label_fat32(int fd, struct fat32_super_block *fat32sb, char **label) { ++ unsigned c; ++ off_t fo, b, o; ++ int i, ifat; ++ size_t m, cs; ++ ++ ifat = fat32sb->s_mirror[0] & 128 ? (fat32sb->s_mirror[0] & 0xF) : 0; ++ ++ if (ifat >= fat32sb->s_nfats) ++ return -1; ++ ++ fo = (off_t) assemble2le(fat32sb->s_ssec) * /* bytes per sector */ ++ ((off_t) assemble2le(fat32sb->s_rsecs) + /* reserved sectors */ ++ (off_t) assemble4le(fat32sb->s_spfat) * /* sectors per fat */ ++ (off_t) ifat); /* number of FAT used */ ++ ++ b = (off_t) assemble2le(fat32sb->s_ssec) * /* bytes per sector */ ++ ((off_t) assemble2le(fat32sb->s_rsecs) + /* reserved sectors */ ++ (off_t) assemble4le(fat32sb->s_spfat) * /* sectors per fat */ ++ (off_t) fat32sb->s_nfats); /* number of FATs */ ++ ++ c = assemble4le(fat32sb->s_rcluster) & 0x0fffffffL; ++ if (c < 2 || c >= 0x0ffffff0) ++ return -1; ++ ++ m = cs = assemble2le(fat32sb->s_ssec) * (size_t) fat32sb->s_scluster; ++ o = b + (off_t) cs*(c-2); ++ ++ for (i = 0; i < 0xFFFF; i++) { /* safety against DoS attack */ ++ struct fat_dirent dirent; ++ int rv; ++ ++ if (lseek(fd, o, SEEK_SET) != o || ++ read(fd, &dirent, sizeof(dirent)) != sizeof(dirent)) ++ return -1; ++ ++ if ((rv = handle_fat_dirent(&dirent, label)) != 1) ++ return rv; ++ ++ if (m > sizeof(dirent)) { ++ m -= sizeof(dirent); ++ o += sizeof(dirent); ++ } else { ++ off_t d; ++ ++ /* next cluster */ ++ ++ d = fo+4*c; ++ if (lseek(fd, d, SEEK_SET) != d || ++ read(fd, &c, 4) != 4) ++ return -1; ++ ++ c = assemble4le((char*) &c) & 0x0fffffffL; ++ if (c < 2 || c >= 0x0ffffff0) { ++ return -1; ++ } ++ ++ m = cs; ++ o = b + cs*(c-2); ++ } ++ } ++ ++ ++ return -1; ++} ++ ++ ++/* for now, only ext2, ext3, xfs, ocfs, fat, fat32 are supported */ + int + get_label_uuid(const char *device, char **label, char *uuid) { + int fd; +@@ -54,8 +186,10 @@ + struct jfs_super_block jfssb; + struct ocfs_volume_header ovh; /* Oracle */ + struct ocfs_volume_label olbl; ++ struct fat_super_block fatsb; ++ struct fat32_super_block fat32sb; + +- fd = open(device, O_RDONLY); ++ fd = open(device, O_RDONLY); + if (fd < 0) + return rv; + +@@ -111,7 +245,87 @@ + memcpy(*label, jfssb.s_label, namesize); + } + rv = 0; +- } ++ } else if (lseek(fd, 0, SEEK_SET) == 0 ++ && read(fd, (char*) &fat32sb, sizeof(fat32sb)) == sizeof(fat32sb) ++ && fat32sb.s_sig[0] == 0x55 ++ && fat32sb.s_sig[1] == 0xAA ++ && (fat32sb.s_media & 0xF0) == 0xF0 ++ && (fat32sb.s_spfat_old[0] == 0) ++ && (fat32sb.s_spfat_old[1] == 0) ++ && fat32sb.s_extsig == 0x29 ++ && (memcmp(fat32sb.s_fs, "FAT32 ", 8) == 0)) { ++ ++ *label = NULL; ++ ++ /* If no root directory entry volume name was found use the one from the boot sector */ ++ if (read_volume_label_fat32(fd, &fat32sb, label) != 0) { ++ if (memcmp(fat32sb.s_label, "NO NAME ", 11) != 0 && ++ memcmp(fat32sb.s_label, " ", 11) != 0 && ++ memcmp(fat32sb.s_label, "\0\0\0\0\0\0\0\0", 8) != 0) { ++ ++ namesize = sizeof(fat32sb.s_label); ++ if ((*label = calloc(namesize + 1, 1)) != NULL) { ++ memcpy(*label, fat32sb.s_label, namesize); ++ (*label)[namesize] = 0; ++ remtrailspc(*label); ++ } ++ } ++ } ++ ++ if (*label) { ++ ++ /* Set UUID from serial */ ++ uuid[0] = fat32sb.s_serial[3]; ++ uuid[1] = fat32sb.s_serial[2]; ++ uuid[2] = fat32sb.s_serial[1]; ++ uuid[3] = fat32sb.s_serial[0]; ++ memset(uuid+4, 0, 12); ++ ++ rv = 0; ++ } ++ } else if (lseek(fd, 0, SEEK_SET) == 0 ++ && read(fd, (char*) &fatsb, sizeof(fatsb)) == sizeof(fatsb) ++ && fatsb.s_sig[0] == 0x55 ++ && fatsb.s_sig[1] == 0xAA ++ && (fatsb.s_media & 0xF0) == 0xF0 ++ && fatsb.s_extsig == 0x29 ++ && (memcmp(fatsb.s_fs, "FAT12 ", 8) == 0 ++ || memcmp(fatsb.s_fs, "FAT16 ", 8) == 0 ++ || memcmp(fatsb.s_fs, "FAT ", 8) == 0 ++ || memcmp(fatsb.s_fs, "\0\0\0\0\0\0\0\0", 8) == 0) ++ && memcmp(fatsb.s_fs2, "FAT32 ", 8) != 0) { ++ ++ *label = NULL; ++ ++ if (read_volume_label_fat(fd, &fatsb, label) != 0) { ++ ++ /* If no root directory entry volume name was found use the one from the boot sector */ ++ if (memcmp(fatsb.s_label, "NO NAME ", 11) != 0 && ++ memcmp(fatsb.s_label, " ", 11) != 0 && ++ memcmp(fatsb.s_label, "\0\0\0\0\0\0\0\0", 8) != 0) { ++ ++ namesize = sizeof(fatsb.s_label); ++ if ((*label = calloc(namesize + 1, 1)) != NULL) { ++ memcpy(*label, fatsb.s_label, namesize); ++ (*label)[namesize] = 0; ++ remtrailspc(*label); ++ } ++ ++ } ++ } ++ ++ if (*label) { ++ ++ /* Set UUID from serial */ ++ uuid[0] = fatsb.s_serial[3]; ++ uuid[1] = fatsb.s_serial[2]; ++ uuid[2] = fatsb.s_serial[1]; ++ uuid[3] = fatsb.s_serial[0]; ++ memset(uuid+4, 0, 12); ++ ++ rv = 0; ++ } ++ } + + close(fd); + return rv; +diff -uNr util-linux-2.12/mount/linux_fs.h ../patch/util-linux-2.12/mount/linux_fs.h +--- util-linux-2.12/mount/linux_fs.h 2003-07-05 22:16:32.000000000 +0200 ++++ ../patch/util-linux-2.12/mount/linux_fs.h 2003-10-20 18:07:06.000000000 +0200 +@@ -122,13 +122,65 @@ + u_char s_dummy[3]; + u_char s_os[8]; /* "MSDOS5.0" or "MSWIN4.0" or "MSWIN4.1" */ + /* mtools-3.9.4 writes "MTOOL394" */ +- u_char s_dummy2[32]; ++ u_char s_ssec[2]; /* bytes per sector */ ++ u_char s_scluster; /* sectors per cluster */ ++ u_char s_rsecs[2]; /* reserved sectors */ ++ u_char s_nfats; /* number of FATs */ ++ u_char s_dirents[2]; /* maximum root directory entries */ ++ u_char s_nsecs[2]; /* total number of sectors */ ++ u_char s_media; /* media type, upper nibble is 0xF */ ++ u_char s_spfat[2]; /* sectors per fat */ ++ ++ u_char s_dummy2[14]; ++ u_char s_extsig; /* extended signature */ ++ u_char s_serial[4]; /* serial number */ + u_char s_label[11]; /* for DOS? */ +- u_char s_fs[8]; /* "FAT12 " or "FAT16 " or all zero */ ++ u_char s_fs[8]; /* "FAT12 " or "FAT16 " or all zero */ + /* OS/2 BM has "FAT " here. */ +- u_char s_dummy3[9]; +- u_char s_label2[11]; /* for Windows? */ +- u_char s_fs2[8]; /* garbage or "FAT32 " */ ++ ++ u_char s_dummy3[20]; ++ u_char s_fs2[8]; /* "FAT32 " */ ++ ++ u_char s_dummy4[420]; ++ u_char s_sig[2]; /* 55 AA */ ++}; ++ ++struct fat32_super_block { ++ u_char s_dummy[3]; ++ u_char s_os[8]; /* "MSDOS5.0" or "MSWIN4.0" or "MSWIN4.1" */ ++ /* mtools-3.9.4 writes "MTOOL394" */ ++ ++ u_char s_ssec[2]; /* bytes per sector */ ++ u_char s_scluster; /* sectors per cluster */ ++ u_char s_rsecs[2]; /* reserved sectors */ ++ u_char s_nfats; /* number of FATs */ ++ u_char s_dirents[2]; /* maximum root directory entries */ ++ u_char s_nsecs[2]; /* total number of sectors */ ++ u_char s_media; /* media type, upper nibble is 0xF */ ++ u_char s_spfat_old[2]; /* sectors per fat */ ++ ++ u_char s_dummy2[12]; ++ u_char s_spfat[4]; /* sectors per FAT */ ++ u_char s_mirror[2]; /* mirror flag */ ++ u_char s_version[2]; /* fs version */ ++ u_char s_rcluster[4]; /* root directory cluster */ ++ ++ u_char s_dummy3[18]; ++ u_char s_extsig; /* extended signature 0x29 */ ++ u_char s_serial[4]; /* serial number */ ++ u_char s_label[11]; /* label */ ++ u_char s_fs[8]; /* filesystem type "FAT32 " */ ++ ++ u_char s_dummy4[420]; ++ u_char s_sig[2]; /* 55 AA */ ++}; ++ ++struct fat_dirent { ++ u_char s_filename[11]; /* Filename with extension */ ++ u_char s_attr; /* File attribute flags */ ++ u_char s_dummy[14]; ++ u_char s_cluster[2]; /* Starting cluster */ ++ u_char s_size[4]; /* File size */ + }; + + #define XFS_SUPER_MAGIC "XFSB" diff --git a/sys-apps/util-linux/util-linux-2.12-r4.ebuild b/sys-apps/util-linux/util-linux-2.12-r4.ebuild new file mode 100644 index 000000000000..a9e0db3a5879 --- /dev/null +++ b/sys-apps/util-linux/util-linux-2.12-r4.ebuild @@ -0,0 +1,133 @@ +# Copyright 1999-2003 Gentoo Technologies, Inc. +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/sys-apps/util-linux/util-linux-2.12-r4.ebuild,v 1.1 2003/12/29 23:08:45 azarah Exp $ + +IUSE="crypt nls static pam selinux" + +inherit eutils flag-o-matic + +## see below for details on pic.patch +case ${ARCH} in + "x86"|"hppa"|"sparc"|"ppc") + ;; + *) + filter-flags -fPIC + ;; +esac + +S="${WORKDIR}/${P}" +CRYPT_PATCH_P="${P}-cryptoapi-losetup" +SELINUX_PATCH="util-linux-2.12-selinux.diff.bz2" +DESCRIPTION="Various useful Linux utilities" +SRC_URI="mirror://kernel/linux/utils/${PN}/${P}.tar.gz + ftp://ftp.cwi.nl/pub/aeb/${PN}/${P}.tar.gz + crypt? ( mirror://gentoo/${CRYPT_PATCH_P}.patch.bz2 )" +HOMEPAGE="http://www.kernel.org/pub/linux/utils/util-linux/" + +KEYWORDS="~x86 ~amd64 ~ppc ~sparc ~alpha ~arm ~mips ~hppa ~ia64 ~ppc64" +SLOT="0" +LICENSE="GPL-2" + +DEPEND="virtual/glibc + >=sys-apps/sed-4.0.5 + >=sys-libs/ncurses-5.2-r2 + selinux? ( sys-libs/libselinux ) + pam? ( sys-apps/pam-login ) + crypt? ( app-crypt/hashalot )" + +RDEPEND="${DEPEND} dev-lang/perl + nls? ( sys-devel/gettext )" + +src_unpack() { + unpack ${A} + + cd ${S} + + # CryptoAPI losetup patch for the cryptoapi sepecific + # to the 2.6 linux kernel. Needs hashalot. + # Original patch location: + # http://www.stwing.org/~sluskyb/util-linux/losetup-combined.patch + # Mailing list post with info: + # http://www.kerneli.org/pipermail/cryptoapi-devel/2003-September/000634.html + # Follow thread for usage. + use crypt && epatch ${DISTDIR}/${CRYPT_PATCH_P}.patch.bz2 + + # Fix rare failures with -j4 or higher + epatch ${FILESDIR}/${PN}-2.11z-parallel-make.patch + + # Fix unreadable df output + epatch ${FILESDIR}/no-symlink-resolve.patch + + # Add the O option to agetty to display DNS domainname in the issue + # file, thanks to Marius Mauch <genone@genone.de>, bug #22275. + # + # NOTE: Removing this will break future baselayout, so PLEASE + # consult with me before doing so. + # + # <azarah@gentoo.og> (17 Jul 2003) + epatch ${FILESDIR}/${PN}-2.11z-agetty-domainname-option.patch + + # Add NFS4 support (kernel 2.5/2.6). +# if [ ! -z "`use crypt`" ] ; then +# epatch ${FILESDIR}/${PN}-2.11z-01-nfsv4-crypt.dif +# else + epatch ${FILESDIR}/${PN}-2.11z-01-nfsv4.dif +# fi + + # <solar@gentoo.org> This patch should allow us to remove -fPIC + # out of the filter-flags we need this be able to emit position + # independent code so we can link our elf executables as shared + # objects. "prelink" should now also be able to take advantage + epatch ${FILESDIR}/${PN}-2.11z-pic.patch + + # Allow util-linux to compile with 2.6.x headers #31286 + epatch ${FILESDIR}/${P}-kernel-2.6.patch + + # Add support to read fat/fat32 labels, bug #36722 + epatch ${FILESDIR}/${P}-fat-LABEL-support.patch + + # Enable pam only if we use it + use pam && sed -i "s:HAVE_PAM=no:HAVE_PAM=yes:" MCONFIG + + use selinux && epatch ${FILESDIR}/${SELINUX_PATCH} + + sed -i \ + -e "s:-pipe -O2 \$(CPUOPT) -fomit-frame-pointer:${CFLAGS}:" \ + -e "s:CPU=.*:CPU=${CHOST%%-*}:" \ + -e "s:HAVE_SLN=no:HAVE_SLN=yes:" \ + -e "s:HAVE_TSORT=no:HAVE_TSORT=yes:" \ + -e "s:usr/man:usr/share/man:" \ + -e "s:usr/info:usr/share/info:" \ + -e "s:SUIDMODE=.*4755:SUIDMODE=4711:" \ + MCONFIG || die "MCONFIG sed" + + if [ -z "`use nls`" ] ; then + sed -i -e 's/DISABLE_NLS=no/DISABLE_NLS=yes/' MCONFIG || + die "MCONFIG nls sed" + fi + + # /bin/kill is provided by procps ONLY + epatch ${FILESDIR}/${PN}-no-kill.patch +} + +src_compile() { + if [ "`use static`" ] ; then + export LDFLAGS="${LDFLAGS} -static" + fi + + econf || die "configure failed" + + emake || die "emake failed" + cd sys-utils && makeinfo *.texi || die "makeinfo failed" +} + +src_install() { + make DESTDIR="${D}" install || die "install failed" + + dodoc HISTORY MAINTAINER README VERSION + docinto licenses + dodoc licenses/* HISTORY + docinto examples + dodoc example.files/* +} + |