lkml.org 
[lkml]   [2019]   [Feb]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] proc: update i_atime when reading files
Date
Prior to commit 1da4d377f943 ("proc: revalidate misc dentries"), the
access, modify, and change times of files in /proc were just the current
time. Now the mtime and ctime values change mostly as a user would
expect, but the atime isn't updated when the file read. This patch
updates the access time of /proc files when they are read.

Reported-by: David Both <dboth@millennium-technology.com>
Signed-off-by: Jeremy Cline <jcline@redhat.com>
---
fs/proc/inode.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index da649ccd6804..34d8603b9aa1 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -221,12 +221,17 @@ static loff_t proc_reg_llseek(struct file *file, loff_t offset, int whence)
static ssize_t proc_reg_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
{
ssize_t (*read)(struct file *, char __user *, size_t, loff_t *);
- struct proc_dir_entry *pde = PDE(file_inode(file));
+ struct inode *inode = file_inode(file);
+ struct proc_dir_entry *pde = PDE(inode);
ssize_t rv = -EIO;
if (use_pde(pde)) {
read = pde->proc_fops->read;
- if (read)
+ if (read) {
rv = read(file, buf, count, ppos);
+ if (rv >= 0)
+ inode->i_atime = current_time(inode);
+ }
+
unuse_pde(pde);
}
return rv;
--
2.20.1
\
 
 \ /
  Last update: 2019-02-21 17:38    [W:0.037 / U:0.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site