E2BIG from listxattr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

If you create a bunch of xattrs on an inode, you can get into a sitation 
where you can no longer list them.  The reproducer below just does 
setxattr until it gets an error or listxattr starts returning E2BIG.  Once 
you're in this state you can getxattr attrs you know the name of, but you 
can't list them, which is a bit inconvenient.

Presumably the fix is for setxattr to verify that the list of all xattr 
names will fit into a 64K buffer or else return ENOSPC...

sage


#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/xattr.h>
#include <string.h>
#include <errno.h>

int main(int argc, char **argv)
{
	char *fn = argv[1];
	char buf[655360];
	int buflen = sizeof(buf);
	int i;

	for (i = 0; i < 10000; ++i) {
		int r = listxattr(fn, buf, buflen);
		if (r < 0) {
			perror("listxattr");
			return 1;
		}
		char n[100];
		sprintf(n, "user.foooooooooooooooooooooooooooooooooooooo%d", i);
		r = setxattr(fn, n, "", 0, 0);
		if (r < 0) {
			perror("setxattr");
			return 1;
		}
		printf("set %d\n", i);
	}
	return 0;
}

_______________________________________________
xfs mailing list
xfs@xxxxxxxxxxx
http://oss.sgi.com/mailman/listinfo/xfs




[Index of Archives]     [Linux XFS Devel]     [Linux Filesystem Development]     [Filesystem Testing]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux