Try to make indent formatting less horrible
[oweals/busybox.git] / libbb / loop.c
index 36b13d6e6d468bf93c2d34e5d323b394a43a4e27..7dba3e274b85ee19edce518d3f6dfc676a317b9b 100644 (file)
@@ -2,7 +2,7 @@
 /*
  * Utility routines.
  *
- * Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
+ * Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -33,11 +33,12 @@ extern int del_loop(const char *device)
        int fd;
 
        if ((fd = open(device, O_RDONLY)) < 0) {
-               perror_msg("%s", device);
+               bb_perror_msg("%s", device);
                return (FALSE);
        }
        if (ioctl(fd, LOOP_CLR_FD, 0) < 0) {
-               perror_msg("ioctl: LOOP_CLR_FD");
+               close(fd);
+               bb_perror_msg("ioctl: LOOP_CLR_FD");
                return (FALSE);
        }
        close(fd);
@@ -53,12 +54,12 @@ extern int set_loop(const char *device, const char *file, int offset,
        mode = *loopro ? O_RDONLY : O_RDWR;
        if ((ffd = open(file, mode)) < 0 && !*loopro
                && (errno != EROFS || (ffd = open(file, mode = O_RDONLY)) < 0)) {
-               perror_msg("%s", file);
+               bb_perror_msg("%s", file);
                return 1;
        }
        if ((fd = open(device, mode)) < 0) {
                close(ffd);
-               perror_msg("%s", device);
+               bb_perror_msg("%s", device);
                return 1;
        }
        *loopro = (mode == O_RDONLY);
@@ -70,14 +71,14 @@ extern int set_loop(const char *device, const char *file, int offset,
 
        loopinfo.lo_encrypt_key_size = 0;
        if (ioctl(fd, LOOP_SET_FD, ffd) < 0) {
-               perror_msg("ioctl: LOOP_SET_FD");
+               bb_perror_msg("ioctl: LOOP_SET_FD");
                close(fd);
                close(ffd);
                return 1;
        }
        if (ioctl(fd, LOOP_SET_STATUS, &loopinfo) < 0) {
                (void) ioctl(fd, LOOP_CLR_FD, 0);
-               perror_msg("ioctl: LOOP_SET_STATUS");
+               bb_perror_msg("ioctl: LOOP_SET_STATUS");
                close(fd);
                close(ffd);
                return 1;
@@ -95,7 +96,7 @@ extern char *find_unused_loop_device(void)
        struct loop_info loopinfo;
 
        for (i = 0; i <= 7; i++) {
-               sprintf(dev, "/dev/loop%d", i);
+               sprintf(dev, LOOP_FORMAT, i);
                if (stat(dev, &statbuf) == 0 && S_ISBLK(statbuf.st_mode)) {
                        if ((fd = open(dev, O_RDONLY)) >= 0) {
                                if (ioctl(fd, LOOP_GET_STATUS, &loopinfo) != 0) {