Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/libbb/loop.c


Ignore:
Timestamp:
Dec 20, 2016, 4:07:32 PM (7 years ago)
Author:
Bruno Cornec
Message:

New 3?3 banch for incorporation of latest busybox 1.25. Changing minor version to handle potential incompatibilities.

Location:
branches/3.3
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/3.3/mindi-busybox/libbb/loop.c

    r3232 r3621  
    9595    /* Open the file.  Barf if this doesn't work.  */
    9696    mode = ro ? O_RDONLY : O_RDWR;
     97 open_ffd:
    9798    ffd = open(file, mode);
    9899    if (ffd < 0) {
    99100        if (mode != O_RDONLY) {
    100101            mode = O_RDONLY;
    101             ffd = open(file, mode);
     102            goto open_ffd;
    102103        }
    103         if (ffd < 0)
    104             return -errno;
     104        return -errno;
    105105    }
    106106
    107107    /* Find a loop device.  */
    108108    try = *device ? *device : dev;
    109     /* 1048575 is a max possible minor number in Linux circa 2010 */
     109    /* 1048575 (0xfffff) is a max possible minor number in Linux circa 2010 */
    110110    for (i = 0; rc && i < 1048576; i++) {
    111111        sprintf(dev, LOOP_FORMAT, i);
     
    122122            }
    123123            /* Ran out of block devices, return failure.  */
    124             rc = -ENOENT;
     124            rc = -1;
    125125            break;
    126126        }
     
    132132            dfd = open(try, mode);
    133133        }
    134         if (dfd < 0)
     134        if (dfd < 0) {
     135            if (errno == ENXIO) {
     136                /* Happens if loop module is not loaded */
     137                rc = -1;
     138                break;
     139            }
    135140            goto try_again;
     141        }
    136142
    137143        rc = ioctl(dfd, BB_LOOP_GET_STATUS, &loopinfo);
     
    149155                    ioctl(dfd, LOOP_CLR_FD, 0);
    150156            }
    151 
    152         /* If this block device already set up right, re-use it.
    153          * (Yes this is racy, but associating two loop devices with the same
    154          * file isn't pretty either.  In general, mounting the same file twice
    155          * without using losetup manually is problematic.)
    156          */
    157         } else
    158         if (strcmp(file, (char *)loopinfo.lo_file_name) != 0
    159          || offset != loopinfo.lo_offset
    160         ) {
     157        } else {
    161158            rc = -1;
    162159        }
Note: See TracChangeset for help on using the changeset viewer.