diff options
author | Karel Zak | 2013-07-19 17:05:31 +0200 |
---|---|---|
committer | Karel Zak | 2013-07-19 17:15:44 +0200 |
commit | 01307ecf1b1ec8f72377100d67d757f946c9dace (patch) | |
tree | 48a88a898f604c8db72f2bc19cf13fb95af55a7f /sys-utils/losetup.c | |
parent | mount: update xfs docs (diff) | |
download | kernel-qcow2-util-linux-01307ecf1b1ec8f72377100d67d757f946c9dace.tar.gz kernel-qcow2-util-linux-01307ecf1b1ec8f72377100d67d757f946c9dace.tar.xz kernel-qcow2-util-linux-01307ecf1b1ec8f72377100d67d757f946c9dace.zip |
losetup: set errno for misaligned offsets
References: https://bugs.archlinux.org/task/36189
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/losetup.c')
-rw-r--r-- | sys-utils/losetup.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/sys-utils/losetup.c b/sys-utils/losetup.c index 5dd3c6c3e..1bd1f41a4 100644 --- a/sys-utils/losetup.c +++ b/sys-utils/losetup.c @@ -620,6 +620,8 @@ int main(int argc, char **argv) int hasdev = loopcxt_has_device(&lc); do { + const char *errpre; + /* Note that loopcxt_{find_unused,set_device}() resets * loopcxt struct. */ @@ -641,12 +643,18 @@ int main(int argc, char **argv) res = loopcxt_setup_device(&lc); if (res == 0) break; /* success */ - if (errno != EBUSY) { - warn(_("%s: failed to set up loop device"), - hasdev && loopcxt_get_fd(&lc) < 0 ? - loopcxt_get_device(&lc) : file); - break; - } + if (errno == EBUSY) + continue; + + /* errors */ + errpre = hasdev && loopcxt_get_fd(&lc) < 0 ? + loopcxt_get_device(&lc) : file; + if (errno == ERANGE && offset && offset % 512) + warnx(_("%s: failed to set up loop device, " + "offset is not 512-byte aligned."), errpre); + else + warn(_("%s: failed to set up loop device"), errpre); + break; } while (hasdev == 0); if (res == 0) { |