aboutsummaryrefslogtreecommitdiff
path: root/lib/functions.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2007-01-07 22:51:12 -0500
committerRob Landley <rob@landley.net>2007-01-07 22:51:12 -0500
commit1322beb384ea43a15c17f8229e7db070949dd331 (patch)
tree8cd23c638a6b6aeffa0a761025848e7bce60d4f1 /lib/functions.c
parent016bf8289e12346f45f543d5b048d2496f4f0256 (diff)
downloadtoybox-1322beb384ea43a15c17f8229e7db070949dd331.tar.gz
xopen() wants 2 arguments unless you're creating a file, in which case you
need 3. Doing varargs for this doesn't really appeal to me (bugs in waiting) so I made an xcreate() that takes 3 args, and had xopen() call it with 0 for the third argument. That way, if we feed O_CREAT to xopen() the permission 000 result should be easy to spot.
Diffstat (limited to 'lib/functions.c')
-rw-r--r--lib/functions.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/functions.c b/lib/functions.c
index b42f62d3..990c34fa 100644
--- a/lib/functions.c
+++ b/lib/functions.c
@@ -141,13 +141,19 @@ void xexec(char **argv)
}
// Die unless we can open/create a file, returning file descriptor.
-int xopen(char *path, int flags, int mode)
+int xcreate(char *path, int flags, int mode)
{
int fd = open(path, flags, mode);
if (fd == -1) error_exit("No file %s\n", path);
return fd;
}
+// Die unless we can open a file, returning file descriptor.
+int xopen(char *path, int flags)
+{
+ return xcreate(path, flags, 0);
+}
+
// Die unless we can open/create a file, returning FILE *.
FILE *xfopen(char *path, char *mode)
{