diff options
author | David Greenman <dg@FreeBSD.org> | 1994-09-09 11:06:27 +0000 |
---|---|---|
committer | David Greenman <dg@FreeBSD.org> | 1994-09-09 11:06:27 +0000 |
commit | 9fef31228956f9a55b5a0925fc8d17f64bad1071 (patch) | |
tree | e0851b00dd84ff861664fa1372a7b37d8932f469 /sbin | |
parent | 8dc01fa8c3b9bbe40e080e233a8f746b396fcb01 (diff) | |
download | src-9fef31228956f9a55b5a0925fc8d17f64bad1071.tar.gz src-9fef31228956f9a55b5a0925fc8d17f64bad1071.zip |
Two fixes from the NetBSD group (Charles Hannum):
1) dir.c: get byte order right in mkentry()
2) pass1.c: When doing -c2 conversion, do secsize reads for a symlink -
not doing so was causing the conversion to fail because the device
driver can't deal with short reads.
Notes
Notes:
svn path=/head/; revision=2603
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/fsck/dir.c | 17 | ||||
-rw-r--r-- | sbin/fsck/pass1.c | 5 | ||||
-rw-r--r-- | sbin/fsck_ffs/dir.c | 17 | ||||
-rw-r--r-- | sbin/fsck_ffs/pass1.c | 5 | ||||
-rw-r--r-- | sbin/fsck_ifs/dir.c | 17 | ||||
-rw-r--r-- | sbin/fsck_ifs/pass1.c | 5 |
6 files changed, 45 insertions, 21 deletions
diff --git a/sbin/fsck/dir.c b/sbin/fsck/dir.c index ee5d095e6c75..77769cc729fa 100644 --- a/sbin/fsck/dir.c +++ b/sbin/fsck/dir.c @@ -328,13 +328,20 @@ mkentry(idesc) dirp->d_reclen = oldlen; dirp = (struct direct *)(((char *)dirp) + oldlen); dirp->d_ino = idesc->id_parent; /* ino to be entered is in id_parent */ - if (newinofmt) + if (newinofmt) { dirp->d_type = typemap[idesc->id_parent]; - else - dirp->d_type = 0; + dirp->d_namlen = newent.d_namlen; + } else { +# if (BYTE_ORDER == LITTLE_ENDIAN) + dirp->d_type = newent.d_namlen; + dirp->d_namlen = 0; +# else + dirp->d_type = 0; + dirp->d_namlen = newent.d_namlen; +# endif + } dirp->d_reclen = newent.d_reclen; - dirp->d_namlen = newent.d_namlen; - bcopy(idesc->id_name, dirp->d_name, (size_t)dirp->d_namlen + 1); + bcopy(idesc->id_name, dirp->d_name, (size_t)newent.d_namlen + 1); return (ALTERED|STOP); } diff --git a/sbin/fsck/pass1.c b/sbin/fsck/pass1.c index a3ab2f9842cd..fc46eb0323e6 100644 --- a/sbin/fsck/pass1.c +++ b/sbin/fsck/pass1.c @@ -95,7 +95,7 @@ checkinode(inumber, idesc) struct zlncnt *zlnp; int ndb, j; mode_t mode; - char symbuf[MAXSYMLINKLEN]; + char *symbuf; dp = getnextinode(inumber); mode = dp->di_mode & IFMT; @@ -141,9 +141,10 @@ checkinode(inumber, idesc) if (doinglevel2 && dp->di_size > 0 && dp->di_size < MAXSYMLINKLEN && dp->di_blocks != 0) { + symbuf = alloca(secsize); if (bread(fsreadfd, symbuf, fsbtodb(&sblock, dp->di_db[0]), - (long)dp->di_size) != 0) + (long)secsize) != 0) errexit("cannot read symlink"); if (debug) { symbuf[dp->di_size] = 0; diff --git a/sbin/fsck_ffs/dir.c b/sbin/fsck_ffs/dir.c index ee5d095e6c75..77769cc729fa 100644 --- a/sbin/fsck_ffs/dir.c +++ b/sbin/fsck_ffs/dir.c @@ -328,13 +328,20 @@ mkentry(idesc) dirp->d_reclen = oldlen; dirp = (struct direct *)(((char *)dirp) + oldlen); dirp->d_ino = idesc->id_parent; /* ino to be entered is in id_parent */ - if (newinofmt) + if (newinofmt) { dirp->d_type = typemap[idesc->id_parent]; - else - dirp->d_type = 0; + dirp->d_namlen = newent.d_namlen; + } else { +# if (BYTE_ORDER == LITTLE_ENDIAN) + dirp->d_type = newent.d_namlen; + dirp->d_namlen = 0; +# else + dirp->d_type = 0; + dirp->d_namlen = newent.d_namlen; +# endif + } dirp->d_reclen = newent.d_reclen; - dirp->d_namlen = newent.d_namlen; - bcopy(idesc->id_name, dirp->d_name, (size_t)dirp->d_namlen + 1); + bcopy(idesc->id_name, dirp->d_name, (size_t)newent.d_namlen + 1); return (ALTERED|STOP); } diff --git a/sbin/fsck_ffs/pass1.c b/sbin/fsck_ffs/pass1.c index a3ab2f9842cd..fc46eb0323e6 100644 --- a/sbin/fsck_ffs/pass1.c +++ b/sbin/fsck_ffs/pass1.c @@ -95,7 +95,7 @@ checkinode(inumber, idesc) struct zlncnt *zlnp; int ndb, j; mode_t mode; - char symbuf[MAXSYMLINKLEN]; + char *symbuf; dp = getnextinode(inumber); mode = dp->di_mode & IFMT; @@ -141,9 +141,10 @@ checkinode(inumber, idesc) if (doinglevel2 && dp->di_size > 0 && dp->di_size < MAXSYMLINKLEN && dp->di_blocks != 0) { + symbuf = alloca(secsize); if (bread(fsreadfd, symbuf, fsbtodb(&sblock, dp->di_db[0]), - (long)dp->di_size) != 0) + (long)secsize) != 0) errexit("cannot read symlink"); if (debug) { symbuf[dp->di_size] = 0; diff --git a/sbin/fsck_ifs/dir.c b/sbin/fsck_ifs/dir.c index ee5d095e6c75..77769cc729fa 100644 --- a/sbin/fsck_ifs/dir.c +++ b/sbin/fsck_ifs/dir.c @@ -328,13 +328,20 @@ mkentry(idesc) dirp->d_reclen = oldlen; dirp = (struct direct *)(((char *)dirp) + oldlen); dirp->d_ino = idesc->id_parent; /* ino to be entered is in id_parent */ - if (newinofmt) + if (newinofmt) { dirp->d_type = typemap[idesc->id_parent]; - else - dirp->d_type = 0; + dirp->d_namlen = newent.d_namlen; + } else { +# if (BYTE_ORDER == LITTLE_ENDIAN) + dirp->d_type = newent.d_namlen; + dirp->d_namlen = 0; +# else + dirp->d_type = 0; + dirp->d_namlen = newent.d_namlen; +# endif + } dirp->d_reclen = newent.d_reclen; - dirp->d_namlen = newent.d_namlen; - bcopy(idesc->id_name, dirp->d_name, (size_t)dirp->d_namlen + 1); + bcopy(idesc->id_name, dirp->d_name, (size_t)newent.d_namlen + 1); return (ALTERED|STOP); } diff --git a/sbin/fsck_ifs/pass1.c b/sbin/fsck_ifs/pass1.c index a3ab2f9842cd..fc46eb0323e6 100644 --- a/sbin/fsck_ifs/pass1.c +++ b/sbin/fsck_ifs/pass1.c @@ -95,7 +95,7 @@ checkinode(inumber, idesc) struct zlncnt *zlnp; int ndb, j; mode_t mode; - char symbuf[MAXSYMLINKLEN]; + char *symbuf; dp = getnextinode(inumber); mode = dp->di_mode & IFMT; @@ -141,9 +141,10 @@ checkinode(inumber, idesc) if (doinglevel2 && dp->di_size > 0 && dp->di_size < MAXSYMLINKLEN && dp->di_blocks != 0) { + symbuf = alloca(secsize); if (bread(fsreadfd, symbuf, fsbtodb(&sblock, dp->di_db[0]), - (long)dp->di_size) != 0) + (long)secsize) != 0) errexit("cannot read symlink"); if (debug) { symbuf[dp->di_size] = 0; |