From le@univie.ac.at Thu Jun 19 14:10:26 2003 Return-Path: Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 58F6037B401 for ; Thu, 19 Jun 2003 14:10:26 -0700 (PDT) Received: from mailbox.univie.ac.at (mail.univie.ac.at [131.130.1.27]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0CCDB43F75 for ; Thu, 19 Jun 2003 14:10:25 -0700 (PDT) (envelope-from le@univie.ac.at) Received: from leelou.in.tern (adslle.cc.univie.ac.at [131.130.102.11]) by mailbox.univie.ac.at (8.12.2/8.12.2) with ESMTP id h5JLACM7110642 for ; Thu, 19 Jun 2003 23:10:15 +0200 Received: from leelou.in.tern (leelou [127.0.0.1]) by leelou.in.tern (8.12.9/8.12.9) with ESMTP id h5JLACuT057785 for ; Thu, 19 Jun 2003 23:10:12 +0200 (CEST) (envelope-from le@leelou.in.tern) Received: (from le@localhost) by leelou.in.tern (8.12.9/8.12.9/Submit) id h5JLABde057784; Thu, 19 Jun 2003 23:10:11 +0200 (CEST) (envelope-from le) Message-Id: <200306192110.h5JLABde057784@leelou.in.tern> Date: Thu, 19 Jun 2003 23:10:11 +0200 (CEST) From: Lukas Ertl Reply-To: Lukas Ertl To: FreeBSD-gnats-submit@freebsd.org Cc: Subject: [PATCH] libufs/getino() calculates inode offset wrong X-Send-Pr-Version: 3.113 X-GNATS-Notify: >Number: 53515 >Category: bin >Synopsis: [PATCH] libufs/getino() calculates inode offset wrong >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: closed >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Jun 19 14:20:14 PDT 2003 >Closed-Date: Thu Jun 19 15:13:44 PDT 2003 >Last-Modified: Thu Jun 19 15:13:44 PDT 2003 >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: State-Changed-From-To: open->closed State-Changed-By: mdodd State-Changed-When: Thu Jun 19 15:13:11 PDT 2003 State-Changed-Why: Committed innode.c:1.6 , thanks. http://www.freebsd.org/cgi/query-pr.cgi?pr=53515 >Unformatted: