NetBSD Problem Report #48798
From www@NetBSD.org Sat May 10 09:10:18 2014
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
(using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits))
(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
by mollari.NetBSD.org (Postfix) with ESMTPS id 4E167A5850
for <gnats-bugs@gnats.NetBSD.org>; Sat, 10 May 2014 09:10:18 +0000 (UTC)
Message-Id: <20140510091016.D7439A5856@mollari.NetBSD.org>
Date: Sat, 10 May 2014 09:10:16 +0000 (UTC)
From: scdbackup@gmx.net
Reply-To: scdbackup@gmx.net
To: gnats-bugs@NetBSD.org
Subject: /bin/ls -i shows 32 bit rollover with inode numbers
X-Send-Pr-Version: www-1.0
>Number: 48798
>Category: bin
>Synopsis: /bin/ls -i shows 32 bit rollover with inode numbers
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat May 10 09:15:00 +0000 2014
>Closed-Date: Sat May 10 09:40:22 +0000 2014
>Last-Modified: Sat May 10 09:40:22 +0000 2014
>Originator: Thomas Schmitt
>Release: 6.1.3
>Organization:
>Environment:
NetBSD netbsd 6.1.3 NetBSD 6.1.3 (GENERIC) i386
>Description:
After fixing kern/48787, the test image there exposes ino_t values
above (2 exp 32 - 1).
But /bin/ls -li shows only their lowest 32 bits:
netbsd# /bin/ls -li /mnt
total 4
34578432 drwxr-xr-x 1 thomas dbus 2048 May 6 15:30 my
34574670 -rw-r--r-- 1 thomas dbus 6 May 6 15:34 small_file
whereas
struct stat stbuf;
...
printf("sizeof(ino_t) = %d\n", (int) sizeof(ino_t));
...
ret = stat("/mnt/small_file", &stbuf);
...
printf("/mnt/small_file , ino = %.f\n", (double) stbuf.st_ino);
reports
sizeof(ino_t) = 8
/mnt/small_file , ino = 4329541966
>How-To-Repeat:
Inode numbers above the 32 bit limit may be studied with the
test image for kern/48787:
http://scdbackup.webframe.org/large.iso.bz2
Just 4470 bytes, MD5 7d78dc3efaec8ea3f1801335329f410d.
It inflates to 4,329,897,984 bytes. Provided under BSD license.
(This image also exposes a bug with data files larger than 4 GiB - 1.)
After fix of kern/48787, and assumed the ISO is presented as /dev/cd0a
do:
mount -t cd9660 /dev/cd0a /mnt
ls -li /mnt
>Fix:
I found two spots in /usr/src/bin/ls where ino_t is printed by
with conversion specifier "%*lu".
After changing these to "%*llu" and the casts from "(unsigned long)"
to "(unsigned long long)", i get shown by ls the same inode numbers
as by stat(1) and stat(2).
>Release-Note:
>Audit-Trail:
From: "Thomas Schmitt" <scdbackup@gmx.net>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: kern/48798
Date: Sat, 10 May 2014 11:16:27 +0200
--- bin/ls/print.c.orig 2014-02-22 13:11:42.000000000 +0000
+++ bin/ls/print.c 2014-05-10 08:47:43.000000000 +0000
@@ -136,8 +136,8 @@ printlong(DISPLAY *dp)
continue;
sp = p->fts_statp;
if (f_inode)
- (void)printf("%*lu ", dp->s_inode,
- (unsigned long)sp->st_ino);
+ (void)printf("%*llu ", dp->s_inode,
+ (unsigned long long)sp->st_ino);
if (f_size) {
if (f_humanize) {
if ((humanize_number(szbuf, sizeof(szbuf),
@@ -365,7 +365,8 @@ printaname(FTSENT *p, int inodefield, in
sp = p->fts_statp;
chcnt = 0;
if (f_inode)
- chcnt += printf("%*lu ", inodefield, (unsigned long)sp->st_ino);
+ chcnt += printf("%*llu ",
+ inodefield, (unsigned long long)sp->st_ino);
if (f_size) {
if (f_humanize) {
if ((humanize_number(szbuf, sizeof(szbuf), sp->st_size,
From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/48798 CVS commit: src/bin/ls
Date: Sat, 10 May 2014 09:39:19 +0000
Module Name: src
Committed By: martin
Date: Sat May 10 09:39:19 UTC 2014
Modified Files:
src/bin/ls: print.c
Log Message:
PR bin/48798: fix format for ino_t.
Slightly modifed variant of the patch provided by Thomas Schmitt.
To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/bin/ls/print.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->closed
State-Changed-By: martin@NetBSD.org
State-Changed-When: Sat, 10 May 2014 09:40:22 +0000
State-Changed-Why:
Fixed, thanks!
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.