UK_PROVIDED_SYSCALLS-$(CONFIG_LIBPOSIX_FDIO) += fsync-1
UK_PROVIDED_SYSCALLS-$(CONFIG_LIBPOSIX_FDIO) += fdatasync-1
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBPOSIX_FDIO) += ftruncate-2
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBPOSIX_FDIO) += fallocate-4
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBPOSIX_FDIO) += fadvise64-4
+
UK_PROVIDED_SYSCALLS-$(CONFIG_LIBPOSIX_FDIO) += fcntl-3
UK_PROVIDED_SYSCALLS-$(CONFIG_LIBPOSIX_FDIO) += ioctl-3
endif
return r;
}
+UK_SYSCALL_R_DEFINE(int, ftruncate, int, fd, off_t, len)
+{
+ int r;
+ union uk_shim_file sf;
+
+ switch (uk_fdtab_shim_get(fd, &sf)) {
+ case UK_SHIM_OFILE:
+ r = uk_sys_ftruncate(sf.ofile, len);
+ uk_fdtab_ret(sf.ofile);
+ break;
+#if CONFIG_LIBVFSCORE
+ case UK_SHIM_LEGACY:
+ /* vfscore_fallocate returns positive error codes */
+ r = -vfscore_ftruncate(sf.vfile, len);
+ fdrop(sf.vfile);
+ break;
+#endif /* CONFIG_LIBVFSCORE */
+ default:
+ r = -EBADF;
+ }
+ return r;
+}
+
+UK_SYSCALL_R_DEFINE(int, fallocate, int, fd, int, mode, off_t, off, off_t, len)
+{
+ int r;
+ union uk_shim_file sf;
+
+ switch (uk_fdtab_shim_get(fd, &sf)) {
+ case UK_SHIM_OFILE:
+ r = uk_sys_fallocate(sf.ofile, mode, off, len);
+ uk_fdtab_ret(sf.ofile);
+ break;
+#if CONFIG_LIBVFSCORE
+ case UK_SHIM_LEGACY:
+ /* vfscore_fallocate returns positive error codes */
+ r = -vfscore_fallocate(sf.vfile, mode, off, len);
+ fdrop(sf.vfile);
+ break;
+#endif /* CONFIG_LIBVFSCORE */
+ default:
+ r = -EBADF;
+ }
+ return r;
+}
+
+UK_SYSCALL_R_DEFINE(int, fadvise64,
+ int, fd, off_t, off, off_t, len, int, advice)
+{
+ int r;
+ union uk_shim_file sf;
+
+ switch (uk_fdtab_shim_get(fd, &sf)) {
+ case UK_SHIM_OFILE:
+ r = uk_sys_fadvise(sf.ofile, off, len, advice);
+ uk_fdtab_ret(sf.ofile);
+ break;
+#if CONFIG_LIBVFSCORE
+ case UK_SHIM_LEGACY:
+ /* vfscore does not support fadvise; stub out */
+ fdrop(sf.vfile);
+ r = 0;
+ break;
+#endif /* CONFIG_LIBVFSCORE */
+ default:
+ r = -EBADF;
+ }
+ return r;
+}
+
UK_LLSYSCALL_R_DEFINE(int, fcntl, int, fd,
unsigned int, cmd, unsigned long, arg)
{
UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += readlink-3
UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += link-2
-UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += ftruncate-2
UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += truncate-2
UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += access-2
UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += faccessat-4
-UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += fallocate-4
UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += chdir-1
UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += fchdir-1
UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += chmod-2
fhold
fdrop
fget
-ftruncate
-ftruncate64
-uk_syscall_e_ftruncate
-uk_syscall_r_ftruncate
stat
stat64
uk_syscall_e_stat
readlink
uk_syscall_e_readlink
uk_syscall_r_readlink
-fallocate
-fallocate64
-uk_syscall_e_fallocate
-uk_syscall_r_fallocate
lseek
lseek64
uk_syscall_e_lseek
vfscore_write
vfscore_lseek
vfscore_fsync
+vfscore_ftruncate
+vfscore_fallocate
vfscore_fstat
vfscore_fcntl
vfscore_ioctl
int vfscore_fsync(struct vfscore_file *fp);
+int vfscore_ftruncate(struct vfscore_file *fp, off_t length);
+int vfscore_fallocate(struct vfscore_file *fp, int mode, off_t off, off_t len);
+
int vfscore_fcntl(struct vfscore_file *fp, unsigned int cmd, unsigned long arg);
int vfscore_ioctl(struct vfscore_file *fp, unsigned long request, void *buf);
LFS64(truncate);
-UK_TRACEPOINT(trace_vfs_ftruncate, "%d %#x", int, off_t);
-UK_TRACEPOINT(trace_vfs_ftruncate_ret, "");
-UK_TRACEPOINT(trace_vfs_ftruncate_err, "%d", int);
-
-UK_SYSCALL_R_DEFINE(int, ftruncate, int, fd, off_t, length)
-{
- trace_vfs_ftruncate(fd, length);
- struct vfscore_file *fp;
- int error;
-
- error = fget(fd, &fp);
- if (error)
- goto out_error;
-
- error = sys_ftruncate(fp, length);
- fdrop(fp);
-
- if (error)
- goto out_error;
- trace_vfs_ftruncate_ret();
- return 0;
-
- out_error:
- trace_vfs_ftruncate_err(error);
- return -error;
-}
-
-#ifdef ftruncate64
-#undef ftruncate64
-#endif
-
-LFS64(ftruncate);
-
UK_SYSCALL_DEFINE(ssize_t, readlink, const char *, pathname, char *, buf, size_t, bufsize)
{
struct task *t = main_task;
return -1;
}
-UK_TRACEPOINT(trace_vfs_fallocate, "%d %d %#x %#x", int, int, loff_t, loff_t);
-UK_TRACEPOINT(trace_vfs_fallocate_ret, "");
-UK_TRACEPOINT(trace_vfs_fallocate_err, "%d", int);
-
-UK_SYSCALL_R_DEFINE(int, fallocate, int, fd, int, mode, loff_t, offset, loff_t, len)
-{
- struct vfscore_file *fp;
- int error;
-
- trace_vfs_fallocate(fd, mode, offset, len);
- error = fget(fd, &fp);
- if (error)
- goto out_error;
-
- error = sys_fallocate(fp, mode, offset, len);
- fdrop(fp);
-
- if (error)
- goto out_error;
- trace_vfs_fallocate_ret();
- return 0;
-
- out_error:
- trace_vfs_fallocate_err(error);
- return -error;
-}
-
-#ifdef fallocate64
-#undef fallocate64
-#endif
-
-LFS64(fallocate);
-
UK_TRACEPOINT(trace_vfs_utimes, "\"%s\"", const char*);
UK_TRACEPOINT(trace_vfs_utimes_ret, "");
UK_TRACEPOINT(trace_vfs_utimes_err, "%d", int);
}
int
-sys_ftruncate(struct vfscore_file *fp, off_t length)
+vfscore_ftruncate(struct vfscore_file *fp, off_t length)
{
struct vnode *vp;
int error;
}
int
-sys_fallocate(struct vfscore_file *fp, int mode, off_t offset, off_t len)
+vfscore_fallocate(struct vfscore_file *fp, int mode, off_t offset, off_t len)
{
int error;
struct vnode *vp;
*/
int sys_truncate(char *path, off_t length);
-/**
- * Similar to the sys_truncate() function, but it takes a vfscore_file
- * instead of path.
- *
- * @param fp
- * Pointer to the vfscore_file
- * @param length
- * The new size (in bytes) of the file to which fp is referring to
- * @return
- * - (0): Completed successfully
- * - (<0): Negative value with error code
- */
-int sys_ftruncate(struct vfscore_file *fp, off_t length);
-
/**
* Store at most bufsize bytes from the content to which the symlink
* at path is pointing in the char array buf. The number of bytes written
*/
int sys_futimens(int fd, const struct timespec times[2]);
-/**
- * Manipulates the file space for the file referred by fd, starting
- * at offset and continuing for len bytes.
- *
- * @param fp
- * Pointer to a vfscore_file structure
- * @param mode
- * Specifies how to manipulates the space. The mode can have the
- * the following values:
- * * 0 - allocates len bytes starting from offset.
- * * FALLOC_FL_KEEP_SIZE - the file size will not change even
- * if offset + len is greater than the file size.
- * * FALLOC_FL_PUNCH_HOLE - deallocates len bytes starting at
- * offset and creates a hole in the file. This flag should
- * always come together with FALLOC_FL_KEEP_SIZE, otherwise
- * the sys_futimens call will fail.
- * @param offset
- * Starting byte from which this operation will apply
- * @param len
- * Number of bytes for which this operation will apply
- * @return
- * - (0): Completed successfully
- * - (<0): Negative value with error code
- */
-int sys_fallocate(struct vfscore_file *fp, int mode, loff_t offset, loff_t len);
-
/**
* This function is not used at this point.
*/