]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
script, hwclock: check file exist with access(3) rather than stat(3)
authorSami Kerola <kerolasa@iki.fi>
Sat, 31 Oct 2015 19:21:17 +0000 (19:21 +0000)
committerKarel Zak <kzak@redhat.com>
Mon, 9 Nov 2015 08:56:14 +0000 (09:56 +0100)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
sys-utils/hwclock.c
term-utils/script.c

index 4b201d7092a1c86df8a226793cbd0e28bfddaeb2..0d110617e41cdbcf13a0ef7227fc504ef4fbb62f 100644 (file)
@@ -258,15 +258,12 @@ hw_clock_is_utc(const bool utc, const bool local_opt,
 static int read_adjtime(struct adjtime *adjtime_p)
 {
        FILE *adjfile;
-       int rc;                 /* local return code */
-       struct stat statbuf;    /* We don't even use the contents of this. */
        char line1[81];         /* String: first line of adjtime file */
        char line2[81];         /* String: second line of adjtime file */
        char line3[81];         /* String: third line of adjtime file */
        long timeval;
 
-       rc = stat(adj_file_name, &statbuf);
-       if (rc < 0 && errno == ENOENT) {
+       if (access(adj_file_name, R_OK) != 0) {
                /* He doesn't have a adjtime file, so we'll use defaults. */
                adjtime_p->drift_factor = 0;
                adjtime_p->last_adj_time = 0;
index b6227c08ed32b86c95988302afd16c1e0fe2a7a5..e247c83cfd4cf4554662054b3e861f429f92fb21 100644 (file)
@@ -609,7 +609,6 @@ static void getmaster(struct script_control *ctl)
        }
 #else
        char *pty, *bank, *cp;
-       struct stat stb;
 
        ctl->isterm = isatty(STDIN_FILENO);
 
@@ -617,7 +616,7 @@ static void getmaster(struct script_control *ctl)
        for (bank = "pqrs"; *bank; bank++) {
                ctl->line[strlen("/dev/pty")] = *bank;
                *pty = '0';
-               if (stat(ctl->line, &stb) < 0)
+               if (access(ctl->line, F_OK) != 0)
                        break;
                for (cp = "0123456789abcdef"; *cp; cp++) {
                        *pty = *cp;