1.1 --- a/lib/src/fsdesc_client.c Sun Apr 05 23:49:39 2020 +0200
1.2 +++ b/lib/src/fsdesc_client.c Wed Apr 15 23:45:55 2020 +0200
1.3 @@ -34,6 +34,7 @@
1.4 #include "fsdesc_client.h"
1.5 #include "fsops.h"
1.6
1.7 +#include <ipc/mem_ipc.h> /* ipc_dataspace functions */
1.8 #include <systypes/user.h>
1.9 #include <systypes/stat.h>
1.10
1.11 @@ -126,8 +127,29 @@
1.12 long
1.13 fs_fstat(file_descriptor_t *desc, struct stat *statbuf)
1.14 {
1.15 - sys_stat_t st;
1.16 - long err = File_fstat((ref_File) desc->ref, &st);
1.17 + size_t size;
1.18 + l4_cap_idx_t statcap;
1.19 + sys_stat_t *buffer;
1.20 + unsigned long buffer_size;
1.21 +
1.22 + /* Request the metadata. */
1.23 +
1.24 + long err = File_fstat((ref_File) desc->ref, &size, &statcap);
1.25 +
1.26 + if (err)
1.27 + return err;
1.28 +
1.29 + if (size != sizeof(sys_stat_t))
1.30 + return -L4_EIO;
1.31 +
1.32 + /* Access the returned capability as a dataspace. */
1.33 +
1.34 + err = ipc_dataspace_size(statcap, &buffer_size);
1.35 +
1.36 + if (err)
1.37 + return err;
1.38 +
1.39 + err = ipc_attach_dataspace(statcap, buffer_size, (void **) &buffer);
1.40
1.41 if (err)
1.42 return err;
1.43 @@ -135,21 +157,25 @@
1.44 /* Read the data from the message. */
1.45 /* Convert the neutral representation to struct stat. */
1.46
1.47 - statbuf->st_dev = st.st_dev;
1.48 - statbuf->st_ino = st.st_ino;
1.49 - statbuf->st_mode = st.st_mode;
1.50 - statbuf->st_nlink = st.st_nlink;
1.51 - statbuf->st_uid = st.st_uid;
1.52 - statbuf->st_gid = st.st_gid;
1.53 - statbuf->st_rdev = st.st_rdev;
1.54 - statbuf->st_size = st.st_size;
1.55 - statbuf->st_atim.tv_sec = st.st_atim.tv_sec;
1.56 - statbuf->st_atim.tv_nsec = st.st_atim.tv_nsec;
1.57 - statbuf->st_mtim.tv_sec = st.st_mtim.tv_sec;
1.58 - statbuf->st_mtim.tv_nsec = st.st_mtim.tv_nsec;
1.59 - statbuf->st_ctim.tv_sec = st.st_ctim.tv_sec;
1.60 - statbuf->st_ctim.tv_nsec = st.st_ctim.tv_nsec;
1.61 - statbuf->st_blksize = st.st_blksize;
1.62 + statbuf->st_dev = buffer->st_dev;
1.63 + statbuf->st_ino = buffer->st_ino;
1.64 + statbuf->st_mode = buffer->st_mode;
1.65 + statbuf->st_nlink = buffer->st_nlink;
1.66 + statbuf->st_uid = buffer->st_uid;
1.67 + statbuf->st_gid = buffer->st_gid;
1.68 + statbuf->st_rdev = buffer->st_rdev;
1.69 + statbuf->st_size = buffer->st_size;
1.70 + statbuf->st_atim.tv_sec = buffer->st_atim.tv_sec;
1.71 + statbuf->st_atim.tv_nsec = buffer->st_atim.tv_nsec;
1.72 + statbuf->st_mtim.tv_sec = buffer->st_mtim.tv_sec;
1.73 + statbuf->st_mtim.tv_nsec = buffer->st_mtim.tv_nsec;
1.74 + statbuf->st_ctim.tv_sec = buffer->st_ctim.tv_sec;
1.75 + statbuf->st_ctim.tv_nsec = buffer->st_ctim.tv_nsec;
1.76 + statbuf->st_blksize = buffer->st_blksize;
1.77 +
1.78 + /* Release the dataspace. */
1.79 +
1.80 + ipc_detach_dataspace(buffer);
1.81
1.82 return L4_EOK;
1.83 }