From drahn@prairieinet.net Thu Nov 15 17:45:36 2001 Date: Thu, 15 Nov 2001 16:37:51 -0600 From: Dale Rahn To: Robert Watson Subject: Re: Posse: EA integration into OpenBSD progress, Part II On Thu, Nov 15, 2001 at 05:33:09PM -0500, Robert Watson wrote: > > If this was a but in the FreeBSD initattr code, I'd be happy to integrate > it back in. Please send me a patch and I'll do so. Keeping the code as > close as possible would probably be beneficial. > The problem is that the write actually writes more than was allocated and zeroed. This occurs because the attribute size is allocated and cleared but the size written is the attribute size and the attribute header. By changing the allocation and clearing to be the sum "chunksize", it now works correctly. BTW, It seems like a bad idea to have an 8192 byte attribute area per inode (how I noticed this first). Something about using up all of the space on the disk ;-) Index: extattrctl.c =================================================================== RCS file: /proj/freebsd/src/usr.sbin/extattrctl/extattrctl.c,v retrieving revision 1.13 diff -u -r1.13 extattrctl.c --- extattrctl.c 19 Mar 2001 06:00:41 -0000 1.13 +++ extattrctl.c 15 Nov 2001 22:34:12 -0000 @@ -122,16 +122,16 @@ if (write(i, &uef, sizeof(uef)) == -1) error = -1; else if (fs_path) { - zero_buf = (char *) (malloc(uef.uef_size)); + chunksize = sizeof(struct ufs_extattr_header) + + uef.uef_size; + zero_buf = (char *) (malloc(chunksize)); if (zero_buf == NULL) { perror("malloc"); unlink(argv[1]); return (-1); } - memset(zero_buf, 0, uef.uef_size); + memset(zero_buf, 0, chunksize); num_inodes = num_inodes_by_path(fs_path); - chunksize = sizeof(struct ufs_extattr_header) + - uef.uef_size; for (loop = 0; loop < num_inodes; loop++) { error = write(i, zero_buf, chunksize); if (error != chunksize) { Dale Rahn drahn@prairieinet.net