Skip to contentSkip to conversation

ramfs and directory modification time

DISCUSSION Ph. Marek 2 participants 2 messages Feb 23, 2006 – Feb 24, 2006

lore
Share & tools
lore

Ph. Marek

author
#0 lore raw

Hello everybody,

I believe that I found a problem regarding ramfs and directory modification times.

Observe:

	$ /tmp# mkdir newdir
	$ /tmp# mount -t ramfs none newdir
	$ /tmp# cd newdir/
	$ /tmp/newdir# mkdir sub
	$ /tmp/newdir# cd sub
	$ /tmp/newdir/sub# ls -la --full-time
	total 0
	drwxr-xr-x 2 root root 0 2006-02-23 14:01:37.573655160 +0100 .
	drwxr-xr-x 3 root root 0 2006-02-23 14:01:33.221316816 +0100 ..
	$ /tmp/newdir/sub# touch a-new-file
	$ /tmp/newdir/sub# ls -la --full-time
	total 0
	drwxr-xr-x 2 root root 0 2006-02-23 14:01:37.573655160 +0100 .
	drwxr-xr-x 3 root root 0 2006-02-23 14:01:33.221316816 +0100 ..
	-rw-r--r-- 1 root root 0 2006-02-23 14:01:48.019067216 +0100 a-new-file

On a tmpfs or other (disk-based) filesystems (ext3) it works correctly. Is that a design wish, that ramfs is kept as simple as possible?

Nevertheless I believe that should be fixed, as everything that relies on the directory mtime won't work on an ramfs.

This is 2.6.26-rc4, btw, on x86.

Please CC me as I'm not subscribed (although I surely will have a look in the archives, too).

Regards,

Phil

#1 lore raw
Quoted 14 lines · Ph. Marek

I believe that I found a problem regarding ramfs and directory modification
times.

Observe:

(quoted diff) +0 -0
 	$ /tmp# mkdir newdir
 	$ /tmp# mount -t ramfs none newdir
 	$ /tmp# cd newdir/
 	$ /tmp/newdir# mkdir sub
 	$ /tmp/newdir# cd sub
 	$ /tmp/newdir/sub# ls -la --full-time
 	total 0

Review

Quoted 10 lines
(quoted diff) +0 -0
 	drwxr-xr-x 2 root root 0 2006-02-23 14:01:37.573655160 +0100 .
 	drwxr-xr-x 3 root root 0 2006-02-23 14:01:33.221316816 +0100 ..
 	$ /tmp/newdir/sub# touch a-new-file
 	$ /tmp/newdir/sub# ls -la --full-time
 	total 0
 	drwxr-xr-x 2 root root 0 2006-02-23 14:01:37.573655160 +0100 .
 	drwxr-xr-x 3 root root 0 2006-02-23 14:01:33.221316816 +0100 ..
 	-rw-r--r-- 1 root root 0 2006-02-23 14:01:48.019067216 +0100 a-new-file
 
 On a tmpfs or other (disk-based) filesystems (ext3) it works correctly.

Yes, bug. Thanks.

fs/ramfs/inode.c renamed from fs/ramfs/inode.c~ramfs-update-dir-mtime-and-ctime +2 -0
@@ -27,6 +27,7 @@
 #include <linux/fs.h>
 #include <linux/pagemap.h>
 #include <linux/highmem.h>
+#include <linux/time.h>
 #include <linux/init.h>
 #include <linux/string.h>
 #include <linux/smp_lock.h>
@@ -104,6 +105,7 @@ ramfs_mknod(struct inode *dir, struct de
 		d_instantiate(dentry, inode);
 		dget(dentry);	/* Extra count - pin the dentry in core */
 		error = 0;
+		dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
 	}
 	return error;
 }

_