summaryrefslogtreecommitdiffstats
path: root/sys-utils/losetup.c
diff options
context:
space:
mode:
authorKarel Zak2011-12-22 12:18:43 +0100
committerKarel Zak2011-12-22 12:20:07 +0100
commit934df30dd0af1a0cc01dab690aca566bfc5f0e7a (patch)
tree8dc88bc96bf85f3c21ccab69e17ae4060ef15546 /sys-utils/losetup.c
parentlosetup: cleanup man page (diff)
downloadkernel-qcow2-util-linux-934df30dd0af1a0cc01dab690aca566bfc5f0e7a.tar.gz
kernel-qcow2-util-linux-934df30dd0af1a0cc01dab690aca566bfc5f0e7a.tar.xz
kernel-qcow2-util-linux-934df30dd0af1a0cc01dab690aca566bfc5f0e7a.zip
losetup: cleanup headers, cmdline checks
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/losetup.c')
-rw-r--r--sys-utils/losetup.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/sys-utils/losetup.c b/sys-utils/losetup.c
index 32fcc474f..35c1c919d 100644
--- a/sys-utils/losetup.c
+++ b/sys-utils/losetup.c
@@ -6,26 +6,18 @@
*/
#include <stdio.h>
#include <string.h>
-#include <ctype.h>
-#include <fcntl.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
-#include <sys/mman.h>
-#include <sys/sysmacros.h>
#include <inttypes.h>
-#include <dirent.h>
#include <getopt.h>
-#include <stdarg.h>
-#include "strutils.h"
+#include "c.h"
#include "nls.h"
-#include "pathnames.h"
+#include "strutils.h"
#include "loopdev.h"
-#include "xalloc.h"
-#include "canonicalize.h"
enum {
A_CREATE = 1, /* setup a new device */
@@ -373,7 +365,8 @@ int main(int argc, char **argv)
_("the options %s are allowed to loop device setup only"),
"--{encryption,sizelimit,pass-fd,read-only,show}");
- if (act != A_CREATE && act != A_SHOW && (flags & LOOPDEV_FL_OFFSET))
+ if ((flags & LOOPDEV_FL_OFFSET) &&
+ act != A_CREATE && (act != A_SHOW || !file))
errx(EXIT_FAILURE, _("the option --offset is not allowed in this context."));
switch (act) {