From owner-freebsd-bugs@FreeBSD.ORG Thu Jun 19 14:20:17 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5B2F237B407 for ; Thu, 19 Jun 2003 14:20:17 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 01FFF43FBD for ; Thu, 19 Jun 2003 14:20:14 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h5JLKEUp023434 for ; Thu, 19 Jun 2003 14:20:14 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h5JLKEo7023433; Thu, 19 Jun 2003 14:20:14 -0700 (PDT) Resent-Date: Thu, 19 Jun 2003 14:20:14 -0700 (PDT) Resent-Message-Id: <200306192120.h5JLKEo7023433@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Lukas Ertl 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 To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/53515: [PATCH] libufs/getino() calculates inode offset wrong X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Lukas Ertl List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Jun 2003 21:20:17 -0000 >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: