From owner-freebsd-current@FreeBSD.ORG Fri Jul 8 22:15:29 2005 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 65F3A16A41C for ; Fri, 8 Jul 2005 22:15:29 +0000 (GMT) (envelope-from cracauer@schlepper.zs64.net) Received: from schlepper.zs64.net (schlepper.zs64.net [212.12.50.230]) by mx1.FreeBSD.org (Postfix) with ESMTP id D259843D4C for ; Fri, 8 Jul 2005 22:15:28 +0000 (GMT) (envelope-from cracauer@schlepper.zs64.net) Received: from schlepper.zs64.net (schlepper [212.12.50.230]) by schlepper.zs64.net (8.13.1/8.12.9) with ESMTP id j68MFR91054831 for ; Sat, 9 Jul 2005 00:15:27 +0200 (CEST) (envelope-from cracauer@schlepper.zs64.net) Received: (from cracauer@localhost) by schlepper.zs64.net (8.13.1/8.12.9/Submit) id j68MFRri054829 for freebsd-current@freebsd.org; Fri, 8 Jul 2005 18:15:27 -0400 (EDT) (envelope-from cracauer) Date: Fri, 8 Jul 2005 18:15:27 -0400 From: Martin Cracauer To: freebsd-current@freebsd.org Message-ID: <20050708181514.A54677@cons.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Yylu36WmvOXNoKYn" Content-Disposition: inline User-Agent: Mutt/1.2.5i Subject: Repairing ext2fs stat(2), fts(3) in 6.0-current, please test on 5.x X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jul 2005 22:15:29 -0000 --Yylu36WmvOXNoKYn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline ext2fs fails to set the device in the stat(2) system call. Subsequently, that makes fts(3) fail, which goes as far as make ls(1) fail (which uses fts). The appended diff fixes it for me and looks correct to me. Unless somebody objects I will submit it to re@ for commit approval. %% I don't have a 5.x system anywhere, can somebody please test whether the problem exists in 5.x? Here is how: - compile appended test program - mount an ext2fs to -say- /mnt/tmp - `./stattests /mnt/tmp` ==> must return identical device ids Quicker test: - mount ext2fs to /mnt/tmp - `ls -F /mnt/tmp` ==> will fail with file not found errors. Martin -- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Martin Cracauer http://www.cons.org/cracauer/ No warranty. This email is probably produced by one of my cats stepping on the keys. No, I don't have an infinite number of cats. --Yylu36WmvOXNoKYn Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="diff.ext2fs" Index: ext2_vnops.c =================================================================== RCS file: /lhome/CVS-FreeBSD/src/sys/gnu/fs/ext2fs/ext2_vnops.c,v retrieving revision 1.102 diff -u -r1.102 ext2_vnops.c --- ext2_vnops.c 15 Jun 2005 02:36:11 -0000 1.102 +++ ext2_vnops.c 8 Jul 2005 22:07:16 -0000 @@ -346,6 +346,7 @@ /* * Copy from inode table */ + vap->va_fsid = dev2udev(ip->i_devvp->v_rdev); vap->va_fileid = ip->i_number; vap->va_mode = ip->i_mode & ~IFMT; vap->va_nlink = ip->i_nlink; --Yylu36WmvOXNoKYn Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="stattests.c" #include #include #include #include #include #include #include static void print(const char *const msg, const struct stat *const s) { fprintf(stderr, "dev %s: %X (%d/%d)\n", msg, s->st_dev , major(s->st_dev) , minor(s->st_dev)); } int main(int argc, char *argv[]) { struct stat s; struct stat s_direct; int fd; char *filename1 = NULL; if (argc < 2) { fprintf(stderr, "Usage: filename\n"); exit(1); } filename1 = argv[1]; if (stat(filename1, &s_direct) == -1) { perror("stat"); exit(2); } print("just stat", &s_direct); fd = open(filename1, O_RDONLY); if (fd == -1) { perror("open"); exit(2); } if (fstat(fd, &s) == -1) { perror("fstat"); exit(2); } print("using fstat", &s); #if 0 DIR *dir; dir = opendir(filename1); if (dir == NULL) { perror("opendir"); exit(2); } if (fstat(dirfd(dir), &s) == -1) { perror("fstat"); exit(2); } fprintf(stderr, "dev: %d\n", s.st_dev); if (stat("/mnt/tmp/X11", &s) == -1) { perror("stat"); exit(2); } fprintf(stderr, "dev: %d\n", s.st_dev); #endif return 0; } --Yylu36WmvOXNoKYn--