Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
1 files changed, 13 insertions, 7 deletions
-rw-r--r--chwrite/chwrite.c20
diff --git a/chwrite/chwrite.c b/chwrite/chwrite.c
index 395cf91..8aecf4b 100644
--- a/chwrite/chwrite.c
+++ b/chwrite/chwrite.c
@@ -53,12 +53,16 @@ main(int argc, char *argv[]) {
for (i = 2; i < argc; ++i) {
f = open(argv[i], 0);
- if (f == -1)
- return errno;
+ if (f == -1) {
+ perror("open");
+ return 3;
+ }
result = fstat(f, &fs);
- if (result == -1)
- return errno;
+ if (result == -1) {
+ perror("fstat");
+ return 3;
+ }
if (operation == '+')
fs.st_mode |= S_IWUSR;
@@ -66,8 +70,10 @@ main(int argc, char *argv[]) {
fs.st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
result = fchmod(f, fs.st_mode);
- if (result == -1)
- return errno;
+ if (result == -1) {
+ perror("fchmod");
+ return 3;
+ }
}
- return result;
+ return 0;
}