summaryrefslogtreecommitdiffstats
path: root/mount/mount.c
diff options
context:
space:
mode:
authorKarel Zak2010-10-29 20:04:00 +0200
committerKarel Zak2010-10-29 20:04:00 +0200
commita21640baec08b7b20e7d829c3aae87e35d5dbf04 (patch)
tree508a97067581fc8122a61bb90062ded5ed33bab8 /mount/mount.c
parentdocs: add note about agetty to TODO (diff)
downloadkernel-qcow2-util-linux-a21640baec08b7b20e7d829c3aae87e35d5dbf04.tar.gz
kernel-qcow2-util-linux-a21640baec08b7b20e7d829c3aae87e35d5dbf04.tar.xz
kernel-qcow2-util-linux-a21640baec08b7b20e7d829c3aae87e35d5dbf04.zip
mount: use utimensat(AT_FDCWD) rather than open()+futimens()
Thanks to Kay Sievers. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'mount/mount.c')
-rw-r--r--mount/mount.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/mount/mount.c b/mount/mount.c
index 0567418db..1c8a55fd3 100644
--- a/mount/mount.c
+++ b/mount/mount.c
@@ -1313,8 +1313,6 @@ cdrom_setspeed(const char *spec) {
static int
is_readonly(const char *path)
{
- int fd;
-
if (access(path, W_OK) == 0)
return 0;
if (errno == EROFS)
@@ -1332,19 +1330,14 @@ is_readonly(const char *path)
*
* - for read-write filesystem with read-only VFS node (aka -o remount,ro,bind)
*/
- fd = open(path, O_RDONLY);
- if (fd >= 0) {
+ {
struct timespec times[2];
- int errsv = 0;
times[0].tv_nsec = UTIME_NOW; /* atime */
times[1].tv_nsec = UTIME_OMIT; /* mtime */
- if (futimens(fd, times) == -1)
- errsv = errno;
- close(fd);
-
- return errsv == EROFS;
+ if (utimensat(AT_FDCWD, path, times, 0) == -1)
+ return errno == EROFS;
}
#endif
return 0;