@@ -68,43 +68,24 @@ xbps_pkgdb_lock(struct xbps_handle *xhp)
6868{
6969 char path [PATH_MAX ];
7070 mode_t prev_umask ;
71- int r = 0 ;
72-
73- if (access (xhp -> rootdir , W_OK ) == -1 && errno != ENOENT ) {
74- return xbps_error_errno (errno ,
75- "failed to check whether the root directory is writable: "
76- "%s: %s\n" ,
77- xhp -> rootdir , strerror (errno ));
78- }
7971
8072 if (xbps_path_join (path , sizeof (path ), xhp -> metadir , "lock" , (char * )NULL ) == -1 ) {
8173 return xbps_error_errno (errno ,
8274 "failed to create lockfile path: %s\n" , strerror (errno ));
8375 }
8476
8577 prev_umask = umask (022 );
86-
87- /* if metadir does not exist, create it */
88- if (access (xhp -> metadir , R_OK |X_OK ) == -1 ) {
89- if (errno != ENOENT ) {
90- umask (prev_umask );
91- return xbps_error_errno (errno ,
92- "failed to check access to metadir: %s: %s\n" ,
93- xhp -> metadir , strerror (- r ));
94- }
95- if (xbps_mkpath (xhp -> metadir , 0755 ) == -1 && errno != EEXIST ) {
96- umask (prev_umask );
97- return xbps_error_errno (errno ,
98- "failed to create metadir: %s: %s\n" ,
99- xhp -> metadir , strerror (errno ));
100- }
78+ if (xbps_mkpath (xhp -> metadir , 0755 ) == -1 && errno != EEXIST ) {
79+ umask (prev_umask );
80+ return xbps_error_errno (errno ,
81+ "failed to create metadir: %s: %s\n" ,
82+ xhp -> metadir , strerror (errno ));
10183 }
10284
10385 xhp -> lock_fd = open (path , O_CREAT |O_WRONLY |O_CLOEXEC , 0664 );
104- if (xhp -> lock_fd == -1 ) {
86+ if (xhp -> lock_fd == -1 ) {
10587 return xbps_error_errno (errno ,
106- "failed to create lock file: %s: %s\n" , path ,
107- strerror (errno ));
88+ "failed to lock package database: %s\n" , strerror (errno ));
10889 }
10990 umask (prev_umask );
11091
0 commit comments