sbin_PROGRAMS = losetup swapon
dist_man_MANS = fstab.5 mount.8 swapoff.8 swapon.8 umount.8 losetup.8
-# generic sources for all programs (mount, umount, losetup)
+# generic sources for all programs (mount, umount)
srcs_common = sundries.c $(top_srcdir)/lib/canonicalize.c sundries.h
# generic header for mount and umount
$(top_srcdir)/lib/loopdev.c \
$(top_srcdir)/lib/strutils.c
-# generic flags for all programs (except losetup)
+# generic flags for all programs
# -- note that pkg-config autoconf macros (pkg.m4) does not differentiate
# between CFLAGS and CPPFLAGS, we follow this behaviour and use CFLAGS only.
ldadd_common = $(ul_libblkid_la)
swapon_CFLAGS = $(cflags_common)
swapon_LDADD = $(ldadd_common)
-losetup_SOURCES = lomount.c $(srcs_common) loop.h lomount.h \
+losetup_SOURCES = lomount.c \
+ $(top_srcdir)/lib/canonicalize.c \
$(top_srcdir)/lib/strutils.c
mount_static_LDADD =
#include "strutils.h"
#include "nls.h"
-#include "sundries.h"
#include "pathnames.h"
#include "loopdev.h"
+#include "xalloc.h"
+#include "canonicalize.h"
+
+static int verbose;
static int is_associated(int dev, struct stat *file, unsigned long long offset, int isoff);
}
if (looplist_open(&ll, LLFLG_USEDONLY) == -1) {
- error(_("%s: /dev directory does not exist."), progname);
+ warnx(_("/dev directory does not exist."));
return 1;
}
int fd;
if (looplist_open(&ll, LLFLG_USEDONLY) == -1) {
- error(_("%s: /dev directory does not exist."), progname);
+ warnx(_("/dev directory does not exist."));
return 1;
}
looplist_close(&ll);
if (!ll.ct_succ && ll.ct_perm) {
- error(_("%s: no permission to look at /dev/loop%s<N>"), progname,
+ warnx(_("no permission to look at /dev/loop%s<N>"),
(ll.flag & LLFLG_SUBDIR) ? "/" : "");
return 1;
}
}
if (looplist_open(&ll, LLFLG_USEDONLY) == -1) {
- error(_("%s: /dev directory does not exist."), progname);
+ warnx(_("/dev directory does not exist."));
return 1;
}
}
if (looplist_open(&ll, LLFLG_USEDONLY) == -1) {
- error(_("%s: /dev directory does not exist."), progname);
+ warnx(_("/dev directory does not exist."));
return NULL;
}
int fd;
if (looplist_open(&ll, LLFLG_FREEONLY) == -1) {
- error(_("%s: /dev directory does not exist."), progname);
+ warnx(_("/dev directory does not exist."));
return NULL;
}
return devname;
if (!ll.ct_succ && ll.ct_perm)
- error(_("%s: no permission to look at /dev/loop%s<N>"), progname,
+ warnx(_("no permission to look at /dev/loop%s<N>"),
(ll.flag & LLFLG_SUBDIR) ? "/" : "");
else if (ll.ct_succ)
- error(_("%s: could not find any free loop device"), progname);
+ warnx(_("could not find any free loop device"));
else
- error(_(
- "%s: Could not find any loop device. Maybe this kernel "
+ warnx(_(
+ "Could not find any loop device. Maybe this kernel "
"does not know\n"
" about the loop device? (If so, recompile or "
- "`modprobe loop'.)"), progname);
+ "`modprobe loop'.)"));
return NULL;
}
pass = realloc(tmppass, buflen);
if (pass == NULL) {
/* realloc failed. Stop reading. */
- error(_("Out of memory while reading passphrase"));
+ warn(_("Out of memory while reading passphrase"));
pass = tmppass; /* the old buffer hasn't changed */
break;
}
}
memset(&loopinfo64, 0, sizeof(loopinfo64));
- if (!(filename = canonicalize(file)))
+ if (!(filename = canonicalize_path(file)))
filename = (char *) file;
xstrncpy((char *)loopinfo64.lo_file_name, filename, LO_NAME_SIZE);
int ok = 0;
if (looplist_open(&ll, LLFLG_USEDONLY) == -1) {
- error(_("%s: /dev directory does not exist."), progname);
+ warnx(_("/dev directory does not exist."));
return 1;
}
looplist_close(&ll);
if (!ll.ct_succ && ll.ct_perm) {
- error(_("%s: no permission to look at /dev/loop%s<N>"), progname,
+ warnx(_("no permission to look at /dev/loop%s<N>"),
(ll.flag & LLFLG_SUBDIR) ? "/" : "");
return 1;
}
" %1$s -c | --set-capacity <loopdev> resize\n"
" %1$s -j | --associated <file> [-o <num>] list all associated with <file>\n"
" %1$s [options] {-f|--find|loopdev} <file> setup\n"),
- progname);
+ program_invocation_short_name);
fputs(_("\nOptions:\n"), out);
fputs(_(" -e, --encryption <type> enable data encryption with specified <name/num>\n"
capacity = delete = delete_all = find = all = 0;
assoc = offset = sizelimit = encryption = passfd = NULL;
- progname = argv[0];
- if ((p = strrchr(progname, '/')) != NULL)
- progname = p+1;
-
while ((c = getopt_long(argc, argv, "acdDe:E:fhj:o:p:rsv",
longopts, NULL)) != -1) {
switch (c) {
}
if (offset && strtosize(offset, &off)) {
- error(_("%s: invalid offset '%s' specified"), progname, offset);
+ warnx(_("invalid offset '%s' specified"), offset);
usage(stderr);
}
if (sizelimit && strtosize(sizelimit, &slimit)) {
- error(_("%s: invalid sizelimit '%s' specified"),
- progname, sizelimit);
+ warnx(_("invalid sizelimit '%s' specified"), sizelimit);
usage(stderr);
}
if (device) {
if (res == 2)
- error(_("%s: %s: device is busy"), progname, device);
+ warnx(_("%s: device is busy"), device);
else if (res == 0) {
if (verbose)
printf(_("Loop device is %s\n"), device);