X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=lib%2Futils_loop.c;h=d7b03a136b152bf5b3b4ae41d43913027b96d850;hb=a3777a6b2cde2c7133141474dd4c428220a3e9cc;hp=d0f185b6c97e6db10914857c92421ed1317ecd6c;hpb=ee8425b8365532217c5aa132a5d80eae1d3881df;p=platform%2Fupstream%2Fcryptsetup.git diff --git a/lib/utils_loop.c b/lib/utils_loop.c index d0f185b..d7b03a1 100644 --- a/lib/utils_loop.c +++ b/lib/utils_loop.c @@ -2,10 +2,12 @@ * loopback block device utilities * * Copyright (C) 2011-2012, Red Hat, Inc. All rights reserved. + * Copyright (C) 2009-2012, Milan Broz * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,6 +27,7 @@ #include #include #include +#include #include #include "utils_loop.h" @@ -43,13 +46,10 @@ static char *crypt_loop_get_device_old(void) { char dev[20]; int i, loop_fd; - struct stat st; struct loop_info64 lo64 = {0}; for (i = 0; i < 256; i++) { sprintf(dev, "/dev/loop%d", i); - if (stat(dev, &st) || !S_ISBLK(st.st_mode)) - return NULL; loop_fd = open(dev, O_RDONLY); if (loop_fd < 0) @@ -99,7 +99,7 @@ int crypt_loop_attach(const char *loop, const char *file, int offset, int loop_fd = -1, file_fd = -1, r = 1; file_fd = open(file, (*readonly ? O_RDONLY : O_RDWR) | O_EXCL); - if (file_fd < 0 && errno == EROFS && !*readonly) { + if (file_fd < 0 && (errno == EROFS || errno == EACCES) && !*readonly) { *readonly = 1; file_fd = open(file, O_RDONLY | O_EXCL); }