lx_fs: handle errors on mkdir correctly

Fixes #2444
This commit is contained in:
Christian Prochaska 2017-06-12 16:02:11 +02:00 committed by Christian Helmuth
parent c8e4d2715b
commit a1b1525ec1
3 changed files with 18 additions and 10 deletions

View File

@ -31,7 +31,8 @@ install_config {
<default-route> <default-route>
<any-service> <parent/> <any-child/> </any-service> <any-service> <parent/> <any-child/> </any-service>
</default-route> </default-route>
<start name="lx_fs"> <default caps="100"/>
<start name="lx_fs" caps="200">
<resource name="RAM" quantum="4M"/> <resource name="RAM" quantum="4M"/>
<provides> <service name="File_system"/> </provides> <provides> <service name="File_system"/> </provides>
<config> <policy label_prefix="test-libc_vfs" root="/libc_vfs" writeable="yes" /> </config> <config> <policy label_prefix="test-libc_vfs" root="/libc_vfs" writeable="yes" /> </config>
@ -39,12 +40,11 @@ install_config {
<start name="test-libc_vfs"> <start name="test-libc_vfs">
<resource name="RAM" quantum="2M"/> <resource name="RAM" quantum="2M"/>
<config> <config>
<libc stdout="/dev/log"> <vfs>
<vfs> <fs />
<fs /> <dir name="dev"> <log/> </dir>
<dir name="dev"> <log/> </dir> </vfs>
</vfs> <libc stdout="/dev/log"/>
</libc>
</config> </config>
</start> </start>
</config> </config>

View File

@ -120,7 +120,7 @@ static void test(Genode::Xml_node node)
CALL_AND_CHECK(ret, mkdir(dir_name, 0777), ((ret == 0) || (errno == EEXIST)), "dir_name=%s", dir_name); CALL_AND_CHECK(ret, mkdir(dir_name, 0777), ((ret == 0) || (errno == EEXIST)), "dir_name=%s", dir_name);
/* try to create again */ /* try to create again */
CALL_AND_CHECK(ret, mkdir(dir_name, 0777), ((ret == 0) || (errno == EEXIST)), "dir_name=%s", dir_name); CALL_AND_CHECK(ret, mkdir(dir_name, 0777), (errno == EEXIST), "dir_name=%s", dir_name);
/* change to new directory */ /* change to new directory */
CALL_AND_CHECK(ret, chdir(dir_name), ret == 0, "dir_name=%s", dir_name); CALL_AND_CHECK(ret, chdir(dir_name), ret == 0, "dir_name=%s", dir_name);

View File

@ -42,8 +42,16 @@ class File_system::Directory : public Node
if (create) { if (create) {
mode_t ugo = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; mode_t ugo = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
ret = mkdir(path, ugo); ret = mkdir(path, ugo);
if (ret == -1) if (ret == -1) {
throw No_space(); switch (errno) {
case ENAMETOOLONG: throw Name_too_long();
case EACCES: throw Permission_denied();
case ENOENT: throw Lookup_failed();
case EEXIST: throw Node_already_exists();
case ENOSPC:
default: throw No_space();
}
}
} }
struct stat s; struct stat s;