Date: Thu, 19 Jun 2003 23:10:11 +0200 (CEST) From: Lukas Ertl <l.ertl@univie.ac.at> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/53515: [PATCH] libufs/getino() calculates inode offset wrong Message-ID: <200306192110.h5JLABde057784@leelou.in.tern> Resent-Message-ID: <200306192120.h5JLKEo7023433@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 53515 >Category: bin >Synopsis: [PATCH] libufs/getino() calculates inode offset wrong >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Jun 19 14:20:14 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Lukas Ertl >Release: FreeBSD 5.1-CURRENT i386 >Organization: Vienna University Computer Center >Environment: System: FreeBSD leelou 5.1-CURRENT FreeBSD 5.1-CURRENT #0: Mon Jun 16 13:00:21 CEST 2003 le@leelou:/usr/obj/usr/src/sys/LEELOU i386 >Description: I just spent a couple of hours debugging an app that uses libufs/getino() until I recognized that the bug was not in the app but in libufs. The problem arises as soon as you're trying to get inode number 128 (UFS1) or 64 (UFS2). >How-To-Repeat: Use getino() from libufs and try to get inode 128 from an UFS1 fs or inode 64 from an UFS2 fs. >Fix: I looked at the dump(8) sources which has a function getino() in src/sbin/dump/traverse.c. getino() from libufs is almost a verbatim copy of that function, but has a typo: '&' instead of '%'. --- inode.c.diff begins here --- Index: lib/libufs/inode.c =================================================================== RCS file: /hugo/bsdcvs/src/lib/libufs/inode.c,v retrieving revision 1.5 diff -u -r1.5 inode.c --- lib/libufs/inode.c 9 Jun 2003 09:32:29 -0000 1.5 +++ lib/libufs/inode.c 19 Jun 2003 20:54:28 -0000 @@ -74,7 +74,7 @@ goto gotit; bread(disk, fsbtodb(fs, ino_to_fsba(fs, inode)), inoblock, fs->fs_bsize); - disk->d_inomin = min = inode - (inode & INOPB(fs)); + disk->d_inomin = min = inode - (inode % INOPB(fs)); disk->d_inomax = max = min + INOPB(fs); gotit: switch (disk->d_ufs) { case 1: --- inode.c.diff ends here --- >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200306192110.h5JLABde057784>