From: Philip Homburg Date: Fri, 27 Jan 2006 12:58:09 +0000 (+0000) Subject: Check contents of symbolic links. X-Git-Tag: v3.1.2a~411 X-Git-Url: http://zhaoyanbai.com/repos/?a=commitdiff_plain;h=21c06cfa1fd824065aa13b12c7cac33355f97840;p=minix.git Check contents of symbolic links. --- diff --git a/commands/simple/fsck.c b/commands/simple/fsck.c index 413611a6a..f7e9a1c59 100755 --- a/commands/simple/fsck.c +++ b/commands/simple/fsck.c @@ -198,6 +198,8 @@ _PROTOTYPE(int chkdots, (Ino_t ino, off_t pos, dir_struct *dp, Ino_t exp)); _PROTOTYPE(int chkname, (Ino_t ino, dir_struct *dp)); _PROTOTYPE(int chkentry, (Ino_t ino, off_t pos, dir_struct *dp)); _PROTOTYPE(int chkdirzone, (Ino_t ino, d_inode *ip, off_t pos, zone_nr zno)); +_PROTOTYPE(int chksymlinkzone, (Ino_t ino, d_inode *ip, off_t pos, + zone_nr zno)); _PROTOTYPE(void errzone, (char *mess, zone_nr zno, int level, off_t pos)); _PROTOTYPE(int markzone, (zone_nr zno, int level, off_t pos)); _PROTOTYPE(int chkindzone, (Ino_t ino, d_inode *ip, off_t *pos, zone_nr zno, int level)); @@ -1111,6 +1113,37 @@ zone_nr zno; return(1); } + +int chksymlinkzone(ino, ip, pos, zno) +ino_t ino; +d_inode *ip; +off_t pos; +zone_nr zno; +{ + long offset; + size_t len; + char target[PATH_MAX+1]; + + if (ip->i_size > PATH_MAX) + fatal("chksymlinkzone: fsck program inconsistency\n"); + offset = zaddr(zno); + devread(offset, target, ip->i_size); + target[ip->i_size]= '\0'; + len= strlen(target); + if (len != ip->i_size) + { + printf("bad size in symbolic link (%d instead of %d) ", + ip->i_size, len); + printpath(2, 0); + if (yes(". update")) { + setbit(spec_imap, (bit_nr) ino); + ip->i_size = len; + devwrite(inoaddr(ino), (char *) ip, INODE_SIZE); + } + } + return 1; +} + /* There is something wrong with the given zone. Print some details. */ void errzone(mess, zno, level, pos) char *mess; @@ -1206,6 +1239,9 @@ int level; if ((ip->i_mode & I_TYPE) == I_DIRECTORY && !chkdirzone(ino, ip, *pos, zno)) return(0); + if ((ip->i_mode & I_TYPE) == I_SYMBOLIC_LINK && + !chksymlinkzone(ino, ip, *pos, zno)) + return(0); *pos += ZONE_SIZE; return(1); } else