mirror of
https://github.com/moparisthebest/pacman
synced 2024-08-13 17:03:46 -04:00
Be smarter about failure to read backup file contents
Instead of always printing MISSING, we can switch on the errno value set by access() and print a more useful string. In this case, handle files we can't read by printing UNREADABLE, print MISSING on ENOENT, and print UNKNOWN for anything else. Fixes FS#22546. Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
c91bd3dda9
commit
cda7d7847f
@ -25,6 +25,7 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#include <alpm.h>
|
||||
@ -183,7 +184,16 @@ static const char *get_backup_file_status(const char *root,
|
||||
}
|
||||
free(md5sum);
|
||||
} else {
|
||||
ret = "MISSING";
|
||||
switch(errno) {
|
||||
case EACCES:
|
||||
ret = "UNREADABLE";
|
||||
break;
|
||||
case ENOENT:
|
||||
ret = "MISSING";
|
||||
break;
|
||||
default:
|
||||
ret = "UNKNOWN";
|
||||
}
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user