[Yaffs] Problem with file attributes

Luc Van Oostenryck luc.vanoostenryck at looxix.net
Sun Jul 24 10:53:04 BST 2005


Frank Lehmann wrote:
> Hello Everyone,
> 
> just now I changed from 'jffs2' to 'yaffs'. Up to now no problems occurred
> during compiling and setting up my embedded system with 'yaffs' NAND flash
> partitions in combination with kernel 2.4.25. The MTD driver is working
> fine. Installing and mounting 'yaffs' partitions performed very well.
> No errors when reading from or writing to 'yaffs' partitions. As far as
> good!
> 
> Unfortunately at the end of the day one problem came up. All files or
> directories I create as user (not 'root') are assigned to 'root'.
> For example if I am user 'abc' and I create a file or if I transfer a file
> via FTP to the 'yaffs' partition to any directory which doesn't belong to
> group or user 'root', I always get assigned user and group 'root' to that
> file. After that I can change permissions, user and group.
> 
> Even if I use the setgid and setuid flags (6755) of a directory which
> belongs to user 'abc' and group 'xyz' and where I create or transfer a file,
> the result is always the same. The new file belongs to 'root'.
> 
> It seems that after remounting everything is fine.
> 
> My expectation was that 'yaffs' handles the file/directory attributes in
> same way like other file systems. Maybe I am wrong?
> 
> Any idea what's going wrong? Hints in this regard are appreciated.
> 
> Thanks,
> Frank
> 

The attached patch is needed to properly handle attributes of created files.


Luc

-------------- next part --------------
diff --git a/fs/yaffs2/yaffs_fs.c b/fs/yaffs2/yaffs_fs.c
--- a/fs/yaffs2/yaffs_fs.c
+++ b/fs/yaffs2/yaffs_fs.c
@@ -914,6 +914,8 @@ static int yaffs_mknod(struct inode *dir
 	yaffs_Object *parent = yaffs_InodeToObject(dir);
 	
 	int error = -ENOSPC;
+	uid_t uid = current->fsuid;
+	gid_t gid = (dir->i_mode & S_ISGID) ? dir->i_gid : current->fsgid;
 
 	if(parent)
 	{
@@ -939,18 +941,18 @@ static int yaffs_mknod(struct inode *dir
 			// Special (socket, fifo, device...)
 			T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod: making special\n"));
 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
-                        obj = yaffs_MknodSpecial(parent,dentry->d_name.name,mode,current->uid, current->gid,old_encode_dev(rdev));
+                        obj = yaffs_MknodSpecial(parent,dentry->d_name.name,mode,uid, gid,old_encode_dev(rdev));
 #else
-                        obj = yaffs_MknodSpecial(parent,dentry->d_name.name,mode,current->uid, current->gid,rdev);
+                        obj = yaffs_MknodSpecial(parent,dentry->d_name.name,mode,uid, gid,rdev);
 #endif			
                 break;
 		case S_IFREG:	// file		
 			T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod: making file\n"));
-			obj = yaffs_MknodFile(parent,dentry->d_name.name,mode,current->uid, current->gid);
+			obj = yaffs_MknodFile(parent,dentry->d_name.name,mode,uid, gid);
 			break;
 		case S_IFDIR:	// directory
 			T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod: making directory\n"));
-			obj = yaffs_MknodDirectory(parent,dentry->d_name.name,mode,current->uid, current->gid);
+			obj = yaffs_MknodDirectory(parent,dentry->d_name.name,mode,uid, gid);
 			break;
 		case S_IFLNK:	// symlink
 			T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod: making file\n"));
@@ -1086,13 +1088,15 @@ static int yaffs_symlink(struct inode * 
 {
 	yaffs_Object *obj;
 	yaffs_Device *dev;
+	uid_t uid = current->fsuid;
+	gid_t gid = (dir->i_mode & S_ISGID) ? dir->i_gid : current->fsgid;
 	
 	T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_symlink\n"));
 	
 	dev = yaffs_InodeToObject(dir)->myDev;
 	yaffs_GrossLock(dev);
 	obj = yaffs_MknodSymLink(yaffs_InodeToObject(dir), dentry->d_name.name, 
-							 S_IFLNK | S_IRWXUGO, current->uid, current->gid,
+							 S_IFLNK | S_IRWXUGO, uid, gid,
 							 symname);
 	yaffs_GrossUnlock(dev);
 



More information about the yaffs mailing list