Module Name:    src
Committed By:   manu
Date:           Tue May  1 07:48:25 UTC 2012

Modified Files:
        src/sys/kern: vfs_xattr.c
        src/sys/ufs/ufs: ufs_extattr.c

Log Message:
Return ENODATA when no attribute is found, like Linux does. After
all we decided to adopt the Linux API, therefore there is rationale
to stick to it.

No standard tells us what to do, and our extended attribute API has not
been used in a release, therefore we do not break anything, and we get
more easily compatible with programs using the Linux extended attribute
API.

Note that FreeBSD and MacOS X return ENOATTR. FreeBSD has its own API
and MacOS X has a Linux-like API. How did the world get so complicated?


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/kern/vfs_xattr.c
cvs rdiff -u -r1.38 -r1.39 src/sys/ufs/ufs/ufs_extattr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/vfs_xattr.c
diff -u src/sys/kern/vfs_xattr.c:1.30 src/sys/kern/vfs_xattr.c:1.31
--- src/sys/kern/vfs_xattr.c:1.30	Tue Mar 13 18:40:57 2012
+++ src/sys/kern/vfs_xattr.c	Tue May  1 07:48:25 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_xattr.c,v 1.30 2012/03/13 18:40:57 elad Exp $	*/
+/*	$NetBSD: vfs_xattr.c,v 1.31 2012/05/01 07:48:25 manu Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_xattr.c,v 1.30 2012/03/13 18:40:57 elad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_xattr.c,v 1.31 2012/05/01 07:48:25 manu Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -219,7 +219,7 @@ extattr_set_vp(struct vnode *vp, int att
 				       &attrlen, l->l_cred);
 
 		switch (error) {
-		case ENOATTR:
+		case ENODATA:
 			if (flag & XATTR_REPLACE)
 				goto done;
 			break;

Index: src/sys/ufs/ufs/ufs_extattr.c
diff -u src/sys/ufs/ufs/ufs_extattr.c:1.38 src/sys/ufs/ufs/ufs_extattr.c:1.39
--- src/sys/ufs/ufs/ufs_extattr.c:1.38	Mon Mar 26 11:03:43 2012
+++ src/sys/ufs/ufs/ufs_extattr.c	Tue May  1 07:48:25 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_extattr.c,v 1.38 2012/03/26 11:03:43 wiz Exp $	*/
+/*	$NetBSD: ufs_extattr.c,v 1.39 2012/05/01 07:48:25 manu Exp $	*/
 
 /*-
  * Copyright (c) 1999-2002 Robert N. M. Watson
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ufs_extattr.c,v 1.38 2012/03/26 11:03:43 wiz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_extattr.c,v 1.39 2012/05/01 07:48:25 manu Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ffs.h"
@@ -886,7 +886,7 @@ ufs_extattr_disable(struct ufsmount *ump
 
 	uele = ufs_extattr_find_attr(ump, attrnamespace, attrname);
 	if (!uele)
-		return (ENOATTR);
+		return (ENODATA);
 
 	LIST_REMOVE(uele, uele_entries);
 
@@ -1034,7 +1034,7 @@ ufs_extattr_get_header(struct vnode *vp,
 
 	/* Defined? */
 	if ((ueh->ueh_flags & UFS_EXTATTR_ATTR_FLAG_INUSE) == 0)
-		return ENOATTR;
+		return ENODATA;
 
 	/* Valid for the current inode generation? */
 	if (ueh->ueh_i_gen != ip->i_gen) {
@@ -1047,7 +1047,7 @@ ufs_extattr_get_header(struct vnode *vp,
 		printf("%s (%s): inode gen inconsistency (%u, %jd)\n",
 		       __func__,  mp->mnt_stat.f_mntonname, ueh->ueh_i_gen,
 		       (intmax_t)ip->i_gen);
-		return ENOATTR;
+		return ENODATA;
 	}
 
 	/* Local size consistency check. */
@@ -1120,7 +1120,7 @@ ufs_extattr_get(struct vnode *vp, int at
 
 	attribute = ufs_extattr_find_attr(ump, attrnamespace, name);
 	if (!attribute)
-		return (ENOATTR);
+		return (ENODATA);
 
 	/*
 	 * Allow only offsets of zero to encourage the read/replace
@@ -1244,7 +1244,7 @@ ufs_extattr_list(struct vnode *vp, int a
 			continue;
 
 		error = ufs_extattr_get_header(vp, uele, &ueh, NULL);
-		if (error == ENOATTR)
+		if (error == ENODATA)
 			continue;	
 		if (error != 0)
 			return error;
@@ -1408,7 +1408,7 @@ ufs_extattr_set(struct vnode *vp, int at
 		attribute =  ufs_extattr_autocreate_attr(vp, attrnamespace, 
 							 name, l);
 		if  (!attribute)
-			return (ENOATTR);
+			return (ENODATA);
 	}
 
 	/*
@@ -1518,7 +1518,7 @@ ufs_extattr_rm(struct vnode *vp, int att
 
 	attribute = ufs_extattr_find_attr(ump, attrnamespace, name);
 	if (!attribute)
-		return (ENOATTR);
+		return (ENODATA);
 
 	/*
 	 * Don't need to get a lock on the backing file if the getattr is

Reply via email to