forked from pool/util-linux
This commit is contained in:
parent
371ba62aab
commit
1071344f16
@ -1,128 +0,0 @@
|
||||
## 30swsusp-resume.dpatch by Jeff Bailey <jbailey@ubuntu.com>
|
||||
Index: util-linux-ng-2.12r+git20070330/mount/swapon.c
|
||||
===================================================================
|
||||
--- util-linux-ng-2.12r+git20070330.orig/mount/swapon.c
|
||||
+++ util-linux-ng-2.12r+git20070330/mount/swapon.c
|
||||
@@ -10,7 +10,9 @@
|
||||
#include <string.h>
|
||||
#include <mntent.h>
|
||||
#include <errno.h>
|
||||
+#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
+#include <fcntl.h>
|
||||
#include "xmalloc.h"
|
||||
#include "swap_constants.h"
|
||||
#include "swapargs.h"
|
||||
@@ -23,6 +25,7 @@
|
||||
|
||||
#define _PATH_FSTAB "/etc/fstab"
|
||||
#define PROC_SWAPS "/proc/swaps"
|
||||
+#define PATH_MKSWAP "/sbin/mkswap"
|
||||
|
||||
#define SWAPON_NEEDS_TWO_ARGS
|
||||
|
||||
@@ -179,6 +182,85 @@ display_summary(void)
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * It's better do swsuspend detection by follow routine than
|
||||
+ * include huge mount_guess_fstype.o to swapon. We need only
|
||||
+ * swsuspend and no the others filesystems.
|
||||
+ */
|
||||
+#ifdef HAVE_LIBBLKID
|
||||
+static int
|
||||
+swap_is_swsuspend(const char *device) {
|
||||
+ const char *type = blkid_get_tag_value(blkid, "TYPE", device);
|
||||
+
|
||||
+ if (type && strcmp(type, "swsuspend")==0)
|
||||
+ return 0;
|
||||
+ return 1;
|
||||
+}
|
||||
+#else
|
||||
+static int
|
||||
+swap_is_swsuspend(const char *device) {
|
||||
+ int fd, re = 1, n = getpagesize() - 10;
|
||||
+ char buf[10];
|
||||
+
|
||||
+ fd = open(device, O_RDONLY);
|
||||
+ if (fd < 0)
|
||||
+ return -1;
|
||||
+
|
||||
+ if (lseek(fd, n, SEEK_SET) >= 0 &&
|
||||
+ read(fd, buf, sizeof buf) == sizeof buf &&
|
||||
+ (memcmp("S1SUSPEND", buf, 9)==0 ||
|
||||
+ memcmp("S2SUSPEND", buf, 9)==0 ||
|
||||
+ memcmp("ULSUSPEND", buf, 9)==0))
|
||||
+ re = 0;
|
||||
+
|
||||
+ close(fd);
|
||||
+ return re;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+/* calls mkswap */
|
||||
+static int
|
||||
+swap_reinitialize(const char *device) {
|
||||
+ const char *label = mount_get_volume_label_by_spec(device);
|
||||
+ pid_t pid;
|
||||
+
|
||||
+ switch((pid=fork())) {
|
||||
+ case -1: /* fork error */
|
||||
+ fprintf(stderr, _("%s: cannot fork: %s\n"),
|
||||
+ progname, strerror(errno));
|
||||
+ return -1;
|
||||
+
|
||||
+ case 0: /* child */
|
||||
+ if (label && *label)
|
||||
+ execl(PATH_MKSWAP, PATH_MKSWAP, "-L", label, device, NULL);
|
||||
+ else
|
||||
+ execl(PATH_MKSWAP, PATH_MKSWAP, device, NULL);
|
||||
+ exit(1); /* error */
|
||||
+
|
||||
+ default: /* parent */
|
||||
+ {
|
||||
+ int status;
|
||||
+ int ret;
|
||||
+
|
||||
+ do {
|
||||
+ if ((ret = waitpid(pid, &status, 0)) < 0
|
||||
+ && errno == EINTR)
|
||||
+ continue;
|
||||
+ else if (ret < 0) {
|
||||
+ fprintf(stderr, _("%s: waitpid: %s\n"),
|
||||
+ progname, strerror(errno));
|
||||
+ return -1;
|
||||
+ }
|
||||
+ } while (0);
|
||||
+
|
||||
+ /* mkswap returns: 0=suss, 1=error */
|
||||
+ if (WIFEXITED(status) && WEXITSTATUS(status)==0)
|
||||
+ return 0; /* ok */
|
||||
+ }
|
||||
+ }
|
||||
+ return -1; /* error */
|
||||
+}
|
||||
+
|
||||
static int
|
||||
do_swapon(const char *orig_special, int prio) {
|
||||
int status;
|
||||
@@ -202,6 +284,18 @@ do_swapon(const char *orig_special, int
|
||||
return -1;
|
||||
}
|
||||
|
||||
+ /* We have to reinitialize swap with old (=useless) software suspend
|
||||
+ * data. The problem is that if we don't do it, then we get data
|
||||
+ * corruption the next time with suspended on.
|
||||
+ */
|
||||
+ if (swap_is_swsuspend(special)==0) {
|
||||
+ fprintf(stdout, _("%s: %s: software suspend data detected. "
|
||||
+ "Reinitializing the swap.\n"),
|
||||
+ progname, special);
|
||||
+ if (swap_reinitialize(special) < 0)
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
/* people generally dislike this warning - now it is printed
|
||||
only when `verbose' is set */
|
||||
if (verbose) {
|
@ -1,12 +0,0 @@
|
||||
Index: util-linux-ng-2.13rc2+git20070725/mount/lomount.c
|
||||
===================================================================
|
||||
--- util-linux-ng-2.13rc2+git20070725.orig/mount/lomount.c
|
||||
+++ util-linux-ng-2.13rc2+git20070725/mount/lomount.c
|
||||
@@ -325,6 +325,7 @@ set_loop(const char *device, const char
|
||||
}
|
||||
if ((fd = open(device, mode)) < 0) {
|
||||
perror (device);
|
||||
+ close(ffd);
|
||||
return 1;
|
||||
}
|
||||
*loopro = (mode == O_RDONLY);
|
96
util-linux-2.13.1-canonicalize_loopfile_name.patch
Normal file
96
util-linux-2.13.1-canonicalize_loopfile_name.patch
Normal file
@ -0,0 +1,96 @@
|
||||
commit bfdb8be5c49d8fadb25118fb4416ab2a68fc3a16
|
||||
Author: Karel Zak <kzak@redhat.com>
|
||||
Date: Thu Oct 25 12:29:51 2007 +0200
|
||||
|
||||
losetup: canonicalize loopfile name
|
||||
|
||||
When setting up a loop device, canonicalize the loop file
|
||||
name. This simplifies a later identification of loop file names
|
||||
when querying the loop devices.
|
||||
|
||||
Co-Author: Matthias Koenig <mkoenig@suse.de>
|
||||
Signed-off-by: Matthias Koenig <mkoenig@suse.de>
|
||||
Signed-off-by: Karel Zak <kzak@redhat.com>
|
||||
|
||||
Index: util-linux-ng-2.13.1/mount/lomount.c
|
||||
===================================================================
|
||||
--- util-linux-ng-2.13.1.orig/mount/lomount.c
|
||||
+++ util-linux-ng-2.13.1/mount/lomount.c
|
||||
@@ -22,10 +22,12 @@
|
||||
#include "lomount.h"
|
||||
#include "xstrncpy.h"
|
||||
#include "nls.h"
|
||||
+#include "realpath.h"
|
||||
+#include "xmalloc.h"
|
||||
+
|
||||
|
||||
extern int verbose;
|
||||
extern char *progname;
|
||||
-extern char *xstrdup (const char *s); /* not: #include "sundries.h" */
|
||||
extern void error (const char *fmt, ...); /* idem */
|
||||
|
||||
#define SIZE(a) (sizeof(a)/sizeof(a[0]))
|
||||
@@ -279,6 +281,7 @@ set_loop(const char *device, const char
|
||||
struct loop_info64 loopinfo64;
|
||||
int fd, ffd, mode, i;
|
||||
char *pass;
|
||||
+ char filename[PATH_MAX+1];
|
||||
|
||||
mode = (*loopro ? O_RDONLY : O_RDWR);
|
||||
if ((ffd = open(file, mode)) < 0) {
|
||||
@@ -298,7 +301,8 @@ set_loop(const char *device, const char
|
||||
|
||||
memset(&loopinfo64, 0, sizeof(loopinfo64));
|
||||
|
||||
- xstrncpy(loopinfo64.lo_file_name, file, LO_NAME_SIZE);
|
||||
+ myrealpath(file, filename, PATH_MAX);
|
||||
+ xstrncpy(loopinfo64.lo_file_name, filename, LO_NAME_SIZE);
|
||||
|
||||
if (encryption && *encryption) {
|
||||
if (digits_only(encryption)) {
|
||||
@@ -386,7 +390,7 @@ set_loop(const char *device, const char
|
||||
|
||||
if (verbose > 1)
|
||||
printf(_("set_loop(%s,%s,%llu): success\n"),
|
||||
- device, file, offset);
|
||||
+ device, filename, offset);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -470,23 +474,6 @@ usage(void) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
-char *
|
||||
-xstrdup (const char *s) {
|
||||
- char *t;
|
||||
-
|
||||
- if (s == NULL)
|
||||
- return NULL;
|
||||
-
|
||||
- t = strdup (s);
|
||||
-
|
||||
- if (t == NULL) {
|
||||
- fprintf(stderr, _("not enough memory"));
|
||||
- exit(1);
|
||||
- }
|
||||
-
|
||||
- return t;
|
||||
-}
|
||||
-
|
||||
void
|
||||
error (const char *fmt, ...) {
|
||||
va_list args;
|
||||
Index: util-linux-ng-2.13.1/mount/Makefile.am
|
||||
===================================================================
|
||||
--- util-linux-ng-2.13.1.orig/mount/Makefile.am
|
||||
+++ util-linux-ng-2.13.1/mount/Makefile.am
|
||||
@@ -25,7 +25,7 @@ umount_LDFLAGS = $(SUID_LDFLAGS) $(AM_LD
|
||||
|
||||
swapon_SOURCES = swapon.c swap_constants.h $(utils_common)
|
||||
|
||||
-losetup_SOURCES = lomount.c loop.h lomount.h
|
||||
+losetup_SOURCES = lomount.c loop.h lomount.h realpath.c xmalloc.c
|
||||
losetup_CPPFLAGS = -DMAIN $(AM_CPPFLAGS)
|
||||
|
||||
mount_LDADD = $(LDADD_common)
|
24
util-linux-2.13.1-getfs_fix.patch
Normal file
24
util-linux-2.13.1-getfs_fix.patch
Normal file
@ -0,0 +1,24 @@
|
||||
Index: util-linux-ng-2.13.1/mount/fstab.c
|
||||
===================================================================
|
||||
--- util-linux-ng-2.13.1.orig/mount/fstab.c
|
||||
+++ util-linux-ng-2.13.1/mount/fstab.c
|
||||
@@ -419,11 +419,17 @@ getfs_by_spec (const char *spec) {
|
||||
struct mntentchn *
|
||||
getfs_by_devname (const char *devname) {
|
||||
struct mntentchn *mc, *mc0;
|
||||
+ char *name;
|
||||
|
||||
mc0 = fstab_head();
|
||||
- for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt)
|
||||
- if (streq(mc->m.mnt_fsname, devname))
|
||||
+ for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt) {
|
||||
+ name = canonicalize(mc->m.mnt_fsname);
|
||||
+ if (streq(name, devname)) {
|
||||
+ free(name);
|
||||
return mc;
|
||||
+ }
|
||||
+ }
|
||||
+ free(name);
|
||||
return NULL;
|
||||
}
|
||||
|
65
util-linux-2.13.1-mkfs.minix_add_sectorsize_check.patch
Normal file
65
util-linux-2.13.1-mkfs.minix_add_sectorsize_check.patch
Normal file
@ -0,0 +1,65 @@
|
||||
X-Gnus-Coding-System: -*- coding: utf-8; -*-
|
||||
|
||||
Minix filesystem until version 2 has a fixed blocksize of 1024 bytes.
|
||||
If you try to create a filsystem on a device with a physical sectorsize
|
||||
larger than 1024 bytes, this resulting minix fs cannot be mounted,
|
||||
because the physical sectorsize must be smaller than the filesystem
|
||||
blocksize.
|
||||
This patch adds a check for this and will refuse to create a filesystem
|
||||
if the sectorsize is bigger than the blocksize.
|
||||
|
||||
Signed-off-by: Matthias Koenig <mkoenig@suse.de>
|
||||
---
|
||||
|
||||
disk-utils/Makefile.am | 4 +++-
|
||||
disk-utils/mkfs.minix.c | 12 ++++++++++--
|
||||
2 files changed, 13 insertions(+), 3 deletions(-)
|
||||
|
||||
Index: util-linux-ng-2.13.1/disk-utils/mkfs.minix.c
|
||||
===================================================================
|
||||
--- util-linux-ng-2.13.1.orig/disk-utils/mkfs.minix.c
|
||||
+++ util-linux-ng-2.13.1/disk-utils/mkfs.minix.c
|
||||
@@ -78,6 +78,7 @@
|
||||
#ifndef BLKGETSIZE
|
||||
#define BLKGETSIZE _IO(0x12,96) /* return device size */
|
||||
#endif
|
||||
+#define BLKSSZGET _IO(0x12,104)/* get block device sector size */
|
||||
|
||||
#ifndef __GNUC__
|
||||
#error "needs gcc for the bitop-__asm__'s"
|
||||
@@ -238,6 +239,16 @@ get_size(const char *file) {
|
||||
return size;
|
||||
}
|
||||
|
||||
+/* get hardware sector size */
|
||||
+int
|
||||
+blkdev_get_sector_size(int fd, int *sector_size)
|
||||
+{
|
||||
+ if (ioctl(fd, BLKSSZGET, sector_size) >= 0)
|
||||
+ return 0;
|
||||
+
|
||||
+ return -1;
|
||||
+}
|
||||
+
|
||||
static void
|
||||
write_tables(void) {
|
||||
/* Mark the super block valid. */
|
||||
@@ -707,9 +718,16 @@ main(int argc, char ** argv) {
|
||||
DEV = open(device_name,O_RDWR);
|
||||
if (DEV<0)
|
||||
die(_("unable to open %s"));
|
||||
- if (!S_ISBLK(statbuf.st_mode))
|
||||
+ if (S_ISBLK(statbuf.st_mode)) {
|
||||
+ int sectorsize;
|
||||
+
|
||||
+ if (blkdev_get_sector_size(DEV, §orsize) == -1)
|
||||
+ die(_("cannot determine sector size for %s"));
|
||||
+ if (BLOCK_SIZE < sectorsize)
|
||||
+ die(_("block size smaller than physical sector size of %s"));
|
||||
+ } else if (!S_ISBLK(statbuf.st_mode)) {
|
||||
check=0;
|
||||
- else if (statbuf.st_rdev == 0x0300 || statbuf.st_rdev == 0x0340)
|
||||
+ } else if (statbuf.st_rdev == 0x0300 || statbuf.st_rdev == 0x0340)
|
||||
die(_("will not try to make filesystem on '%s'"));
|
||||
setup_tables();
|
||||
if (check)
|
103
util-linux-2.13.1-mkfs.minix_device_size_cleanup.patch
Normal file
103
util-linux-2.13.1-mkfs.minix_device_size_cleanup.patch
Normal file
@ -0,0 +1,103 @@
|
||||
Index: util-linux-ng-2.13.1/disk-utils/mkfs.minix.c
|
||||
===================================================================
|
||||
--- util-linux-ng-2.13.1.orig/disk-utils/mkfs.minix.c
|
||||
+++ util-linux-ng-2.13.1/disk-utils/mkfs.minix.c
|
||||
@@ -78,6 +78,7 @@
|
||||
#ifndef BLKGETSIZE
|
||||
#define BLKGETSIZE _IO(0x12,96) /* return device size */
|
||||
#endif
|
||||
+#define BLKGETSIZE64 _IOR(0x12,114,size_t) /* return device size in bytes (u64 *arg) */
|
||||
#define BLKSSZGET _IO(0x12,104)/* get block device sector size */
|
||||
|
||||
#ifndef __GNUC__
|
||||
@@ -103,7 +104,7 @@
|
||||
static char * program_name = "mkfs";
|
||||
static char * device_name = NULL;
|
||||
static int DEV = -1;
|
||||
-static long BLOCKS = 0;
|
||||
+static unsigned long long BLOCKS = 0;
|
||||
static int check = 0;
|
||||
static int badblocks = 0;
|
||||
static int namelen = 30; /* default (changed to 30, per Linus's
|
||||
@@ -219,24 +220,21 @@ count_blocks (int fd) {
|
||||
return (low + 1);
|
||||
}
|
||||
|
||||
-static int
|
||||
-get_size(const char *file) {
|
||||
- int fd;
|
||||
- long size;
|
||||
-
|
||||
- fd = open(file, O_RDWR);
|
||||
- if (fd < 0) {
|
||||
- perror(file);
|
||||
- exit(1);
|
||||
- }
|
||||
+/* get size in bytes */
|
||||
+int
|
||||
+blkdev_get_size(int fd, unsigned long long *bytes)
|
||||
+{
|
||||
+ unsigned long size;
|
||||
+
|
||||
+ if (ioctl(fd, BLKGETSIZE64, bytes) >= 0)
|
||||
+ return 0;
|
||||
+
|
||||
if (ioctl(fd, BLKGETSIZE, &size) >= 0) {
|
||||
- close(fd);
|
||||
- return (size * 512);
|
||||
+ *bytes = ((unsigned long long)size << 9);
|
||||
+ return 0;
|
||||
}
|
||||
-
|
||||
- size = count_blocks(fd);
|
||||
- close(fd);
|
||||
- return size;
|
||||
+
|
||||
+ return -1;
|
||||
}
|
||||
|
||||
/* get hardware sector size */
|
||||
@@ -687,19 +685,9 @@ main(int argc, char ** argv) {
|
||||
}
|
||||
}
|
||||
|
||||
- if (device_name && !BLOCKS)
|
||||
- BLOCKS = get_size (device_name) / 1024;
|
||||
- if (!device_name || BLOCKS<10) {
|
||||
+ if (!device_name) {
|
||||
usage();
|
||||
}
|
||||
- if (version2) {
|
||||
- if (namelen == 14)
|
||||
- magic = MINIX2_SUPER_MAGIC;
|
||||
- else
|
||||
- magic = MINIX2_SUPER_MAGIC2;
|
||||
- } else
|
||||
- if (BLOCKS > 65535)
|
||||
- BLOCKS = 65535;
|
||||
check_mount(); /* is it already mounted? */
|
||||
tmp = root_block;
|
||||
*(short *)tmp = 1;
|
||||
@@ -725,10 +713,22 @@ main(int argc, char ** argv) {
|
||||
die(_("cannot determine sector size for %s"));
|
||||
if (BLOCK_SIZE < sectorsize)
|
||||
die(_("block size smaller than physical sector size of %s"));
|
||||
+ if (!BLOCKS && blkdev_get_size(DEV, &BLOCKS) == -1)
|
||||
+ die(_("cannot determine size of %s"));
|
||||
} else if (!S_ISBLK(statbuf.st_mode)) {
|
||||
check=0;
|
||||
} else if (statbuf.st_rdev == 0x0300 || statbuf.st_rdev == 0x0340)
|
||||
die(_("will not try to make filesystem on '%s'"));
|
||||
+ if (BLOCKS < 10)
|
||||
+ die(_("number of blocks too small"));
|
||||
+ if (version2) {
|
||||
+ if (namelen == 14)
|
||||
+ magic = MINIX2_SUPER_MAGIC;
|
||||
+ else
|
||||
+ magic = MINIX2_SUPER_MAGIC2;
|
||||
+ } else
|
||||
+ if (BLOCKS > 65535)
|
||||
+ BLOCKS = 65535;
|
||||
setup_tables();
|
||||
if (check)
|
||||
check_blocks();
|
@ -0,0 +1,245 @@
|
||||
commit 2368077223fa5800cf88659c9c57a7f6517f3fad
|
||||
Author: Karel Zak <kzak@redhat.com>
|
||||
Date: Tue Sep 11 14:35:34 2007 +0200
|
||||
|
||||
mount: prevent loop mounting the same file twice
|
||||
|
||||
The mount syscall prevents mounting the same device twice
|
||||
to the same mountpoint. When loop mounting a file, for each
|
||||
file a new loop device gets allocated, which prevents the detection
|
||||
of loop mounting the same file to the same mountpoint twice.
|
||||
The patch adds a check to prevent double mounts, if the same loopfile
|
||||
is going to be mounted with the same offset to the same mountpoint.
|
||||
|
||||
Co-Author: Matthias Koenig <mkoenig@suse.de>
|
||||
Signed-off-by: Matthias Koenig <mkoenig@suse.de>
|
||||
Signed-off-by: Karel Zak <kzak@redhat.com>
|
||||
|
||||
Index: util-linux-ng-2.13.1/mount/lomount.c
|
||||
===================================================================
|
||||
--- util-linux-ng-2.13.1.orig/mount/lomount.c
|
||||
+++ util-linux-ng-2.13.1/mount/lomount.c
|
||||
@@ -143,7 +143,7 @@ show_used_loop_devices (void) {
|
||||
|
||||
for (j = 0; j < SIZE(loop_formats); j++) {
|
||||
for(i = 0; i < 256; i++) {
|
||||
- sprintf(dev, loop_formats[j], i);
|
||||
+ snprintf(dev, sizeof(dev), loop_formats[j], i);
|
||||
if (stat (dev, &statbuf) == 0 && S_ISBLK(statbuf.st_mode)) {
|
||||
fd = open (dev, O_RDONLY);
|
||||
if (fd >= 0) {
|
||||
@@ -169,6 +169,102 @@ show_used_loop_devices (void) {
|
||||
|
||||
#endif
|
||||
|
||||
+/* check if the loopfile is already associated with the same given
|
||||
+ * parameters.
|
||||
+ *
|
||||
+ * returns: -1 error
|
||||
+ * 0 unused
|
||||
+ * 1 loop device already used
|
||||
+ */
|
||||
+static int
|
||||
+is_associated(int dev, struct stat *file, unsigned long long offset)
|
||||
+{
|
||||
+ struct loop_info64 linfo64;
|
||||
+ struct loop_info64 linfo;
|
||||
+ int ret = 0;
|
||||
+
|
||||
+ if (ioctl(dev, LOOP_GET_STATUS64, &linfo64) == 0) {
|
||||
+ if (file->st_dev == linfo64.lo_device &&
|
||||
+ file->st_ino == linfo64.lo_inode &&
|
||||
+ offset == linfo64.lo_offset)
|
||||
+ ret = 1;
|
||||
+ return ret;
|
||||
+ }
|
||||
+ if (ioctl(dev, LOOP_GET_STATUS, &linfo) == 0) {
|
||||
+ if (file->st_dev == linfo.lo_device &&
|
||||
+ file->st_ino == linfo.lo_inode &&
|
||||
+ offset == linfo.lo_offset)
|
||||
+ ret = 1;
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ return errno == ENXIO ? 0 : -1;
|
||||
+}
|
||||
+
|
||||
+/* check if the loop file is already used with the same given
|
||||
+ * parameters. We check for device no, inode and offset.
|
||||
+ * returns: associated devname or NULL
|
||||
+ */
|
||||
+char *
|
||||
+loopfile_used (const char *filename, unsigned long long offset) {
|
||||
+ char dev[20];
|
||||
+ char *loop_formats[] = { "/dev/loop%d", "/dev/loop/%d" };
|
||||
+ int i, j, fd;
|
||||
+ struct stat devstat, filestat;
|
||||
+ struct loop_info loopinfo;
|
||||
+
|
||||
+ if (stat(filename, &filestat) == -1) {
|
||||
+ perror(filename);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ for (j = 0; j < SIZE(loop_formats); j++) {
|
||||
+ for(i = 0; i < 256; i++) {
|
||||
+ snprintf(dev, sizeof(dev), loop_formats[j], i);
|
||||
+ if (stat (dev, &devstat) == 0 && S_ISBLK(devstat.st_mode)) {
|
||||
+ fd = open (dev, O_RDONLY);
|
||||
+ if (fd >= 0) {
|
||||
+ int res = 0;
|
||||
+
|
||||
+ if(ioctl (fd, LOOP_GET_STATUS, &loopinfo) == 0)
|
||||
+ res = is_associated(fd, &filestat, offset);
|
||||
+ close (fd);
|
||||
+ if (res == 1)
|
||||
+ return xstrdup(dev);
|
||||
+ }
|
||||
+ continue; /* continue trying as long as devices exist */
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+int
|
||||
+loopfile_used_with(char *devname, const char *filename, unsigned long long offset)
|
||||
+{
|
||||
+ struct stat statbuf;
|
||||
+ int fd, ret;
|
||||
+
|
||||
+ if (!is_loop_device(devname))
|
||||
+ return 0;
|
||||
+
|
||||
+ if (stat(filename, &statbuf) == -1) {
|
||||
+ perror(filename);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ fd = open(devname, O_RDONLY);
|
||||
+ if (fd == -1) {
|
||||
+ perror(devname);
|
||||
+ return -1;
|
||||
+ }
|
||||
+ ret = is_associated(fd, &statbuf, offset);
|
||||
+
|
||||
+ close(fd);
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
int
|
||||
is_loop_device (const char *device) {
|
||||
struct stat statbuf;
|
||||
@@ -284,6 +380,16 @@ set_loop(const char *device, const char
|
||||
char *filename;
|
||||
char res_file[PATH_MAX+1];
|
||||
|
||||
+ if (verbose) {
|
||||
+ char *xdev = loopfile_used(file, offset);
|
||||
+
|
||||
+ if (xdev) {
|
||||
+ printf(_("warning: %s is already associated with %s\n"),
|
||||
+ file, xdev);
|
||||
+ free(xdev);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
mode = (*loopro ? O_RDONLY : O_RDWR);
|
||||
if ((ffd = open(file, mode)) < 0) {
|
||||
if (!*loopro && errno == EROFS)
|
||||
Index: util-linux-ng-2.13.1/mount/lomount.h
|
||||
===================================================================
|
||||
--- util-linux-ng-2.13.1.orig/mount/lomount.h
|
||||
+++ util-linux-ng-2.13.1/mount/lomount.h
|
||||
@@ -4,3 +4,6 @@ extern int set_loop(const char *, const
|
||||
extern int del_loop(const char *);
|
||||
extern int is_loop_device(const char *);
|
||||
extern char * find_unused_loop_device(void);
|
||||
+
|
||||
+extern int loopfile_used_with(char *devname, const char *filename, unsigned long long offset);
|
||||
+extern char *loopfile_used (const char *filename, unsigned long long offset);
|
||||
Index: util-linux-ng-2.13.1/mount/mount.c
|
||||
===================================================================
|
||||
--- util-linux-ng-2.13.1.orig/mount/mount.c
|
||||
+++ util-linux-ng-2.13.1/mount/mount.c
|
||||
@@ -42,6 +42,7 @@
|
||||
#include "mount_paths.h"
|
||||
#include "env.h"
|
||||
#include "nls.h"
|
||||
+#include "realpath.h"
|
||||
|
||||
#define DO_PS_FIDDLING
|
||||
|
||||
@@ -833,9 +834,49 @@ suid_check(const char *spec, const char
|
||||
*flags &= ~(MS_OWNER | MS_GROUP);
|
||||
}
|
||||
|
||||
+/* Check, if there already exists a mounted loop device on the mountpoint node
|
||||
+ * with the same parameters.
|
||||
+ */
|
||||
+static int
|
||||
+is_mounted_same_loopfile(const char *node0, const char *loopfile, unsigned long long offset)
|
||||
+{
|
||||
+ struct mntentchn *mnt = NULL;
|
||||
+ char node[PATH_MAX+1];
|
||||
+ int res = 0;
|
||||
+
|
||||
+ myrealpath(node0, node, PATH_MAX);
|
||||
+
|
||||
+ /* Search for mountpoint node in mtab,
|
||||
+ * procceed if any of these has the loop option set or
|
||||
+ * the device is a loop device
|
||||
+ */
|
||||
+ mnt = getmntdirbackward(node, mnt);
|
||||
+ if (!mnt) {
|
||||
+ return 0;
|
||||
+ }
|
||||
+ for(; mnt && res == 0; mnt = getmntdirbackward(node, mnt)) {
|
||||
+ char *p;
|
||||
+
|
||||
+ if (strncmp(mnt->m.mnt_fsname, "/dev/loop", 9) == 0)
|
||||
+ res = loopfile_used_with((char *) mnt->m.mnt_fsname,
|
||||
+ loopfile, offset);
|
||||
+
|
||||
+ else if ((p = strstr(mnt->m.mnt_opts, "loop="))) {
|
||||
+ char *dev = xstrdup(p+5);
|
||||
+ if ((p = strchr(dev, ',')))
|
||||
+ *p = '\0';
|
||||
+ res = loopfile_used_with(dev, loopfile, offset);
|
||||
+ free(dev);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return res;
|
||||
+}
|
||||
+
|
||||
static int
|
||||
loop_check(const char **spec, const char **type, int *flags,
|
||||
- int *loop, const char **loopdev, const char **loopfile) {
|
||||
+ int *loop, const char **loopdev, const char **loopfile,
|
||||
+ const char *node) {
|
||||
int looptype;
|
||||
unsigned long long offset;
|
||||
|
||||
@@ -876,6 +917,11 @@ loop_check(const char **spec, const char
|
||||
|
||||
offset = opt_offset ? strtoull(opt_offset, NULL, 0) : 0;
|
||||
|
||||
+ if (is_mounted_same_loopfile(node, *loopfile, offset)) {
|
||||
+ error(_("mount: according to mtab %s is already mounted on %s as loop"), *loopfile, node);
|
||||
+ return EX_FAIL;
|
||||
+ }
|
||||
+
|
||||
do {
|
||||
if (!*loopdev || !**loopdev)
|
||||
*loopdev = find_unused_loop_device();
|
||||
@@ -1061,7 +1107,7 @@ try_mount_one (const char *spec0, const
|
||||
* stale assignments of files to loop devices. Nasty when used for
|
||||
* encryption.
|
||||
*/
|
||||
- res = loop_check(&spec, &types, &flags, &loop, &loopdev, &loopfile);
|
||||
+ res = loop_check(&spec, &types, &flags, &loop, &loopdev, &loopfile, node);
|
||||
if (res)
|
||||
goto out;
|
||||
}
|
@ -40,31 +40,33 @@ Signed-off-by: Ludwig Nussel <ludwig.nussel@suse.de>
|
||||
create mode 100644 mount/sha512.c
|
||||
create mode 100644 mount/sha512.h
|
||||
|
||||
diff --git a/mount/Makefile.am b/mount/Makefile.am
|
||||
index 01643b2..cb7af0a 100644
|
||||
--- a/mount/Makefile.am
|
||||
+++ b/mount/Makefile.am
|
||||
@@ -13,6 +13,7 @@ headers_common = fstab.h mount_mntent.h mount_constants.h \
|
||||
Index: util-linux-ng-2.13.1/mount/Makefile.am
|
||||
===================================================================
|
||||
--- util-linux-ng-2.13.1.orig/mount/Makefile.am
|
||||
+++ util-linux-ng-2.13.1/mount/Makefile.am
|
||||
@@ -13,6 +13,7 @@ headers_common = fstab.h linux_fs.h moun
|
||||
getusername.h loop.h sundries.h
|
||||
|
||||
mount_common = fstab.c mount_mntent.c getusername.c lomount.c \
|
||||
+ rmd160.c sha512.c \
|
||||
$(utils_common) $(headers_common) ../lib/env.c ../lib/linux_version.c \
|
||||
../lib/blkdev.c
|
||||
$(utils_common) $(headers_common) ../lib/env.c
|
||||
|
||||
mount_SOURCES = mount.c $(mount_common) ../lib/setproctitle.c
|
||||
@@ -25,7 +26,8 @@ umount_LDFLAGS = $(SUID_LDFLAGS) $(AM_LD
|
||||
|
||||
@@ -27,6 +28,7 @@ umount_LDFLAGS = $(SUID_LDFLAGS) $(AM_LDFLAGS)
|
||||
swapon_SOURCES = swapon.c swap_constants.h $(utils_common)
|
||||
|
||||
losetup_SOURCES = lomount.c sundries.c xmalloc.c realpath.c \
|
||||
+ rmd160.c sha512.c \
|
||||
loop.h lomount.h xmalloc.h sundries.h realpath.h
|
||||
-losetup_SOURCES = lomount.c loop.h lomount.h realpath.c xmalloc.c
|
||||
+losetup_SOURCES = lomount.c loop.h lomount.h realpath.c xmalloc.c \
|
||||
+ rmd160.c sha512.c
|
||||
losetup_CPPFLAGS = -DMAIN $(AM_CPPFLAGS)
|
||||
|
||||
diff --git a/mount/lomount.c b/mount/lomount.c
|
||||
index 5bd8954..98f144f 100644
|
||||
--- a/mount/lomount.c
|
||||
+++ b/mount/lomount.c
|
||||
@@ -20,12 +20,18 @@
|
||||
mount_LDADD = $(LDADD_common)
|
||||
Index: util-linux-ng-2.13.1/mount/lomount.c
|
||||
===================================================================
|
||||
--- util-linux-ng-2.13.1.orig/mount/lomount.c
|
||||
+++ util-linux-ng-2.13.1/mount/lomount.c
|
||||
@@ -20,11 +20,16 @@
|
||||
|
||||
#include "loop.h"
|
||||
#include "lomount.h"
|
||||
@ -72,22 +74,20 @@ index 5bd8954..98f144f 100644
|
||||
+#include "sha512.h"
|
||||
#include "xstrncpy.h"
|
||||
#include "nls.h"
|
||||
#include "sundries.h"
|
||||
#include "xmalloc.h"
|
||||
#include "realpath.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
+#ifndef MIN
|
||||
+#define MIN(a,b) ((a<b)?(a):(b))
|
||||
+#endif
|
||||
+
|
||||
#define SIZE(a) (sizeof(a)/sizeof(a[0]))
|
||||
|
||||
#ifdef LOOP_SET_FD
|
||||
@@ -93,12 +99,22 @@ show_loop(char *device) {
|
||||
extern int verbose;
|
||||
extern char *progname;
|
||||
@@ -97,12 +102,22 @@ show_loop(char *device) {
|
||||
|
||||
if (loopinfo64.lo_encrypt_type ||
|
||||
loopinfo64.lo_crypt_name[0]) {
|
||||
- char *e = (char *)loopinfo64.lo_crypt_name;
|
||||
- char *e = loopinfo64.lo_crypt_name;
|
||||
+ const char *e = (const char*)loopinfo64.lo_crypt_name;
|
||||
|
||||
if (*e == 0 && loopinfo64.lo_encrypt_type == 1)
|
||||
@ -109,7 +109,7 @@ index 5bd8954..98f144f 100644
|
||||
}
|
||||
printf("\n");
|
||||
close (fd);
|
||||
@@ -353,7 +369,7 @@ xgetpass(int pfd, const char *prompt) {
|
||||
@@ -357,7 +372,7 @@ xgetpass(int pfd, const char *prompt) {
|
||||
}
|
||||
|
||||
if (pass == NULL)
|
||||
@ -118,7 +118,7 @@ index 5bd8954..98f144f 100644
|
||||
|
||||
pass[i] = 0;
|
||||
return pass;
|
||||
@@ -367,12 +383,30 @@ digits_only(const char *s) {
|
||||
@@ -371,12 +386,30 @@ digits_only(const char *s) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -148,12 +148,12 @@ index 5bd8954..98f144f 100644
|
||||
int fd, ffd, mode, i;
|
||||
- char *pass;
|
||||
+ char *pass = NULL;
|
||||
char *filename;
|
||||
char filename[PATH_MAX+1];
|
||||
|
||||
if (verbose) {
|
||||
@@ -406,13 +440,37 @@ set_loop(const char *device, const char *file, unsigned long long offset,
|
||||
filename = (char *) file;
|
||||
xstrncpy((char *)loopinfo64.lo_file_name, filename, LO_NAME_SIZE);
|
||||
@@ -410,13 +443,38 @@ set_loop(const char *device, const char
|
||||
myrealpath(file, filename, PATH_MAX);
|
||||
xstrncpy(loopinfo64.lo_file_name, filename, LO_NAME_SIZE);
|
||||
|
||||
+ loopinfo64.lo_encrypt_key_size = 0;
|
||||
+
|
||||
@ -167,8 +167,8 @@ index 5bd8954..98f144f 100644
|
||||
+ } else if (digits_only(encryption)) {
|
||||
loopinfo64.lo_encrypt_type = atoi(encryption);
|
||||
} else {
|
||||
- loopinfo64.lo_encrypt_type = LO_CRYPT_CRYPTOAPI;
|
||||
- snprintf((char *)loopinfo64.lo_crypt_name, LO_NAME_SIZE,
|
||||
loopinfo64.lo_encrypt_type = LO_CRYPT_CRYPTOAPI;
|
||||
- snprintf(loopinfo64.lo_crypt_name, LO_NAME_SIZE,
|
||||
+ // check for something like twofish256
|
||||
+ unsigned len = strlen(encryption);
|
||||
+ snprintf((char*)loopinfo64.lo_crypt_name, LO_NAME_SIZE,
|
||||
@ -192,7 +192,7 @@ index 5bd8954..98f144f 100644
|
||||
}
|
||||
}
|
||||
|
||||
@@ -432,20 +490,70 @@ set_loop(const char *device, const char *file, unsigned long long offset,
|
||||
@@ -436,20 +494,70 @@ set_loop(const char *device, const char
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -210,7 +210,7 @@ index 5bd8954..98f144f 100644
|
||||
+ void (*hfunc)(const unsigned char*, size_t, unsigned char*, size_t) = NULL;
|
||||
+
|
||||
memset(loopinfo64.lo_encrypt_key, 0, LO_KEY_SIZE);
|
||||
- xstrncpy((char *)loopinfo64.lo_encrypt_key, pass, LO_KEY_SIZE);
|
||||
- xstrncpy(loopinfo64.lo_encrypt_key, pass, LO_KEY_SIZE);
|
||||
+
|
||||
+ pass = xgetpass(pfd, _("Password: "));
|
||||
+ if(!pass)
|
||||
@ -275,7 +275,7 @@ index 5bd8954..98f144f 100644
|
||||
}
|
||||
|
||||
if (ioctl(fd, LOOP_SET_FD, ffd) < 0) {
|
||||
@@ -532,8 +640,8 @@ mutter(void) {
|
||||
@@ -530,8 +638,8 @@ mutter(void) {
|
||||
}
|
||||
|
||||
int
|
||||
@ -286,7 +286,7 @@ index 5bd8954..98f144f 100644
|
||||
mutter();
|
||||
return 1;
|
||||
}
|
||||
@@ -569,7 +677,13 @@ usage(void) {
|
||||
@@ -570,7 +678,13 @@ usage(void) {
|
||||
" %1$s [ options ] {-f|--find|loop_device} file # setup\n"
|
||||
"\nOptions:\n"
|
||||
" -e | --encryption <type> enable data encryption with specified <name/num>\n"
|
||||
@ -300,7 +300,7 @@ index 5bd8954..98f144f 100644
|
||||
" -o | --offset <num> start at offset <num> into file\n"
|
||||
" -p | --pass-fd <num> read passphrase from file descriptor <num>\n"
|
||||
" -r | --read-only setup read-only loop device\n"
|
||||
@@ -582,11 +696,14 @@ usage(void) {
|
||||
@@ -594,11 +708,14 @@ error (const char *fmt, ...) {
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
char *p, *offset, *encryption, *passfd, *device, *file;
|
||||
@ -315,7 +315,7 @@ index 5bd8954..98f144f 100644
|
||||
unsigned long long off;
|
||||
struct option longopts[] = {
|
||||
{ "all", 0, 0, 'a' },
|
||||
@@ -594,6 +711,8 @@ main(int argc, char **argv) {
|
||||
@@ -606,6 +723,8 @@ main(int argc, char **argv) {
|
||||
{ "encryption", 1, 0, 'e' },
|
||||
{ "find", 0, 0, 'f' },
|
||||
{ "help", 0, 0, 'h' },
|
||||
@ -324,7 +324,7 @@ index 5bd8954..98f144f 100644
|
||||
{ "offset", 1, 0, 'o' },
|
||||
{ "pass-fd", 1, 0, 'p' },
|
||||
{ "read-only", 0, 0, 'r' },
|
||||
@@ -609,12 +728,13 @@ main(int argc, char **argv) {
|
||||
@@ -621,12 +740,13 @@ main(int argc, char **argv) {
|
||||
delete = find = all = 0;
|
||||
off = 0;
|
||||
offset = encryption = passfd = NULL;
|
||||
@ -339,7 +339,7 @@ index 5bd8954..98f144f 100644
|
||||
longopts, NULL)) != -1) {
|
||||
switch (c) {
|
||||
case 'a':
|
||||
@@ -633,6 +753,12 @@ main(int argc, char **argv) {
|
||||
@@ -645,6 +765,12 @@ main(int argc, char **argv) {
|
||||
case 'f':
|
||||
find = 1;
|
||||
break;
|
||||
@ -352,7 +352,7 @@ index 5bd8954..98f144f 100644
|
||||
case 'o':
|
||||
offset = optarg;
|
||||
break;
|
||||
@@ -696,8 +822,10 @@ main(int argc, char **argv) {
|
||||
@@ -708,8 +834,10 @@ main(int argc, char **argv) {
|
||||
usage();
|
||||
if (passfd && sscanf(passfd, "%d", &pfd) != 1)
|
||||
usage();
|
||||
@ -364,22 +364,10 @@ index 5bd8954..98f144f 100644
|
||||
if (res == 2 && find) {
|
||||
if (verbose)
|
||||
printf("stolen loop=%s...trying again\n",
|
||||
diff --git a/mount/lomount.h b/mount/lomount.h
|
||||
index 38b3a48..3a6210f 100644
|
||||
--- a/mount/lomount.h
|
||||
+++ b/mount/lomount.h
|
||||
@@ -1,5 +1,5 @@
|
||||
-extern int set_loop(const char *, const char *, unsigned long long,
|
||||
- const char *, int, int *);
|
||||
+extern int set_loop(const char *device, const char *file, unsigned long long offset,
|
||||
+ const char *encryption, const char* phash, int pfd, int *loopro, int keysz);
|
||||
extern int del_loop(const char *);
|
||||
extern int is_loop_device(const char *);
|
||||
extern char * find_unused_loop_device(void);
|
||||
diff --git a/mount/losetup.8 b/mount/losetup.8
|
||||
index db2929f..54bbc94 100644
|
||||
--- a/mount/losetup.8
|
||||
+++ b/mount/losetup.8
|
||||
Index: util-linux-ng-2.13.1/mount/losetup.8
|
||||
===================================================================
|
||||
--- util-linux-ng-2.13.1.orig/mount/losetup.8
|
||||
+++ util-linux-ng-2.13.1/mount/losetup.8
|
||||
@@ -76,6 +76,15 @@ find the first unused loop device. If a
|
||||
argument is present, use this device. Otherwise, print its name.
|
||||
.IP "\fB\-h, \-\-help\fP"
|
||||
@ -405,11 +393,11 @@ index db2929f..54bbc94 100644
|
||||
|
||||
Cryptoloop is deprecated in favor of dm-crypt. For more details see
|
||||
.B cryptsetup(8).
|
||||
diff --git a/mount/mount.8 b/mount/mount.8
|
||||
index 54b11d4..e79ea04 100644
|
||||
--- a/mount/mount.8
|
||||
+++ b/mount/mount.8
|
||||
@@ -615,6 +615,15 @@ This option implies the options
|
||||
Index: util-linux-ng-2.13.1/mount/mount.8
|
||||
===================================================================
|
||||
--- util-linux-ng-2.13.1.orig/mount/mount.8
|
||||
+++ util-linux-ng-2.13.1/mount/mount.8
|
||||
@@ -610,6 +610,15 @@ This option implies the options
|
||||
(unless overridden by subsequent options, as in the option line
|
||||
.BR group,dev,suid ).
|
||||
.TP
|
||||
@ -425,7 +413,7 @@ index 54b11d4..e79ea04 100644
|
||||
.B mand
|
||||
Allow mandatory locks on this filesystem. See
|
||||
.BR fcntl (2).
|
||||
@@ -2010,6 +2019,10 @@ that are really options to
|
||||
@@ -2008,6 +2017,10 @@ that are really options to
|
||||
.BR \%losetup (8).
|
||||
(These options can be used in addition to those specific
|
||||
to the filesystem type.)
|
||||
@ -436,11 +424,11 @@ index 54b11d4..e79ea04 100644
|
||||
|
||||
If no explicit loop device is mentioned
|
||||
(but just an option `\fB\-o loop\fP' is given), then
|
||||
diff --git a/mount/mount.c b/mount/mount.c
|
||||
index 60fe4fe..164ae3c 100644
|
||||
--- a/mount/mount.c
|
||||
+++ b/mount/mount.c
|
||||
@@ -88,6 +88,9 @@ static int suid = 0;
|
||||
Index: util-linux-ng-2.13.1/mount/mount.c
|
||||
===================================================================
|
||||
--- util-linux-ng-2.13.1.orig/mount/mount.c
|
||||
+++ util-linux-ng-2.13.1/mount/mount.c
|
||||
@@ -94,6 +94,9 @@ static int suid = 0;
|
||||
/* Contains the fd to read the passphrase from, if any. */
|
||||
static int pfd = -1;
|
||||
|
||||
@ -450,7 +438,7 @@ index 60fe4fe..164ae3c 100644
|
||||
/* Map from -o and fstab option strings to the flag argument to mount(2). */
|
||||
struct opt_map {
|
||||
const char *opt; /* option name */
|
||||
@@ -182,6 +185,7 @@ static const struct opt_map opt_map[] = {
|
||||
@@ -191,6 +194,7 @@ static int opt_nofail = 0;
|
||||
|
||||
static const char *opt_loopdev, *opt_vfstype, *opt_offset, *opt_encryption,
|
||||
*opt_speed, *opt_comment, *opt_uhelper;
|
||||
@ -458,7 +446,7 @@ index 60fe4fe..164ae3c 100644
|
||||
|
||||
static int mounted (const char *spec0, const char *node0);
|
||||
static int check_special_mountprog(const char *spec, const char *node,
|
||||
@@ -196,6 +200,8 @@ static struct string_opt_map {
|
||||
@@ -205,6 +209,8 @@ static struct string_opt_map {
|
||||
{ "vfs=", 1, &opt_vfstype },
|
||||
{ "offset=", 0, &opt_offset },
|
||||
{ "encryption=", 0, &opt_encryption },
|
||||
@ -467,7 +455,7 @@ index 60fe4fe..164ae3c 100644
|
||||
{ "speed=", 0, &opt_speed },
|
||||
{ "comment=", 1, &opt_comment },
|
||||
{ "uhelper=", 0, &opt_uhelper },
|
||||
@@ -897,7 +903,7 @@ loop_check(const char **spec, const char **type, int *flags,
|
||||
@@ -903,7 +909,7 @@ loop_check(const char **spec, const char
|
||||
*type = opt_vfstype;
|
||||
}
|
||||
|
||||
@ -476,7 +464,7 @@ index 60fe4fe..164ae3c 100644
|
||||
*loopfile = *spec;
|
||||
|
||||
if (*loop) {
|
||||
@@ -923,9 +929,10 @@ loop_check(const char **spec, const char **type, int *flags,
|
||||
@@ -929,9 +935,10 @@ loop_check(const char **spec, const char
|
||||
return EX_SYSERR; /* no more loop devices */
|
||||
if (verbose)
|
||||
printf(_("mount: going to use the loop device %s\n"), *loopdev);
|
||||
@ -489,15 +477,15 @@ index 60fe4fe..164ae3c 100644
|
||||
if (res == 2) {
|
||||
/* loop dev has been grabbed by some other process,
|
||||
try again, if not given explicitly */
|
||||
@@ -1661,6 +1668,7 @@ static struct option longopts[] = {
|
||||
@@ -1681,6 +1688,7 @@ static struct option longopts[] = {
|
||||
{ "options", 1, 0, 'o' },
|
||||
{ "test-opts", 1, 0, 'O' },
|
||||
{ "pass-fd", 1, 0, 'p' },
|
||||
+ { "keybits", 1, 0, 'k' },
|
||||
{ "types", 1, 0, 't' },
|
||||
{ "bind", 0, 0, 128 },
|
||||
{ "move", 0, 0, 133 },
|
||||
@@ -1807,6 +1815,7 @@ main(int argc, char *argv[]) {
|
||||
{ "replace", 0, 0, 129 },
|
||||
@@ -1836,6 +1844,7 @@ main(int argc, char *argv[]) {
|
||||
char *options = NULL, *test_opts = NULL, *node;
|
||||
const char *spec = NULL;
|
||||
char *label = NULL;
|
||||
@ -505,7 +493,7 @@ index 60fe4fe..164ae3c 100644
|
||||
char *uuid = NULL;
|
||||
char *types = NULL;
|
||||
char *p;
|
||||
@@ -1837,7 +1846,7 @@ main(int argc, char *argv[]) {
|
||||
@@ -1866,7 +1875,7 @@ main(int argc, char *argv[]) {
|
||||
initproctitle(argc, argv);
|
||||
#endif
|
||||
|
||||
@ -514,7 +502,7 @@ index 60fe4fe..164ae3c 100644
|
||||
longopts, NULL)) != -1) {
|
||||
switch (c) {
|
||||
case 'a': /* mount everything in fstab */
|
||||
@@ -1855,6 +1864,9 @@ main(int argc, char *argv[]) {
|
||||
@@ -1884,6 +1893,9 @@ main(int argc, char *argv[]) {
|
||||
case 'i':
|
||||
external_allowed = 0;
|
||||
break;
|
||||
@ -524,9 +512,9 @@ index 60fe4fe..164ae3c 100644
|
||||
case 'l':
|
||||
list_with_volumelabel = 1;
|
||||
break;
|
||||
@@ -1991,6 +2003,9 @@ main(int argc, char *argv[]) {
|
||||
|
||||
atexit(unlock_mtab);
|
||||
@@ -2030,6 +2042,9 @@ main(int argc, char *argv[]) {
|
||||
create_mtab ();
|
||||
}
|
||||
|
||||
+ if (keysize && sscanf(keysize,"%d",&keysz) != 1)
|
||||
+ die (EX_USAGE, _("mount: argument to --keybits or -k must be a number"));
|
||||
@ -534,22 +522,10 @@ index 60fe4fe..164ae3c 100644
|
||||
switch (argc+specseen) {
|
||||
case 0:
|
||||
/* mount -a */
|
||||
diff --git a/mount/my_dev_t.h b/mount/my_dev_t.h
|
||||
new file mode 100644
|
||||
index 0000000..5c4c0a1
|
||||
Index: util-linux-ng-2.13.1/mount/rmd160.c
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ b/mount/my_dev_t.h
|
||||
@@ -0,0 +1,5 @@
|
||||
+/* silliness to get dev_t defined as the kernel defines it */
|
||||
+/* glibc uses a different dev_t */
|
||||
+
|
||||
+#include <linux/posix_types.h>
|
||||
+#define my_dev_t __kernel_old_dev_t
|
||||
diff --git a/mount/rmd160.c b/mount/rmd160.c
|
||||
new file mode 100644
|
||||
index 0000000..3430954
|
||||
--- /dev/null
|
||||
+++ b/mount/rmd160.c
|
||||
+++ util-linux-ng-2.13.1/mount/rmd160.c
|
||||
@@ -0,0 +1,532 @@
|
||||
+/* rmd160.c - RIPE-MD160
|
||||
+ * Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
@ -1083,11 +1059,10 @@ index 0000000..3430954
|
||||
+ rmd160_final( &hd );
|
||||
+ memcpy( outbuf, hd.buf, 20 );
|
||||
+}
|
||||
diff --git a/mount/rmd160.h b/mount/rmd160.h
|
||||
new file mode 100644
|
||||
index 0000000..4b2c61d
|
||||
Index: util-linux-ng-2.13.1/mount/rmd160.h
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ b/mount/rmd160.h
|
||||
+++ util-linux-ng-2.13.1/mount/rmd160.h
|
||||
@@ -0,0 +1,11 @@
|
||||
+#ifndef RMD160_H
|
||||
+#define RMD160_H
|
||||
@ -1100,11 +1075,10 @@ index 0000000..4b2c61d
|
||||
+#endif /*RMD160_H*/
|
||||
+
|
||||
+
|
||||
diff --git a/mount/sha512.c b/mount/sha512.c
|
||||
new file mode 100644
|
||||
index 0000000..e4c9c13
|
||||
Index: util-linux-ng-2.13.1/mount/sha512.c
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ b/mount/sha512.c
|
||||
+++ util-linux-ng-2.13.1/mount/sha512.c
|
||||
@@ -0,0 +1,432 @@
|
||||
+/*
|
||||
+ * sha512.c
|
||||
@ -1538,11 +1512,10 @@ index 0000000..e4c9c13
|
||||
+ memset(&ctx, 0, sizeof(ctx));
|
||||
+}
|
||||
+#endif
|
||||
diff --git a/mount/sha512.h b/mount/sha512.h
|
||||
new file mode 100644
|
||||
index 0000000..4b57c01
|
||||
Index: util-linux-ng-2.13.1/mount/sha512.h
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ b/mount/sha512.h
|
||||
+++ util-linux-ng-2.13.1/mount/sha512.h
|
||||
@@ -0,0 +1,45 @@
|
||||
+/*
|
||||
+ * sha512.h
|
||||
@ -1589,6 +1562,16 @@ index 0000000..4b57c01
|
||||
+/* no sha384_write(), use sha512_write() */
|
||||
+/* no sha384_final(), use sha512_final(), result in ctx->sha_out[0...47] */
|
||||
+extern void sha384_hash_buffer(const unsigned char *, size_t, unsigned char *, size_t);
|
||||
--
|
||||
1.5.3.4
|
||||
|
||||
Index: util-linux-ng-2.13.1/mount/lomount.h
|
||||
===================================================================
|
||||
--- util-linux-ng-2.13.1.orig/mount/lomount.h
|
||||
+++ util-linux-ng-2.13.1/mount/lomount.h
|
||||
@@ -1,6 +1,6 @@
|
||||
extern int verbose;
|
||||
-extern int set_loop(const char *, const char *, unsigned long long,
|
||||
- const char *, int, int *);
|
||||
+extern int set_loop(const char *device, const char *file, unsigned long long offset,
|
||||
+ const char *encryption, const char* phash, int pfd, int *loopro, int keysz);
|
||||
extern int del_loop(const char *);
|
||||
extern int is_loop_device(const char *);
|
||||
extern char * find_unused_loop_device(void);
|
||||
|
112
util-linux-ng-2.13-swapon-swsuspend.patch
Normal file
112
util-linux-ng-2.13-swapon-swsuspend.patch
Normal file
@ -0,0 +1,112 @@
|
||||
From db6041b3a569d78f5716baa5a134a3a857014337 Mon Sep 17 00:00:00 2001
|
||||
From: Karel Zak <kzak@redhat.com>
|
||||
Date: Wed, 30 May 2007 13:22:51 +0200
|
||||
Subject: [PATCH] mount: automatically reinitialize swap with old swsuspend data
|
||||
|
||||
We have to reinitialize swap area with old (=useless) software suspend
|
||||
data. The problem is that if we don't do it, then we get data
|
||||
corruption the next time with suspended on.
|
||||
|
||||
Signed-off-by: Karel Zak <kzak@redhat.com>
|
||||
---
|
||||
mount/swapon.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
1 files changed, 63 insertions(+), 0 deletions(-)
|
||||
|
||||
diff --git a/mount/swapon.c b/mount/swapon.c
|
||||
index ed91afc..3f9b442 100644
|
||||
--- a/mount/swapon.c
|
||||
+++ b/mount/swapon.c
|
||||
@@ -10,6 +10,9 @@
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
+#include <sys/types.h>
|
||||
+#include <sys/wait.h>
|
||||
+#include <fcntl.h>
|
||||
#include "xmalloc.h"
|
||||
#include "swap_constants.h"
|
||||
#include "nls.h"
|
||||
@@ -17,6 +20,8 @@
|
||||
#include "realpath.h"
|
||||
#include "mount_paths.h"
|
||||
|
||||
+#define PATH_MKSWAP "/sbin/mkswap"
|
||||
+
|
||||
#ifdef HAVE_SYS_SWAP_H
|
||||
# include <sys/swap.h>
|
||||
#endif
|
||||
@@ -158,6 +163,52 @@ display_summary(void)
|
||||
}
|
||||
|
||||
static int
|
||||
+swap_is_swsuspend(const char *device) {
|
||||
+ const char *type = fsprobe_get_fstype_by_devname(device);
|
||||
+
|
||||
+ return (type && strcmp(type, "swsuspend") == 0) ? 1 : 0;
|
||||
+}
|
||||
+
|
||||
+/* calls mkswap */
|
||||
+static int
|
||||
+swap_reinitialize(const char *device) {
|
||||
+ const char *label = fsprobe_get_label_by_devname(device);
|
||||
+ pid_t pid;
|
||||
+ int status, ret;
|
||||
+
|
||||
+ switch((pid=fork())) {
|
||||
+ case -1: /* fork error */
|
||||
+ fprintf(stderr, _("%s: cannot fork: %s\n"),
|
||||
+ progname, strerror(errno));
|
||||
+ return -1;
|
||||
+
|
||||
+ case 0: /* child */
|
||||
+ if (label && *label)
|
||||
+ execl(PATH_MKSWAP, PATH_MKSWAP, "-L", label, device, NULL);
|
||||
+ else
|
||||
+ execl(PATH_MKSWAP, PATH_MKSWAP, device, NULL);
|
||||
+ exit(1); /* error */
|
||||
+
|
||||
+ default: /* parent */
|
||||
+ do {
|
||||
+ if ((ret = waitpid(pid, &status, 0)) < 0
|
||||
+ && errno == EINTR)
|
||||
+ continue;
|
||||
+ else if (ret < 0) {
|
||||
+ fprintf(stderr, _("%s: waitpid: %s\n"),
|
||||
+ progname, strerror(errno));
|
||||
+ return -1;
|
||||
+ }
|
||||
+ } while (0);
|
||||
+
|
||||
+ /* mkswap returns: 0=suss, 1=error */
|
||||
+ if (WIFEXITED(status) && WEXITSTATUS(status)==0)
|
||||
+ return 0; /* ok */
|
||||
+ }
|
||||
+ return -1; /* error */
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
do_swapon(const char *orig_special, int prio, int canonic) {
|
||||
int status;
|
||||
struct stat st;
|
||||
@@ -179,6 +230,18 @@ do_swapon(const char *orig_special, int prio, int canonic) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
+ /* We have to reinitialize swap with old (=useless) software suspend
|
||||
+ * data. The problem is that if we don't do it, then we get data
|
||||
+ * corruption the next time with suspended on.
|
||||
+ */
|
||||
+ if (swap_is_swsuspend(special)) {
|
||||
+ fprintf(stdout, _("%s: %s: software suspend data detected. "
|
||||
+ "Reinitializing the swap.\n"),
|
||||
+ progname, special);
|
||||
+ if (swap_reinitialize(special) < 0)
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
/* people generally dislike this warning - now it is printed
|
||||
only when `verbose' is set */
|
||||
if (verbose) {
|
||||
--
|
||||
1.5.2.2
|
||||
|
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:901086dc7bc99a89b9f11839107a0dc83f6b9e89158bccb8b30ad0a5a609123b
|
||||
size 1585119
|
3
util-linux-ng-2.13.1.tar.bz2
Normal file
3
util-linux-ng-2.13.1.tar.bz2
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:e67d86683adef0855220b6f5a4b7ca2c51a15faa142e2ecd69925ede76854a4d
|
||||
size 2854716
|
@ -1,3 +1,25 @@
|
||||
-------------------------------------------------------------------
|
||||
Thu Feb 7 12:41:25 CET 2008 - mkoenig@suse.de
|
||||
|
||||
- update to version 2.13.1:
|
||||
mount:
|
||||
* -L|-U segfault when label or uuid doesn't exist
|
||||
* chain of symlinks to fstab causes use of pointer after free
|
||||
* don't call canonicalize(SPEC) for cifs, smbfs and nfs
|
||||
* improve error message when helper program not present
|
||||
losetup:
|
||||
* fix errno usage
|
||||
mkswap:
|
||||
* possible to crash with SELinux relabeling support
|
||||
sfdisk:
|
||||
* allow partitioning drives of over 2^31 sectors
|
||||
hwclock:
|
||||
* check for ENODEV
|
||||
- mount: fix problem with device canonicalization when using
|
||||
persistent name in fstab but call mount with real bd name
|
||||
- patches merged:
|
||||
util-linux-2.13-mount_fd_leak.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Dec 18 15:55:19 CET 2007 - mkoenig@suse.de
|
||||
|
||||
|
782
util-linux.spec
782
util-linux.spec
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user