swapon_SOURCES = swapon.c swap_constants.h $(utils_common)
-losetup_SOURCES = lomount.c sundries.c xmalloc.c loop.h lomount.h xmalloc.h \
- sundries.h
+losetup_SOURCES = lomount.c sundries.c xmalloc.c realpath.c \
+ loop.h lomount.h xmalloc.h sundries.h realpath.h
losetup_CPPFLAGS = -DMAIN $(AM_CPPFLAGS)
mount_LDADD = $(LDADD_common)
#include "nls.h"
#include "sundries.h"
#include "xmalloc.h"
+#include "realpath.h"
#define SIZE(a) (sizeof(a)/sizeof(a[0]))
struct loop_info64 loopinfo64;
int fd, ffd, mode, i;
char *pass;
+ char *filename;
mode = (*loopro ? O_RDONLY : O_RDWR);
if ((ffd = open(file, mode)) < 0) {
memset(&loopinfo64, 0, sizeof(loopinfo64));
- xstrncpy((char *)loopinfo64.lo_file_name, file, LO_NAME_SIZE);
+ if (!(filename = canonicalize(file)))
+ filename = (char *) file;
+ xstrncpy((char *)loopinfo64.lo_file_name, filename, LO_NAME_SIZE);
if (encryption && *encryption) {
if (digits_only(encryption)) {
close(fd);
close(ffd);
+ if (file != filename)
+ free(filename);
return rc;
}
close (ffd);
if (i) {
ioctl (fd, LOOP_CLR_FD, 0);
close (fd);
+ if (file != filename)
+ free(filename);
return 1;
}
close (fd);
if (verbose > 1)
printf(_("set_loop(%s,%s,%llu): success\n"),
- device, file, offset);
+ device, filename, offset);
+ if (file != filename)
+ free(filename);
return 0;
}