Compare commits
2 Commits
43f90c4f88
...
2fbc6105d7
Author | SHA1 | Date | |
---|---|---|---|
2fbc6105d7 | |||
61f969c60c |
@ -8,8 +8,8 @@
|
|||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
StringView pathname;
|
StringView pathname;
|
||||||
bool show_all;
|
bool show_all { false };
|
||||||
bool show_almost_all;
|
bool show_almost_all { false };
|
||||||
|
|
||||||
ArgumentParser parser;
|
ArgumentParser parser;
|
||||||
parser.add_positional_argument(pathname, "directory"_sv, "/"_sv);
|
parser.add_positional_argument(pathname, "directory"_sv, "/"_sv);
|
||||||
|
@ -44,6 +44,8 @@ Result<u64> sys_open(Registers*, SyscallArgs args)
|
|||||||
if ((flags & O_WRONLY) && (inode->mode() & S_IWUSR) == 0) return err(EACCES);
|
if ((flags & O_WRONLY) && (inode->mode() & S_IWUSR) == 0) return err(EACCES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(inode->type() != VFS::InodeType::Directory && (flags & O_DIRECTORY)) return err(ENOTDIR);
|
||||||
|
|
||||||
if ((flags & O_WRONLY) && (flags & O_TRUNC)) inode->truncate(0);
|
if ((flags & O_WRONLY) && (flags & O_TRUNC)) inode->truncate(0);
|
||||||
|
|
||||||
int fd = TRY(current->allocate_fd(0));
|
int fd = TRY(current->allocate_fd(0));
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#define O_TRUNC 32
|
#define O_TRUNC 32
|
||||||
#define O_NONBLOCK 64
|
#define O_NONBLOCK 64
|
||||||
#define O_CLOEXEC 128
|
#define O_CLOEXEC 128
|
||||||
|
#define O_DIRECTORY 256
|
||||||
|
|
||||||
#define O_ACCMODE O_RDWR
|
#define O_ACCMODE O_RDWR
|
||||||
|
|
||||||
|
@ -13,8 +13,7 @@ extern "C"
|
|||||||
DIR* dp = (DIR*)malloc(sizeof(DIR));
|
DIR* dp = (DIR*)malloc(sizeof(DIR));
|
||||||
if (!dp) { return nullptr; }
|
if (!dp) { return nullptr; }
|
||||||
|
|
||||||
// FIXME: Use O_DIRECTORY (validate that path is actually a directory)
|
int fd = open(path, O_RDONLY | O_DIRECTORY);
|
||||||
int fd = open(path, O_RDONLY);
|
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
free(dp);
|
free(dp);
|
||||||
|
Loading…
Reference in New Issue
Block a user