From: Sturle Sunde <sturle.sunde@usit.uio.no>
To: linux-kernel@vger.kernel.org
Cc: viro@parcelfarce.linux.theplanet.co.uk, torvalds@osdl.org
Subject: [PATCH] atime on devices
Date: Wed, 09 Jun 2004 16:20:17 +0200 [thread overview]
Message-ID: <riqhdtkke3i.fsf@maggie.uio.no> (raw)
Some software use access times on device files to check if there is
mouse or keyboard activity on the console. This used to work in old
kernels, or perhaps it was old hardware, but not any more. Google
didn't find any other portable ways of checking for mouse or keyboard
activity without accessing the X11 display.
After writing a patch for it, I searched a bit more, and found this
discussion in the linux-kernel list archives from April:
|[Viro]
|Particulary interesting one is in tty_io.c. There we
|1) unconditionally touch i_atime on read()
|2) do not touch it on write()
|3) never mark the inode dirty.
|[Viro]
|>[Linus]
|> >[Viro]
|> > There are similar places in some other char drivers. Obvious step
|> > would be to have them do file_accessed() instead; however, I'd
|> > really like to hear the rationale for existing
|> > behaviour. Comments?
|>
|> I don't know about other char drivers, those may well be wrong. But
|> for tty's in particular, idle time calculations really do pretty
|> much require the behaviour (apart from #3 - and #3 is, I think,
|> effectively required by not wanting to touch the disk on keyboard
|> accesses).
|
|AFAICS, they simply copy what tty_io.c does. Out of these guys
|busmouse.c might have a similar excuse; qtronix.c and sonypi.c AFAICS
|have no reason to touch atime at all. No idea what should
|usb/core/devio.c do...
|
|Anyway, I'm going down right now; expect a patchbomb tonight after I
|get some sleep...
Was there any patches regarding atime on devices?
Here is a patch to set atime on device files for mouse, joystick,
touchscreen, USB and hid devices in the same way as tty devices. I
hope it doesn't collide with any ongoing atime work.
Description:
Update atime on successfull reads from input devices in the same way
as TTY devices and other related character devices.
Patch against 2.6.7-rc3:
------------8<-------------8<-------------8<-------------8<-------------
diff -uprN linux-2.6.7-rc3.orig/drivers/input/evdev.c linux-2.6.7-rc3/drivers/input/evdev.c
--- linux-2.6.7-rc3.orig/drivers/input/evdev.c 2004-06-13 19:35:47.512015637 +0200
+++ linux-2.6.7-rc3/drivers/input/evdev.c 2004-06-13 19:40:35.933984810 +0200
@@ -190,6 +190,9 @@ static ssize_t evdev_read(struct file *
retval += sizeof(struct input_event);
}
+ if (retval > 0)
+ file->f_dentry->d_inode->i_atime = CURRENT_TIME;
+
return retval;
}
diff -uprN linux-2.6.7-rc3.orig/drivers/input/joydev.c linux-2.6.7-rc3/drivers/input/joydev.c
--- linux-2.6.7-rc3.orig/drivers/input/joydev.c 2004-06-13 19:35:47.527015739 +0200
+++ linux-2.6.7-rc3/drivers/input/joydev.c 2004-06-13 19:40:35.933984810 +0200
@@ -273,6 +273,9 @@ static ssize_t joydev_read(struct file *
retval += sizeof(struct js_event);
}
+ if (retval > 0)
+ file->f_dentry->d_inode->i_atime = CURRENT_TIME;
+
return retval;
}
diff -uprN linux-2.6.7-rc3.orig/drivers/input/mousedev.c linux-2.6.7-rc3/drivers/input/mousedev.c
--- linux-2.6.7-rc3.orig/drivers/input/mousedev.c 2004-06-13 19:35:47.657016630 +0200
+++ linux-2.6.7-rc3/drivers/input/mousedev.c 2004-06-13 20:22:04.210901032 +0200
@@ -462,6 +462,9 @@ static ssize_t mousedev_read(struct file
if (copy_to_user(buffer, list->ps2 + list->bufsiz - list->buffer - count, count))
return -EFAULT;
+ if (count > 0)
+ file->f_dentry->d_inode->i_atime = CURRENT_TIME;
+
return count;
}
diff -uprN linux-2.6.7-rc3.orig/drivers/input/tsdev.c linux-2.6.7-rc3/drivers/input/tsdev.c
--- linux-2.6.7-rc3.orig/drivers/input/tsdev.c 2004-05-10 04:33:20.000000000 +0200
+++ linux-2.6.7-rc3/drivers/input/tsdev.c 2004-06-13 19:40:35.933984810 +0200
@@ -176,6 +176,9 @@ static ssize_t tsdev_read(struct file *f
retval += sizeof(TS_EVENT);
}
+ if (retval > 0)
+ file->f_dentry->d_inode->i_atime = CURRENT_TIME;
+
return retval;
}
diff -uprN linux-2.6.7-rc3.orig/drivers/usb/core/devio.c linux-2.6.7-rc3/drivers/usb/core/devio.c
--- linux-2.6.7-rc3.orig/drivers/usb/core/devio.c 2004-06-13 19:35:52.027046571 +0200
+++ linux-2.6.7-rc3/drivers/usb/core/devio.c 2004-06-13 19:40:35.933984810 +0200
@@ -172,6 +172,9 @@ static ssize_t usbdev_read(struct file *
pos += length;
}
+ if (ret > 0)
+ file->f_dentry->d_inode->i_atime = CURRENT_TIME;
+
err:
up(&dev->serialize);
return ret;
diff -uprN linux-2.6.7-rc3.orig/drivers/usb/input/hiddev.c linux-2.6.7-rc3/drivers/usb/input/hiddev.c
--- linux-2.6.7-rc3.orig/drivers/usb/input/hiddev.c 2004-06-13 19:35:52.232047975 +0200
+++ linux-2.6.7-rc3/drivers/usb/input/hiddev.c 2004-06-13 20:21:33.435693144 +0200
@@ -371,6 +371,9 @@ static ssize_t hiddev_read(struct file *
}
+ if(retval > 0)
+ file->f_dentry->d_inode->i_atime = CURRENT_TIME;
+
return retval;
}
------------8<-------------8<-------------8<-------------8<-------------
--
Sturle
~~~~~
et atime on device files for mouse, joystick,
touchscreen, USB and hid devices in the same way as tty devices. I
hope it doesn't collide with any ongoing atime work.
Description:
Update atime on successfull reads from input devices in the same way
as TTY devices and other related character devices.
Patch against 2.6.7-rc3:
------------8<-------------8<-------------8<-------------8<-------------
diff -uprN linux-2.6.7-rc3.orig/drivers/input/evdev.c linux-2.6.7-rc3/drivers/input/evdev.c
--- linux-2.6.7-rc3.orig/drivers/input/evdev.c 2004-06-13 19:35:47.512015637 +0200
+++ linux-2.6.7-rc3/drivers/input/evdev.c 2004-06-13 19:40:35.933984810 +0200
@@ -190,6 +190,9 @@ static ssize_t evdev_read(struct file *
retval += sizeof(struct input_event);
}
+ if (retval > 0)
+ file->f_dentry->d_inode->i_atime = CURRENT_TIME;
+
return retval;
}
diff -uprN linux-2.6.7-rc3.orig/drivers/input/joydev.c linux-2.6.7-rc3/drivers/input/joydev.c
--- linux-2.6.7-rc3.orig/drivers/input/joydev.c 2004-06-13 19:35:47.527015739 +0200
+++ linux-2.6.7-rc3/drivers/input/joydev.c 2004-06-13 19:40:35.933984810 +0200
@@ -273,6 +273,9 @@ static ssize_t joydev_read(struct file *
retval += sizeof(struct js_event);
}
+ if (retval > 0)
+ file->f_dentry->d_inode->i_atime = CURRENT_TIME;
+
return retval;
}
diff -uprN linux-2.6.7-rc3.orig/drivers/input/mousedev.c linux-2.6.7-rc3/drivers/input/mousedev.c
--- linux-2.6.7-rc3.orig/drivers/input/mousedev.c 2004-06-13 19:35:47.657016630 +0200
+++ linux-2.6.7-rc3/drivers/input/mousedev.c 2004-06-13 20:22:04.210901032 +0200
@@ -462,6 +462,9 @@ static ssize_t mousedev_read(struct file
if (copy_to_user(buffer, list->ps2 + list->bufsiz - list->buffer - count, count))
return -EFAULT;
+ if (count > 0)
+ file->f_dentry->d_inode->i_atime = CURRENT_TIME;
+
return count;
}
diff -uprN linux-2.6.7-rc3.orig/drivers/input/tsdev.c linux-2.6.7-rc3/drivers/input/tsdev.c
--- linux-2.6.7-rc3.orig/drivers/input/tsdev.c 2004-05-10 04:33:20.000000000 +0200
+++ linux-2.6.7-rc3/drivers/input/tsdev.c 2004-06-13 19:40:35.933984810 +0200
@@ -176,6 +176,9 @@ static ssize_t tsdev_read(struct file *f
retval += sizeof(TS_EVENT);
}
+ if (retval > 0)
+ file->f_dentry->d_inode->i_atime = CURRENT_TIME;
+
return retval;
}
diff -uprN linux-2.6.7-rc3.orig/drivers/usb/core/devio.c linux-2.6.7-rc3/drivers/usb/core/devio.c
--- linux-2.6.7-rc3.orig/drivers/usb/core/devio.c 2004-06-13 19:35:52.027046571 +0200
+++ linux-2.6.7-rc3/drivers/usb/core/devio.c 2004-06-13 19:40:35.933984810 +0200
@@ -172,6 +172,9 @@ static ssize_t usbdev_read(struct file *
pos += length;
}
+ if (ret > 0)
+ file->f_dentry->d_inode->i_atime = CURRENT_TIME;
+
err:
up(&dev->serialize);
return ret;
diff -uprN linux-2.6.7-rc3.orig/drivers/usb/input/hiddev.c linux-2.6.7-rc3/drivers/usb/input/hiddev.c
--- linux-2.6.7-rc3.orig/drivers/usb/input/hiddev.c 2004-06-13 19:35:52.232047975 +0200
+++ linux-2.6.7-rc3/drivers/usb/input/hiddev.c 2004-06-13 20:21:33.435693144 +0200
@@ -371,6 +371,9 @@ static ssize_t hiddev_read(struct file *
}
+ if(retval > 0)
+ file->f_dentry->d_inode->i_atime = CURRENT_TIME;
+
return retval;
}
------------8<-------------8<-------------8<-------------8<-------------
--
Sturle
~~~~~
next reply other threads:[~2004-06-16 0:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-09 14:20 Sturle Sunde [this message]
2004-06-16 12:59 ` Jan-Benedict Glaw
[not found] <fa.j3j5n9a.12n2f8g@ifi.uio.no>
[not found] ` <fa.gbo3vfu.1e429hc@ifi.uio.no>
2004-06-16 15:30 ` Sturle Sunde
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=riqhdtkke3i.fsf@maggie.uio.no \
--to=sturle.sunde@usit.uio.no \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.org \
--cc=viro@parcelfarce.linux.theplanet.co.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®