/* * Virtual Filesystem Root * * Copyright (c) 2009-2019 * AVM GmbH, Berlin, Germany * * License: Free, use with no restriction. */ #ifndef AVMACL2_VIRTUAL_H #define AVMACL2_VIRTUAL_H #ifdef __cplusplus extern "C" { #endif /** * Set the real path of virtual "/" * @param real_root real file system path to virtual root directory * Use \p real_root value \c NULL to \c free(3) memory. */ void virtual_set_root(const char *real_root); /** * Change the real path to a virtual client path * @param [in,out] ppath virtual path as input and real path as output */ void virtual_make_from_real_path(char **ppath); FILE *virtual_fopen(const char *fn, const char *mode); int virtual_mkdir(const char *dir, mode_t mode); int virtual_rename(const char *from, const char *to); int virtual_stat(const char *path, struct stat *buf); int virtual_rmdir(const char *pathname); /** * @brief Remove a directory recursively. * Does not follow links. * On any error, \c errno will be set to \c EACCES or \c ENOTDIR. * * @param pathname Virtual path name. * * @retval 0 Success. * @retval -1 Not allowed to access directory, directory not existent or no directory. Nothing happend. * @retval -2 Failed to delete a file or directory. Some are still left, others may gone. */ int virtual_rmdir_recursive(const char *pathname); int virtual_unlink(const char *pathname); int virtual_chdir(const char *path); DIR *virtual_opendir(const char *name); int virtual_chmod(const char *path, mode_t mode); /** * change file last access and modification times * * @param path * @param actime * @param modtime * * @return 0 on success else failure, @c errno will be set */ int virtual_utime(const char *path, time_t actime, time_t modtime); /** * Check if write access is allowed to the given file system path \p path. * Set \c errno to \c EACCES if access is not allowed. * * @param path virtual file system path * @param [out] preal_path real file system path * * @retval 1 if write access is given to \p path * @retval 0 if no write access is given to \p path */ int virtual_is_write_access(const char *path, /*OUT*/char **preal_path); /** * Check if read access is allowed to the given file system path \p path. * Set \c errno to \c EACCES if access is not allowed. * * @param path virtual file system path * @param [out] preal_path real file system path * * @retval 1 if read access is given to \p path * @retval 0 if no read access is given to \p path */ int virtual_is_read_access(const char *path, /*OUT*/char **preal_path); #if defined(COMPILE_HOSTTOOLS) /** * @brief Cleanup temporary strings. * Needed for module tests with memory checks. */ void virtual_freetmpstring(void); #endif #ifdef __cplusplus } #endif #endif /* !AVMACL2_VIRTUAL_H */