]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
losetup: cleanup headers, cmdline checks
authorKarel Zak <kzak@redhat.com>
Thu, 22 Dec 2011 11:18:43 +0000 (12:18 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 22 Dec 2011 11:20:07 +0000 (12:20 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/losetup.c

index 32fcc474fe2df1e1fc0a3786ea41d7e0540ca278..35c1c919d58a9fb5202143979b845578c7065ea8 100644 (file)
@@ -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) {