diff -r 21274e5950af -r a1f4cb076d2f src/server/public/vfs.h --- a/src/server/public/vfs.h Tue Aug 13 22:14:32 2019 +0200 +++ b/src/server/public/vfs.h Sat Sep 24 16:26:10 2022 +0200 @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright 2013 Olaf Wintermann. All rights reserved. + * Copyright 2018 Olaf Wintermann. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -48,13 +48,16 @@ #define VFS_ENTRY VFSEntry struct VFS { - SYS_FILE (*open)(VFSContext *ctx, char *path, int oflags); - int (*stat)(VFSContext *ctx, char *path, struct stat *buf); + SYS_FILE (*open)(VFSContext *ctx, const char *path, int oflags); + int (*stat)(VFSContext *ctx, const char *path, struct stat *buf); int (*fstat)(VFSContext *ctx, SYS_FILE fd, struct stat *buf); - VFS_DIR (*opendir)(VFSContext *ctx, char *path); - int (*mkdir)(VFSContext *ctx, char *path); - int (*unlink)(VFSContext *ctx, char *path); + VFS_DIR (*opendir)(VFSContext *ctx, const char *path); + VFS_DIR (*fdopendir)(VFSContext *ctx, SYS_FILE fd); + int (*mkdir)(VFSContext *ctx, const char *path); + int (*unlink)(VFSContext *ctx, const char *path); + int (*rmdir)(VFSContext *Ctx, const char *path); uint32_t flags; + void *instance; }; struct VFSContext { @@ -66,20 +69,21 @@ ACLListHandle *acllist; uint32_t aclreqaccess; int vfs_errno; + WSBool error_response_set; }; struct VFSFile { VFSContext *ctx; - VFS_IO *io; // IO functions - void *data; // private data used by the VFSFile implementation - int fd; // native file descriptor if available, or -1 + VFS_IO *io; /* IO functions */ + void *data; /* private data used by the VFSFile implementation */ + int fd; /* native file descriptor if available, or -1 */ }; struct VFSDir { VFSContext *ctx; VFS_DIRIO *io; - void *data; // private data used by the VFSDir implementation - int fd; // native file descriptor if available, or -1 + void *data; /* private data used by the VFSDir implementation */ + int fd; /* native file descriptor if available, or -1 */ }; struct VFSEntry { @@ -98,6 +102,7 @@ void (*close)(SYS_FILE fd); int (*opt_aioread)(aiocb_s *aiocb); int (*opt_aiowrite)(aiocb_s *aiocb); + const char* (*opt_getetag)(SYS_FILE fd); }; struct VFS_DIRIO { @@ -105,10 +110,18 @@ void (*close)(VFS_DIR dir); }; +typedef void*(*vfs_init_func)(ServerConfiguration *cfg, pool_handle_t *pool, WSConfigNode *config); +typedef VFS*(*vfs_create_func)(Session *sn, Request *rq, pblock *pb, void *initData); + /* * registers a new VFS */ -void vfs_add(char *name, VFS *vfs); +int vfs_register_type(const char *name, vfs_init_func vfsInit, vfs_create_func vfsCreate); + +/* + * Create a new VFS instance + */ +VFS* vfs_create(Session *sn, Request *rq, const char *vfs_class, pblock *pb, void *initData); /* * creates a VFSContext for a Request @@ -116,19 +129,22 @@ */ VFSContext* vfs_request_context(Session *sn, Request *rq); -SYS_FILE vfs_open(VFSContext *ctx, char *path, int oflags); -SYS_FILE vfs_openRO(VFSContext *ctx, char *path); -SYS_FILE vfs_openWO(VFSContext *ctx, char *path); -SYS_FILE vfs_openRW(VFSContext *ctx, char *path); -int vfs_stat(VFSContext *ctx, char *path, struct stat *buf); +SYS_FILE vfs_open(VFSContext *ctx, const char *path, int oflags); +SYS_FILE vfs_openRO(VFSContext *ctx, const char *path); +SYS_FILE vfs_openWO(VFSContext *ctx, const char *path); +SYS_FILE vfs_openRW(VFSContext *ctx, const char *path); +int vfs_stat(VFSContext *ctx, const char *path, struct stat *buf); int vfs_fstat(VFSContext *ctx, SYS_FILE fd, struct stat *buf); +const char * vfs_getetag(SYS_FILE fd); void vfs_close(SYS_FILE fd); -VFS_DIR vfs_opendir(VFSContext *ctx, char *path); +VFS_DIR vfs_opendir(VFSContext *ctx, const char *path); +VFS_DIR vfs_fdopendir(VFSContext *ctx, SYS_FILE fd); int vfs_readdir(VFS_DIR dir, VFS_ENTRY *entry); int vfs_readdir_stat(VFS_DIR dir, VFS_ENTRY *entry); void vfs_closedir(VFS_DIR dir); -int vfs_mkdir(VFSContext *ctx, char *path); -int vfs_unlink(VFSContext *ctx, char *path); +int vfs_mkdir(VFSContext *ctx, const char *path); +int vfs_unlink(VFSContext *ctx, const char *path); +int vfs_rmdir(VFSContext *ctx, const char *path); #ifdef __cplusplus }