- if(obj) {
- retVal = yaffs_SetXAttribute(obj,name,data,size,flags);
- if(retVal< 0){
+static int yaffs_do_setxattr(const YCHAR *path, const char *name,
+ const void *data, int size, int flags, int follow)
+{
+ struct yaffs_obj *obj;
+ struct yaffs_obj *dir;
+ int notDir = 0;
+ int loop = 0;
+
+ int retVal = -1;
+
+ if (!path || !name || !data) {
+ yaffsfs_SetError(-EFAULT);
+ return -1;
+ }
+
+ if (yaffsfs_CheckPath(path) < 0) {
+ yaffsfs_SetError(-ENAMETOOLONG);
+ return -1;
+ }
+
+ yaffsfs_Lock();
+
+ obj = yaffsfs_FindObject(NULL, path, 0, 1, &dir, ¬Dir, &loop);
+
+ if (follow)
+ obj = yaffsfs_FollowLink(obj, 0, &loop);
+
+ if (!dir && notDir)
+ yaffsfs_SetError(-ENOTDIR);
+ else if (loop)
+ yaffsfs_SetError(-ELOOP);
+ else if (!dir || !obj)
+ yaffsfs_SetError(-ENOENT);
+ else {
+ retVal = yaffs_set_xattrib(obj, name, data, size, flags);
+ if (retVal < 0) {