@@ -46,13 +46,10 @@ static int apply_timestamp(const char *path, struct timespec *ts) {
4646
4747 if (utimensat (AT_FDCWD , path , twice , AT_SYMLINK_NOFOLLOW ) < 0 ) {
4848
49- if (errno == EROFS ) {
50- log_debug ("Can't update timestamp file %s, file system is read-only." , path );
51- return 0 ;
52- }
49+ if (errno == EROFS )
50+ return log_debug ("Can't update timestamp file %s, file system is read-only." , path );
5351
54- log_error ("Failed to update timestamp on %s: %m" , path );
55- return - errno ;
52+ return log_error_errno (errno , "Failed to update timestamp on %s: %m" , path );
5653 }
5754
5855 } else if (errno == ENOENT ) {
@@ -62,39 +59,28 @@ static int apply_timestamp(const char *path, struct timespec *ts) {
6259 /* The timestamp file doesn't exist yet? Then let's create it. */
6360
6461 r = mac_selinux_create_file_prepare (path , S_IFREG );
65- if (r < 0 ) {
66- log_error ("Failed to set SELinux context for %s: %s" ,
67- path , strerror (- r ));
68- return r ;
69- }
62+ if (r < 0 )
63+ return log_error_errno (r , "Failed to set SELinux context for %s: %m" , path );
7064
7165 fd = open (path , O_CREAT |O_EXCL |O_WRONLY |O_TRUNC |O_CLOEXEC |O_NOCTTY |O_NOFOLLOW , 0644 );
7266 mac_selinux_create_file_clear ();
7367
7468 if (fd < 0 ) {
69+ if (errno == EROFS )
70+ return log_debug ("Can't create timestamp file %s, file system is read-only." , path );
7571
76- if (errno == EROFS ) {
77- log_debug ("Can't create timestamp file %s, file system is read-only." , path );
78- return 0 ;
79- }
80-
81- log_error ("Failed to create timestamp file %s: %m" , path );
82- return - errno ;
72+ return log_error_errno (errno , "Failed to create timestamp file %s: %m" , path );
8373 }
8474
8575 (void ) loop_write (fd , MESSAGE , strlen (MESSAGE ), false);
8676
8777 twice [0 ] = * ts ;
8878 twice [1 ] = * ts ;
8979
90- if (futimens (fd , twice ) < 0 ) {
91- log_error ("Failed to update timestamp on %s: %m" , path );
92- return - errno ;
93- }
94- } else {
95- log_error ("Failed to stat() timestamp file %s: %m" , path );
96- return - errno ;
97- }
80+ if (futimens (fd , twice ) < 0 )
81+ return log_error_errno (errno , "Failed to update timestamp on %s: %m" , path );
82+ } else
83+ log_error_errno (errno , "Failed to stat() timestamp file %s: %m" , path );
9884
9985 return 0 ;
10086}
@@ -108,7 +94,7 @@ int main(int argc, char *argv[]) {
10894 log_open ();
10995
11096 if (stat ("/usr" , & st ) < 0 ) {
111- log_error ( "Failed to stat /usr: %m" );
97+ log_error_errno ( errno , "Failed to stat /usr: %m" );
11298 return EXIT_FAILURE ;
11399 }
114100
0 commit comments