1 /* |
1 /* |
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
3 * |
3 * |
4 * Copyright 2013 Olaf Wintermann. All rights reserved. |
4 * Copyright 2018 Olaf Wintermann. All rights reserved. |
5 * |
5 * |
6 * Redistribution and use in source and binary forms, with or without |
6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions are met: |
7 * modification, are permitted provided that the following conditions are met: |
8 * |
8 * |
9 * 1. Redistributions of source code must retain the above copyright |
9 * 1. Redistributions of source code must retain the above copyright |
50 struct VFS { |
50 struct VFS { |
51 SYS_FILE (*open)(VFSContext *ctx, char *path, int oflags); |
51 SYS_FILE (*open)(VFSContext *ctx, char *path, int oflags); |
52 int (*stat)(VFSContext *ctx, char *path, struct stat *buf); |
52 int (*stat)(VFSContext *ctx, char *path, struct stat *buf); |
53 int (*fstat)(VFSContext *ctx, SYS_FILE fd, struct stat *buf); |
53 int (*fstat)(VFSContext *ctx, SYS_FILE fd, struct stat *buf); |
54 VFS_DIR (*opendir)(VFSContext *ctx, char *path); |
54 VFS_DIR (*opendir)(VFSContext *ctx, char *path); |
|
55 VFS_DIR (*fdopendir)(VFSContext *ctx, SYS_FILE fd); |
55 int (*mkdir)(VFSContext *ctx, char *path); |
56 int (*mkdir)(VFSContext *ctx, char *path); |
56 int (*unlink)(VFSContext *ctx, char *path); |
57 int (*unlink)(VFSContext *ctx, char *path); |
57 uint32_t flags; |
58 uint32_t flags; |
|
59 void *instance; |
58 }; |
60 }; |
59 |
61 |
60 struct VFSContext { |
62 struct VFSContext { |
61 pool_handle_t *pool; |
63 pool_handle_t *pool; |
62 Session *sn; |
64 Session *sn; |
68 int vfs_errno; |
70 int vfs_errno; |
69 }; |
71 }; |
70 |
72 |
71 struct VFSFile { |
73 struct VFSFile { |
72 VFSContext *ctx; |
74 VFSContext *ctx; |
73 VFS_IO *io; // IO functions |
75 VFS_IO *io; /* IO functions */ |
74 void *data; // private data used by the VFSFile implementation |
76 void *data; /* private data used by the VFSFile implementation */ |
75 int fd; // native file descriptor if available, or -1 |
77 int fd; /* native file descriptor if available, or -1 */ |
76 }; |
78 }; |
77 |
79 |
78 struct VFSDir { |
80 struct VFSDir { |
79 VFSContext *ctx; |
81 VFSContext *ctx; |
80 VFS_DIRIO *io; |
82 VFS_DIRIO *io; |
81 void *data; // private data used by the VFSDir implementation |
83 void *data; /* private data used by the VFSDir implementation */ |
82 int fd; // native file descriptor if available, or -1 |
84 int fd; /* native file descriptor if available, or -1 */ |
83 }; |
85 }; |
84 |
86 |
85 struct VFSEntry { |
87 struct VFSEntry { |
86 char *name; |
88 char *name; |
87 struct stat stat; |
89 struct stat stat; |
122 SYS_FILE vfs_openRW(VFSContext *ctx, char *path); |
124 SYS_FILE vfs_openRW(VFSContext *ctx, char *path); |
123 int vfs_stat(VFSContext *ctx, char *path, struct stat *buf); |
125 int vfs_stat(VFSContext *ctx, char *path, struct stat *buf); |
124 int vfs_fstat(VFSContext *ctx, SYS_FILE fd, struct stat *buf); |
126 int vfs_fstat(VFSContext *ctx, SYS_FILE fd, struct stat *buf); |
125 void vfs_close(SYS_FILE fd); |
127 void vfs_close(SYS_FILE fd); |
126 VFS_DIR vfs_opendir(VFSContext *ctx, char *path); |
128 VFS_DIR vfs_opendir(VFSContext *ctx, char *path); |
|
129 VFS_DIR vfs_fdopendir(VFSContext *ctx, SYS_FILE fd); |
127 int vfs_readdir(VFS_DIR dir, VFS_ENTRY *entry); |
130 int vfs_readdir(VFS_DIR dir, VFS_ENTRY *entry); |
128 int vfs_readdir_stat(VFS_DIR dir, VFS_ENTRY *entry); |
131 int vfs_readdir_stat(VFS_DIR dir, VFS_ENTRY *entry); |
129 void vfs_closedir(VFS_DIR dir); |
132 void vfs_closedir(VFS_DIR dir); |
130 int vfs_mkdir(VFSContext *ctx, char *path); |
133 int vfs_mkdir(VFSContext *ctx, char *path); |
131 int vfs_unlink(VFSContext *ctx, char *path); |
134 int vfs_unlink(VFSContext *ctx, char *path); |