3
0
forked from pool/util-linux
util-linux/util-linux-2.13.1-canonicalize_loopfile_name.patch

97 lines
2.6 KiB
Diff

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)