Fix some error handling
This commit is contained in:
parent
1241011833
commit
c75b586829
@ -14,6 +14,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define CHUNK_SIZE 4096
|
||||
@ -36,8 +37,8 @@ int main(int argc, char ** argv) {
|
||||
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
int fd = open(argv[i], O_RDONLY);
|
||||
if (fd == -1) {
|
||||
fprintf(stderr, "%s: %s: no such file or directory\n", argv[0], argv[i]);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "%s: %s: %s\n", argv[0], argv[i], strerror(errno));
|
||||
ret = 1;
|
||||
continue;
|
||||
}
|
||||
|
@ -951,7 +951,7 @@ int main(int argc, char ** argv) {
|
||||
FILE * f = fopen(argv[optind],"r");
|
||||
|
||||
if (!f) {
|
||||
fprintf(stderr, "%s: %s: file not found\n", argv[0], argv[optind]);
|
||||
fprintf(stderr, "%s: %s: %s\n", argv[0], argv[optind], strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
/etc/master.passwd f 600 0 0 - - - - -
|
||||
/bin/sudo f 4555 0 0 - - - - -
|
||||
/home/local d 775 1000 1000 - - - - -
|
||||
/home/local/hello f 664 1000 1000 - - - - -
|
||||
|
Loading…
Reference in New Issue
Block a user