[pacman-dev] [PATCH 3/3] Be smarter about failure to read backup file contents
dpmcgee at gmail.com
dpmcgee at gmail.com
Sat Jan 22 15:44:02 EST 2011
From: Dan McGee <dan at archlinux.org>
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 at archlinux.org>
---
src/pacman/package.c | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/src/pacman/package.c b/src/pacman/package.c
index 68b0693..77a5ee7 100644
--- a/src/pacman/package.c
+++ b/src/pacman/package.c
@@ -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);
}
--
1.7.3.5
More information about the pacman-dev
mailing list