Kernel, libc: Add O_EXCL
This commit is contained in:
parent
211c76f920
commit
9b0f6b6595
@ -21,6 +21,7 @@
|
|||||||
#define OPEN_TRUNCATED 32
|
#define OPEN_TRUNCATED 32
|
||||||
#define OPEN_CREATE 64
|
#define OPEN_CREATE 64
|
||||||
#define OPEN_APPEND 128
|
#define OPEN_APPEND 128
|
||||||
|
#define OPEN_EXCL 256
|
||||||
|
|
||||||
#define SEEK_SET 0
|
#define SEEK_SET 0
|
||||||
#define SEEK_CUR 1
|
#define SEEK_CUR 1
|
||||||
@ -164,6 +165,17 @@ void sys_open(Context* context, const char* filename, int flags, mode_t) // FIXM
|
|||||||
context->rax = -ENOENT;
|
context->rax = -ENOENT;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bool excl = (flags & OPEN_EXCL) > 0;
|
||||||
|
|
||||||
|
if (excl)
|
||||||
|
{
|
||||||
|
kfree(kfilename);
|
||||||
|
context->rax = -EEXIST;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool can_read = (flags & OPEN_READ) > 0;
|
bool can_read = (flags & OPEN_READ) > 0;
|
||||||
bool can_write = (flags & OPEN_WRITE) > 0;
|
bool can_write = (flags & OPEN_WRITE) > 0;
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
#define O_CREAT 64
|
#define O_CREAT 64
|
||||||
/* Open the file for appending. */
|
/* Open the file for appending. */
|
||||||
#define O_APPEND 128
|
#define O_APPEND 128
|
||||||
|
/* Fail to open the file if it already exists. */
|
||||||
|
#define O_EXCL 256
|
||||||
|
|
||||||
/* Duplicate a file descriptor. */
|
/* Duplicate a file descriptor. */
|
||||||
#define F_DUPFD 0
|
#define F_DUPFD 0
|
||||||
|
Loading…
Reference in New Issue
Block a user