aboutsummaryrefslogtreecommitdiff
path: root/libbb/loop.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/loop.c')
-rw-r--r--libbb/loop.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/libbb/loop.c b/libbb/loop.c
index 9559d429a..6934b7a3b 100644
--- a/libbb/loop.c
+++ b/libbb/loop.c
@@ -81,7 +81,8 @@ int del_loop(const char *device)
81 */ 81 */
82int set_loop(char **device, const char *file, unsigned long long offset) 82int set_loop(char **device, const char *file, unsigned long long offset)
83{ 83{
84 char dev[20], *try; 84 char dev[LOOP_NAMESIZE];
85 char *try;
85 bb_loop_info loopinfo; 86 bb_loop_info loopinfo;
86 struct stat statbuf; 87 struct stat statbuf;
87 int i, dfd, ffd, mode, rc = -1; 88 int i, dfd, ffd, mode, rc = -1;
@@ -140,14 +141,14 @@ int set_loop(char **device, const char *file, unsigned long long offset)
140 rc = -1; 141 rc = -1;
141 } 142 }
142 close(dfd); 143 close(dfd);
143try_again: 144 try_again:
144 if (*device) break; 145 if (*device) break;
145 } 146 }
146 close(ffd); 147 close(ffd);
147 if (!rc) { 148 if (!rc) {
148 if (!*device) 149 if (!*device)
149 *device = xstrdup(dev); 150 *device = xstrdup(dev);
150 return (mode == O_RDONLY) ? 1 : 0; 151 return (mode == O_RDONLY); /* 1:ro, 0:rw */
151 } 152 }
152 return rc; 153 return rc;
153} 154}