42 lines
771 B
C
42 lines
771 B
C
|
|
#include "file.h"
|
||
|
|
|
||
|
|
struct fs_inode *fs_file_get_inode(const struct fs_file *f)
|
||
|
|
{
|
||
|
|
return f->f_inode;
|
||
|
|
}
|
||
|
|
|
||
|
|
size_t fs_file_get_cursor(const struct fs_file *f)
|
||
|
|
{
|
||
|
|
return f->f_seek;
|
||
|
|
}
|
||
|
|
|
||
|
|
enum fs_status fs_file_read(
|
||
|
|
struct fs_file *f,
|
||
|
|
struct xpc_buffer *buf,
|
||
|
|
size_t count)
|
||
|
|
{
|
||
|
|
if (!f->f_ops || !f->f_ops->f_read) {
|
||
|
|
return FS_ERR_NOT_IMPLEMENTED;
|
||
|
|
}
|
||
|
|
|
||
|
|
off_t seek = f->f_seek;
|
||
|
|
enum fs_status status = f->f_ops->f_read(f, buf, count, &seek);
|
||
|
|
f->f_seek = seek;
|
||
|
|
return status;
|
||
|
|
}
|
||
|
|
|
||
|
|
enum fs_status fs_file_write(
|
||
|
|
struct fs_file *f,
|
||
|
|
struct xpc_buffer *buf,
|
||
|
|
size_t count)
|
||
|
|
{
|
||
|
|
if (!f->f_ops || !f->f_ops->f_write) {
|
||
|
|
return FS_ERR_NOT_IMPLEMENTED;
|
||
|
|
}
|
||
|
|
|
||
|
|
off_t seek = f->f_seek;
|
||
|
|
enum fs_status status = f->f_ops->f_write(f, buf, count, &seek);
|
||
|
|
f->f_seek = seek;
|
||
|
|
return status;
|
||
|
|
}
|