Skip to content

Commit

Permalink
Move realfs functions to fs/real.h
Browse files Browse the repository at this point in the history
  • Loading branch information
tbodt committed Apr 12, 2020
1 parent 1452a7f commit a3e0e9f
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 50 deletions.
1 change: 1 addition & 0 deletions app/iOSFS.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "kernel/fs.h"
#include "kernel/errno.h"
#include "fs/path.h"
#include "fs/real.h"

const NSFileCoordinatorWritingOptions NSFileCoordinatorWritingForCreating = NSFileCoordinatorWritingForMerging;

Expand Down
1 change: 1 addition & 0 deletions fs/fake.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "fs/fd.h"
#include "fs/dev.h"
#include "fs/inode.h"
#include "fs/real.h"
#define ISH_INTERNAL
#include "fs/fake.h"

Expand Down
1 change: 1 addition & 0 deletions fs/mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "kernel/calls.h"
#include "kernel/fs.h"
#include "fs/path.h"
#include "fs/real.h"

#define MAX_FILESYSTEMS 10
static const struct fs_ops *filesystems[MAX_FILESYSTEMS] = {
Expand Down
1 change: 1 addition & 0 deletions fs/pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <unistd.h>
#include "kernel/calls.h"
#include "fs/fd.h"
#include "fs/real.h"
#include "debug.h"

static fd_t pipe_f_create(int pipe_fd, int flags) {
Expand Down
1 change: 1 addition & 0 deletions fs/poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "kernel/fs.h"
#include "fs/fd.h"
#include "fs/poll.h"
#include "fs/real.h"

#include "fs/sockrestart.h"

Expand Down
1 change: 1 addition & 0 deletions fs/real.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "kernel/calls.h"
#include "kernel/fs.h"
#include "fs/dev.h"
#include "fs/real.h"
#include "fs/tty.h"

static int getpath(int fd, char *buf) {
Expand Down
52 changes: 52 additions & 0 deletions fs/real.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#ifndef FS_REAL_H
#define FS_REAL_H

#include "kernel/fs.h"

extern const struct fd_ops realfs_fdops;
extern const struct fs_ops realfs;

struct fd *realfs_open_with_fdops(struct mount *mount, const char *path, int flags, int mode, const struct fd_ops *fdops);
struct fd *realfs_open(struct mount *mount, const char *path, int flags, int mode);

ssize_t realfs_readlink(struct mount *mount, const char *path, char *buf, size_t bufsize);
int realfs_link(struct mount *mount, const char *src, const char *dst);
int realfs_unlink(struct mount *mount, const char *path);
int realfs_rmdir(struct mount *mount, const char *path);
int realfs_rename(struct mount *mount, const char *src, const char *dst);
int realfs_symlink(struct mount *mount, const char *target, const char *link);
int realfs_mknod(struct mount *mount, const char *path, mode_t_ mode, dev_t_ UNUSED(dev));

int realfs_stat(struct mount *mount, const char *path, struct statbuf *fake_stat);
int realfs_statfs(struct mount *mount, struct statfsbuf *stat);
int realfs_fstat(struct fd *fd, struct statbuf *fake_stat);
int realfs_setattr(struct mount *mount, const char *path, struct attr attr);
int realfs_fsetattr(struct fd *fd, struct attr attr);

int realfs_mkdir(struct mount *mount, const char *path, mode_t_ mode);

int realfs_truncate(struct mount *mount, const char *path, off_t_ size);
int realfs_utime(struct mount *mount, const char *path, struct timespec atime, struct timespec mtime);

int realfs_statfs(struct mount *mount, struct statfsbuf *stat);
int realfs_flock(struct fd *fd, int operation);
int realfs_getpath(struct fd *fd, char *buf);
ssize_t realfs_read(struct fd *fd, void *buf, size_t bufsize);
ssize_t realfs_write(struct fd *fd, const void *buf, size_t bufsize);

int realfs_readdir(struct fd *fd, struct dir_entry *entry);
unsigned long realfs_telldir(struct fd *fd);
void realfs_seekdir(struct fd *fd, unsigned long ptr);

off_t realfs_lseek(struct fd *fd, off_t offset, int whence);

int realfs_poll(struct fd *fd);
int realfs_mmap(struct fd *fd, struct mem *mem, page_t start, pages_t pages, off_t offset, int prot, int flags);
int realfs_fsync(struct fd *fd);
int realfs_getflags(struct fd *fd);
int realfs_setflags(struct fd *fd, dword_t arg);
ssize_t realfs_ioctl_size(int cmd);
int realfs_ioctl(struct fd *fd, int cmd, void *arg);
int realfs_close(struct fd *fd);

#endif
1 change: 1 addition & 0 deletions fs/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "fs/fd.h"
#include "fs/inode.h"
#include "fs/path.h"
#include "fs/real.h"
#include "fs/sock.h"
#include "debug.h"

Expand Down
47 changes: 0 additions & 47 deletions kernel/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,57 +176,10 @@ struct fs_ops {
struct mount *find_mount_and_trim_path(char *path);
const char *fix_path(const char *path); // TODO reconsider

// real fs
extern const struct fd_ops realfs_fdops;

struct fd *realfs_open_with_fdops(struct mount *mount, const char *path, int flags, int mode, const struct fd_ops *fdops);
struct fd *realfs_open(struct mount *mount, const char *path, int flags, int mode);

ssize_t realfs_readlink(struct mount *mount, const char *path, char *buf, size_t bufsize);
int realfs_link(struct mount *mount, const char *src, const char *dst);
int realfs_unlink(struct mount *mount, const char *path);
int realfs_rmdir(struct mount *mount, const char *path);
int realfs_rename(struct mount *mount, const char *src, const char *dst);
int realfs_symlink(struct mount *mount, const char *target, const char *link);
int realfs_mknod(struct mount *mount, const char *path, mode_t_ mode, dev_t_ UNUSED(dev));

int realfs_stat(struct mount *mount, const char *path, struct statbuf *fake_stat);
int realfs_statfs(struct mount *mount, struct statfsbuf *stat);
int realfs_fstat(struct fd *fd, struct statbuf *fake_stat);
int realfs_setattr(struct mount *mount, const char *path, struct attr attr);
int realfs_fsetattr(struct fd *fd, struct attr attr);

int realfs_mkdir(struct mount *mount, const char *path, mode_t_ mode);

int realfs_truncate(struct mount *mount, const char *path, off_t_ size);
int realfs_utime(struct mount *mount, const char *path, struct timespec atime, struct timespec mtime);

int realfs_statfs(struct mount *mount, struct statfsbuf *stat);
int realfs_flock(struct fd *fd, int operation);
int realfs_getpath(struct fd *fd, char *buf);
ssize_t realfs_read(struct fd *fd, void *buf, size_t bufsize);
ssize_t realfs_write(struct fd *fd, const void *buf, size_t bufsize);

int realfs_readdir(struct fd *fd, struct dir_entry *entry);
unsigned long realfs_telldir(struct fd *fd);
void realfs_seekdir(struct fd *fd, unsigned long ptr);

off_t realfs_lseek(struct fd *fd, off_t offset, int whence);

int realfs_poll(struct fd *fd);
int realfs_mmap(struct fd *fd, struct mem *mem, page_t start, pages_t pages, off_t offset, int prot, int flags);
int realfs_fsync(struct fd *fd);
int realfs_getflags(struct fd *fd);
int realfs_setflags(struct fd *fd, dword_t arg);
ssize_t realfs_ioctl_size(int cmd);
int realfs_ioctl(struct fd *fd, int cmd, void *arg);
int realfs_close(struct fd *fd);

// adhoc fs
struct fd *adhoc_fd_create(const struct fd_ops *ops);

// filesystems
extern const struct fs_ops realfs;
extern const struct fs_ops procfs;
extern const struct fs_ops fakefs;
extern const struct fs_ops devptsfs;
Expand Down
7 changes: 4 additions & 3 deletions kernel/init.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#include <signal.h>
#include <string.h>
#include <sys/stat.h>
#include "kernel/init.h"
#include "kernel/calls.h"
#include "fs/devices.h"
#include "fs/fd.h"
#include "fs/real.h"
#include "fs/tty.h"
#include "fs/devices.h"
#include "kernel/calls.h"
#include "kernel/init.h"

int mount_root(const struct fs_ops *fs, const char *source) {
char source_realpath[MAX_PATH + 1];
Expand Down
1 change: 1 addition & 0 deletions xX_main_Xx.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "kernel/init.h"
#include "kernel/fs.h"
#include "fs/devices.h"
#include "fs/real.h"
#ifdef __APPLE__
#include <sys/resource.h>
#define IOPOL_TYPE_VFS_HFS_CASE_SENSITIVITY 1
Expand Down

0 comments on commit a3e0e9f

Please sign in to comment.