mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-08 20:05:54 +00:00
rump_fs/fuse_fs/lx_fs/ram_fs: symlink fixup
Allow symlinks to be passed to the read and write file system utilities. Disallow writes to symlinks with offsets in file system servers, this is to ensure that writing the target of a symlink is an atomic operation. Fixes #1604
This commit is contained in:
parent
b60f28bee9
commit
2f1db06deb
@ -49,7 +49,8 @@ class File_system::Symlink : public Node
|
||||
|
||||
size_t write(char const *src, size_t len, seek_off_t seek_offset)
|
||||
{
|
||||
if (!_create)
|
||||
/* Ideal symlink operations are atomic. */
|
||||
if (!_create || seek_offset)
|
||||
return 0;
|
||||
|
||||
int ret = rump_sys_symlink(src, _path.base());
|
||||
|
@ -70,6 +70,9 @@ class File_system::Symlink : public Node
|
||||
|
||||
size_t write(char const *src, size_t len, seek_off_t seek_offset)
|
||||
{
|
||||
/* Ideal symlink operations are atomic. */
|
||||
if (seek_offset) return 0;
|
||||
|
||||
int res = Fuse::fuse()->op.symlink(src, _path.base());
|
||||
if (res != 0)
|
||||
return 0;
|
||||
|
@ -103,7 +103,7 @@ namespace File_system {
|
||||
/**
|
||||
* Read file content
|
||||
*/
|
||||
static inline size_t read(Session &fs, File_handle const &file_handle,
|
||||
static inline size_t read(Session &fs, Node_handle const &node_handle,
|
||||
void *dst, size_t count, seek_off_t seek_offset = 0)
|
||||
{
|
||||
bool success = true;
|
||||
@ -122,7 +122,7 @@ namespace File_system {
|
||||
Packet_descriptor
|
||||
packet(source.alloc_packet(curr_packet_size),
|
||||
0,
|
||||
file_handle,
|
||||
node_handle,
|
||||
File_system::Packet_descriptor::READ,
|
||||
curr_packet_size,
|
||||
seek_offset);
|
||||
@ -160,7 +160,7 @@ namespace File_system {
|
||||
/**
|
||||
* Write file content
|
||||
*/
|
||||
static inline size_t write(Session &fs, File_handle const &file_handle,
|
||||
static inline size_t write(Session &fs, Node_handle const &node_handle,
|
||||
void const *src, size_t count, seek_off_t seek_offset = 0)
|
||||
{
|
||||
bool success = true;
|
||||
@ -179,7 +179,7 @@ namespace File_system {
|
||||
Packet_descriptor
|
||||
packet(source.alloc_packet(curr_packet_size),
|
||||
0,
|
||||
file_handle,
|
||||
node_handle,
|
||||
File_system::Packet_descriptor::WRITE,
|
||||
curr_packet_size,
|
||||
seek_offset);
|
||||
|
@ -39,6 +39,9 @@ class File_system::Symlink : public Node
|
||||
|
||||
size_t write(char const *src, size_t len, seek_off_t seek_offset)
|
||||
{
|
||||
/* Ideal symlink operations are atomic. */
|
||||
if (seek_offset) return 0;
|
||||
|
||||
size_t count = min(len, sizeof(_link_to) + 1);
|
||||
Genode::strncpy(_link_to, src, count);
|
||||
return count;
|
||||
|
@ -31,6 +31,9 @@ namespace File_system {
|
||||
|
||||
size_t write(char const *src, size_t len, seek_off_t seek_offset)
|
||||
{
|
||||
/* Ideal symlink operations are atomic. */
|
||||
if (seek_offset) return 0;
|
||||
|
||||
size_t count = min(len, sizeof(_link_to) + 1);
|
||||
Genode::strncpy(_link_to, src, count);
|
||||
return count;
|
||||
|
Loading…
x
Reference in New Issue
Block a user