Skip to contentSkip to conversation

make file times work in tmpfs

PATCH New Christoph Rohland 1 participant 1 message Feb 14, 2001

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 make file times work in tmpfs

Hi Alan,

here is a patch that makes the different file timestamps work on tmpfs.

Greetings
Christoph

mm/shmem.c renamed from mm/shmem.c.orig +9 -1
@@ -160,6 +160,7 @@
 	swp_entry_t **base, **ptr, **last;
 	struct shmem_inode_info * info = &inode->u.shmem_i;
 
+	inode->i_ctime = inode->i_mtime = CURRENT_TIME;
 	spin_lock (&info->lock);
 	index = (inode->i_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
 	if (index > info->max_index)
@@ -734,6 +735,7 @@
 	struct inode * inode = shmem_get_inode(dir->i_sb, mode, dev);
 	int error = -ENOSPC;
 
+	dir->i_ctime = dir->i_mtime = CURRENT_TIME;
 	if (inode) {
 		d_instantiate(dentry, inode);
 		dget(dentry); /* Extra count - pin the dentry in core */
@@ -767,6 +769,7 @@
 	if (S_ISDIR(inode->i_mode))
 		return -EPERM;
 
+	inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME;
 	inode->i_nlink++;
 	atomic_inc(&inode->i_count);	/* New dentry reference */
 	dget(dentry);		/* Extra pinning count for the created dentry */
@@ -809,7 +812,9 @@
 
 static int shmem_unlink(struct inode * dir, struct dentry *dentry)
 {
-	dentry->d_inode->i_nlink--;
+	struct inode *inode = dentry->d_inode;
+	inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME;
+	inode->i_nlink--;
 	dput(dentry);	/* Undo the count from "create" - this does all the work */
 	return 0;
 }
@@ -836,10 +841,12 @@
 	if (shmem_empty(new_dentry)) {
 		struct inode *inode = new_dentry->d_inode;
 		if (inode) {
+			inode->i_ctime = CURRENT_TIME;
 			inode->i_nlink--;
 			dput(new_dentry);
 		}
 		error = 0;
+		old_dentry->d_inode->i_ctime = old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME;
 	}
 	return error;
 }
@@ -873,6 +880,7 @@
 	UnlockPage(page);
 	page_cache_release(page);
 	up(&inode->i_sem);
+	dir->i_ctime = dir->i_mtime = CURRENT_TIME;
 	return 0;
 fail:
 	up(&inode->i_sem);