From cda7d7847f3434959ef077ec6eb78ea4b2078a5a Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 22 Jan 2011 11:38:34 -0600 Subject: 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 --- src/pacman/package.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/pacman/package.c b/src/pacman/package.c index 68b0693a..77a5ee72 100644 --- a/src/pacman/package.c +++ b/src/pacman/package.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -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); } -- cgit v1.2.3-2-g168b