2006-02-23 13:05:23

by Ph. Marek

[permalink] [raw]
Subject: ramfs and directory modification time

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


2006-02-24 12:04:44

by Andrew Morton

[permalink] [raw]
Subject: Re: ramfs and directory modification time

"Ph. Marek" <[email protected]> wrote:
>
> 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.

Yes, bug. Thanks.


--- devel/fs/ramfs/inode.c~ramfs-update-dir-mtime-and-ctime 2006-02-24 03:53:46.000000000 -0800
+++ devel-akpm/fs/ramfs/inode.c 2006-02-24 03:54:29.000000000 -0800
@@ -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;
}
_

2006-02-26 13:08:18

by Chuck Ebbert

[permalink] [raw]
Subject: Re: ramfs and directory modification time

In-Reply-To: <[email protected]>

On Fri, 24 Feb 2006 at 04:04:00 -0800, Andrew Morton wrote:

> --- devel/fs/ramfs/inode.c~ramfs-update-dir-mtime-and-ctime 2006-02-24 03:53:46.000000000 -0800
> +++ devel-akpm/fs/ramfs/inode.c 2006-02-24 03:54:29.000000000 -0800
> @@ -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;
> }


Shouldn't that be CURRENT_TIME?

[me@tu ramfs]$ grep -i current_time *
inode.c: inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;


--
Chuck
"Equations are the Devil's sentences." --Stephen Colbert