Mercurial > illumos > illumos-gate
changeset 3945:84f23e74ca15
6540902 fsck seeks incorrectly and possibly overwrites data
author | casper |
---|---|
date | Mon, 02 Apr 2007 02:03:22 -0700 |
parents | 75371f172291 |
children | 0cc6f51aa203 |
files | usr/src/cmd/fs.d/ufs/fsck/utilities.c |
diffstat | 1 files changed, 9 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/cmd/fs.d/ufs/fsck/utilities.c Sun Apr 01 23:38:22 2007 -0700 +++ b/usr/src/cmd/fs.d/ufs/fsck/utilities.c Mon Apr 02 02:03:22 2007 -0700 @@ -1,5 +1,5 @@ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -473,7 +473,7 @@ return (1); } - if (llseek(fd, offset, 0) < 0) { + if (llseek(fd, offset, SEEK_SET) < 0) { rwerror("SEEK", blk, -1); } @@ -481,7 +481,7 @@ return (0); } rwerror("READ", blk, i); - if (llseek(fd, offset, 0) < 0) { + if (llseek(fd, offset, SEEK_SET) < 0) { rwerror("SEEK", blk, -1); } errs = 0; @@ -489,7 +489,7 @@ pwarn("THE FOLLOWING SECTORS COULD NOT BE READ:"); for (cp = buf, i = 0; i < btodb(size); i++, cp += DEV_BSIZE) { addr = ldbtob(blk + i); - if (llseek(fd, addr, SEEK_CUR) < 0 || + if (llseek(fd, addr, SEEK_SET) < 0 || read(fd, cp, (int)secsize) < 0) { iscorrupt = 1; (void) printf(" %llu", blk + (u_longlong_t)i); @@ -518,7 +518,7 @@ (longlong_t)blk, devname); return; } - if (llseek(fd, offset, 0) < 0) { + if (llseek(fd, offset, SEEK_SET) < 0) { rwerror("SEEK", blk, -1); } if ((i = write(fd, buf, (int)size)) == size) { @@ -526,14 +526,14 @@ return; } rwerror("WRITE", blk, i); - if (llseek(fd, offset, 0) < 0) { + if (llseek(fd, offset, SEEK_SET) < 0) { rwerror("SEEK", blk, -1); } pwarn("THE FOLLOWING SECTORS COULD NOT BE WRITTEN:"); for (cp = buf, i = 0; i < btodb(size); i++, cp += DEV_BSIZE) { n = 0; addr = ldbtob(blk + i); - if (llseek(fd, addr, SEEK_CUR) < 0 || + if (llseek(fd, addr, SEEK_SET) < 0 || (n = write(fd, cp, DEV_BSIZE)) < 0) { iscorrupt = 1; (void) printf(" %llu", blk + (u_longlong_t)i); @@ -1315,7 +1315,7 @@ if ((cleanbuf.b_un.b_buf = malloc(size)) == NULL) errexit("out of memory"); - if (llseek(fsreadfd, sblkoff, 0) == -1) { + if (llseek(fsreadfd, sblkoff, SEEK_SET) == -1) { (void) printf("COULD NOT SEEK TO SUPERBLOCK AT %lld: %s\n", (longlong_t)bno, strerror(errno)); goto out; @@ -1333,7 +1333,7 @@ cleanbuf.b_un.b_fs->fs_reclaim = sblock.fs_reclaim; cleanbuf.b_un.b_fs->fs_flags = sblock.fs_flags; - if (llseek(fswritefd, sblkoff, 0) == -1) { + if (llseek(fswritefd, sblkoff, SEEK_SET) == -1) { (void) printf("COULD NOT SEEK TO SUPERBLOCK AT %lld: %s\n", (longlong_t)bno, strerror(errno)); goto out;