From 5933ac5210ebd86d3bffcf1a11e897cbf514560e Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Fri, 27 Sep 2013 14:44:52 +0200 Subject: [PATCH] Rename O_CREAT to O_CREATE. --- libc/include/fcntl.h | 3 +++ sortix/descriptor.cpp | 6 +++--- sortix/fs/kram.cpp | 2 +- sortix/fs/user.cpp | 2 +- sortix/include/sortix/fcntl.h | 2 +- sortix/initrd.cpp | 2 +- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/libc/include/fcntl.h b/libc/include/fcntl.h index 9477240b..5077abd0 100644 --- a/libc/include/fcntl.h +++ b/libc/include/fcntl.h @@ -45,6 +45,9 @@ __BEGIN_DECLS #define O_WRONLY O_WRITE #define O_RDWR (O_READ | O_WRITE) +/* Backwards compatibility with existing systems that call it O_CREAT. */ +#define O_CREAT O_CREATE + /* Compatibility with Linux and other systems that have this. */ #define O_ACCMODE (O_READ | O_WRITE | O_EXEC | O_SEARCH) diff --git a/sortix/descriptor.cpp b/sortix/descriptor.cpp index 367b547a..da1825bb 100644 --- a/sortix/descriptor.cpp +++ b/sortix/descriptor.cpp @@ -46,7 +46,7 @@ namespace Sortix { const int ACCESS_FLAGS = O_READ | O_WRITE | O_EXEC | O_SEARCH; // Flags that only make sense at open time. -const int OPEN_FLAGS = O_CREAT | O_DIRECTORY | O_EXCL | O_TRUNC; +const int OPEN_FLAGS = O_CREATE | O_DIRECTORY | O_EXCL | O_TRUNC; // Flags that only make sense for descriptors. const int DESCRIPTOR_FLAGS = O_APPEND | O_NONBLOCK; @@ -334,11 +334,11 @@ ssize_t Descriptor::readdirents(ioctx_t* ctx, struct kernel_dirent* dirent, static bool IsSaneFlagModeCombination(int flags, mode_t /*mode*/) { - // It doesn't make sense to pass O_CREAT or O_TRUNC when attempting to open + // It doesn't make sense to pass O_CREATE or O_TRUNC when attempting to open // a directory. We also reject O_TRUNC | O_DIRECTORY early to prevent // opening a directory, attempting to truncate it, and then aborting with an // error because a directory was opened. - if ( (flags & (O_CREAT | O_TRUNC)) && (flags & (O_DIRECTORY)) ) + if ( (flags & (O_CREATE | O_TRUNC)) && (flags & (O_DIRECTORY)) ) return errno = EINVAL, false; return true; diff --git a/sortix/fs/kram.cpp b/sortix/fs/kram.cpp index fe7eb9f8..85c0c4f1 100644 --- a/sortix/fs/kram.cpp +++ b/sortix/fs/kram.cpp @@ -228,7 +228,7 @@ Ref Dir::open(ioctx_t* ctx, const char* filename, int flags, mode_t mode) if ( flags & O_EXCL ) { errno = EEXIST; return Ref(NULL); } return children[childindex].inode; } - if ( !(flags & O_CREAT) ) + if ( !(flags & O_CREATE) ) return errno = ENOENT, Ref(NULL); Ref file(new File(dev, 0, ctx->uid, ctx->gid, mode)); if ( !file ) diff --git a/sortix/fs/user.cpp b/sortix/fs/user.cpp index 32cec508..41088bf9 100644 --- a/sortix/fs/user.cpp +++ b/sortix/fs/user.cpp @@ -556,7 +556,7 @@ Ref ServerNode::open(ioctx_t* /*ctx*/, const char* filename, int flags, errno != ERANGE ) { errno = saved_errno; - if ( !(flags & O_CREAT) ) + if ( !(flags & O_CREATE) ) return errno = ENOENT, Ref(NULL); ino_t ino = (ino_t) ull_ino; return server->BootstrapNode(ino, mode & S_IFMT); diff --git a/sortix/include/sortix/fcntl.h b/sortix/include/sortix/fcntl.h index 91251250..209bd3b7 100644 --- a/sortix/include/sortix/fcntl.h +++ b/sortix/include/sortix/fcntl.h @@ -36,7 +36,7 @@ __BEGIN_DECLS #define O_EXEC (1<<2) #define O_APPEND (1<<3) #define O_CLOEXEC (1<<4) -#define O_CREAT (1<<5) +#define O_CREATE (1<<5) #define O_DIRECTORY (1<<6) #define O_EXCL (1<<7) #define O_TRUNC (1<<8) diff --git a/sortix/initrd.cpp b/sortix/initrd.cpp index 7d1cd785..77c8fbee 100644 --- a/sortix/initrd.cpp +++ b/sortix/initrd.cpp @@ -289,7 +289,7 @@ static bool ExtractDir(ioctx_t* ctx, uint32_t ino, Ref dir) } if ( INITRD_S_ISREG(child->mode) ) { - Ref desc = dir->open(ctx, name, O_WRITE | O_CREAT, mode); + Ref desc = dir->open(ctx, name, O_WRITE | O_CREATE, mode); if ( !desc ) return false; if ( !ExtractNode(ctx, childino, desc) )