aboutsummaryrefslogtreecommitdiff
path: root/util-linux/volume_id/util.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-10-12 11:17:49 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-10-12 11:17:49 +0000
commitd5e305944a9db25f57b252cc9f56c18311e68481 (patch)
tree5f76ea7623209d379a9ea34bfa943ef86af2032a /util-linux/volume_id/util.c
parentcdd1f732bc5b8447dd12b59613663b7d08fce20b (diff)
downloadbusybox-w32-d5e305944a9db25f57b252cc9f56c18311e68481.tar.gz
busybox-w32-d5e305944a9db25f57b252cc9f56c18311e68481.tar.bz2
busybox-w32-d5e305944a9db25f57b252cc9f56c18311e68481.zip
findfs: fix LUKS and FAT detection routines; do not exit if corrupted
FAT fs makes us try to seek past volume function old new delta volume_id_get_buffer 301 327 +26 volume_id_probe_luks 79 82 +3 get_attr_volume_id 73 65 -8 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/1 up/down: 29/-8) Total: 21 bytes
Diffstat (limited to 'util-linux/volume_id/util.c')
-rw-r--r--util-linux/volume_id/util.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/util-linux/volume_id/util.c b/util-linux/volume_id/util.c
index 315d75ca6..c4d20ba47 100644
--- a/util-linux/volume_id/util.c
+++ b/util-linux/volume_id/util.c
@@ -181,7 +181,7 @@ set:
181 buf[4], buf[5], 181 buf[4], buf[5],
182 buf[6], buf[7], 182 buf[6], buf[7],
183 buf[8], buf[9], 183 buf[8], buf[9],
184 buf[10], buf[11], buf[12], buf[13], buf[14],buf[15]); 184 buf[10], buf[11], buf[12], buf[13], buf[14], buf[15]);
185 break; 185 break;
186 case UUID_DCE_STRING: 186 case UUID_DCE_STRING:
187 memcpy(id->uuid, buf, count); 187 memcpy(id->uuid, buf, count);
@@ -190,6 +190,9 @@ set:
190 } 190 }
191} 191}
192 192
193/* Do not use xlseek here. With it, single corrupted filesystem
194 * may result in attempt to seek past device -> exit.
195 * It's better to ignore such fs and continue. */
193void *volume_id_get_buffer(struct volume_id *id, uint64_t off, size_t len) 196void *volume_id_get_buffer(struct volume_id *id, uint64_t off, size_t len)
194{ 197{
195 ssize_t buf_len; 198 ssize_t buf_len;
@@ -204,7 +207,10 @@ void *volume_id_get_buffer(struct volume_id *id, uint64_t off, size_t len)
204 /* check if we need to read */ 207 /* check if we need to read */
205 if ((off + len) > id->sbbuf_len) { 208 if ((off + len) > id->sbbuf_len) {
206 dbg("read sbbuf len:0x%llx", (unsigned long long) (off + len)); 209 dbg("read sbbuf len:0x%llx", (unsigned long long) (off + len));
207 xlseek(id->fd, 0, SEEK_SET); 210 if (lseek(id->fd, 0, SEEK_SET) != 0) {
211 dbg("seek(0) failed");
212 return NULL;
213 }
208 buf_len = full_read(id->fd, id->sbbuf, off + len); 214 buf_len = full_read(id->fd, id->sbbuf, off + len);
209 if (buf_len < 0) { 215 if (buf_len < 0) {
210 dbg("read failed (%s)", strerror(errno)); 216 dbg("read failed (%s)", strerror(errno));
@@ -234,7 +240,10 @@ void *volume_id_get_buffer(struct volume_id *id, uint64_t off, size_t len)
234 /* check if we need to read */ 240 /* check if we need to read */
235 if ((off < id->seekbuf_off) || ((off + len) > (id->seekbuf_off + id->seekbuf_len))) { 241 if ((off < id->seekbuf_off) || ((off + len) > (id->seekbuf_off + id->seekbuf_len))) {
236 dbg("read seekbuf off:0x%llx len:0x%zx", (unsigned long long) off, len); 242 dbg("read seekbuf off:0x%llx len:0x%zx", (unsigned long long) off, len);
237 xlseek(id->fd, off, SEEK_SET); 243 if (lseek(id->fd, off, SEEK_SET) != off) {
244 dbg("seek(0x%llx) failed", (unsigned long long) off);
245 return NULL;
246 }
238 buf_len = full_read(id->fd, id->seekbuf, len); 247 buf_len = full_read(id->fd, id->seekbuf, len);
239 if (buf_len < 0) { 248 if (buf_len < 0) {
240 dbg("read failed (%s)", strerror(errno)); 249 dbg("read failed (%s)", strerror(errno));