Commit 1aca2eaf authored by Marc Vef's avatar Marc Vef
Browse files

I/O fuse functions skeleton added

parent a2fa682a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -16,6 +16,6 @@ find_package(FUSE3 REQUIRED)
find_package(Boost 1.56.0 COMPONENTS system filesystem serialization)

include_directories(${FUSE3_INCLUDE_DIR} include/)
set(SOURCE_FILES src/main.cpp src/main.h src/fuse_ops.h src/util.cpp src/classes/metadata.h src/classes/metadata.cpp src/adafs_ops/metadata_ops.h src/adafs_ops/metadata_ops.cpp src/adafs_ops/dentry_ops.cpp src/adafs_ops/dentry_ops.h src/configure.h src/fuse_ops/file.cpp src/fuse_ops/directory.cpp src/fuse_ops/access.cpp src/fuse_ops/sync.cpp src/adafs_ops/access.cpp src/adafs_ops/access.h src/fuse_ops/fs.cpp)
set(SOURCE_FILES src/main.cpp src/main.h src/fuse_ops.h src/util.cpp src/classes/metadata.h src/classes/metadata.cpp src/adafs_ops/metadata_ops.h src/adafs_ops/metadata_ops.cpp src/adafs_ops/dentry_ops.cpp src/adafs_ops/dentry_ops.h src/configure.h src/fuse_ops/file.cpp src/fuse_ops/directory.cpp src/fuse_ops/access.cpp src/fuse_ops/sync.cpp src/adafs_ops/access.cpp src/adafs_ops/access.h src/fuse_ops/fs.cpp src/fuse_ops/io.cpp)
add_executable(adafs ${SOURCE_FILES} src/main.cpp)
target_link_libraries(adafs ${FUSE3_LIBRARIES} -lpthread -lboost_system -lboost_filesystem -lboost_serialization)
 No newline at end of file
+7 −9
Original line number Diff line number Diff line
@@ -9,27 +9,26 @@

// file
int adafs_getattr(const char* p, struct stat* attr, struct fuse_file_info* fi);

int adafs_mknod(const char* p, mode_t, dev_t);

int adafs_open(const char*, struct fuse_file_info* fi);

int adafs_unlink(const char* p);

int adafs_utimens(const char* p, const struct timespec tv[2], struct fuse_file_info* fi);

// directory
int adafs_opendir(const char* p, struct fuse_file_info* fi);

int adafs_readdir(const char* p, void* buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info* fi,
                  enum fuse_readdir_flags flags);

int adafs_releasedir(const char* p, struct fuse_file_info* fi);

int adafs_mkdir(const char* p, mode_t mode);

int adafs_rmdir(const char* p);

// I/O
int adafs_read(const char* p, char* buf, size_t size, off_t offset, struct fuse_file_info* fi);

int adafs_write(const char* p, const char* buf, size_t size, off_t offset, struct fuse_file_info* fi);

int adafs_truncate(const char* p, off_t offset, struct fuse_file_info* fi);

//
int adafs_flush(const char* p, struct fuse_file_info* fi);

@@ -41,7 +40,6 @@ int adafs_statfs(const char* p, struct statvfs* statvfs);


void* adafs_init(struct fuse_conn_info* conn, struct fuse_config* cfg);

void adafs_destroy(void* adafs_data);

#endif //FS_FUSE_OPS_H

fs/src/fuse_ops/io.cpp

0 → 100644
+53 −0
Original line number Diff line number Diff line
//
// Created by evie on 3/30/17.
//

#include "../main.h"
#include "../fuse_ops.h"

/** Read data from an open file
 *
 * Read should return exactly the number of bytes requested except
 * on EOF or error, otherwise the rest of the data will be
 * substituted with zeroes.	 An exception to this is when the
 * 'direct_io' mount option is specified, in which case the return
 * value of the read system call will reflect the return value of
 * this operation.
 */
int adafs_read(const char* p, char* buf, size_t size, off_t offset, struct fuse_file_info* fi) {
    ADAFS_DATA->logger->info("##### FUSE FUNC ###### adafs_read() enter: name '{}' buf {} size {} offset {}", p, buf,
                             size, offset);
    // TODO implement
    return 0;
}

/** Write data to an open file
 *
 * Write should return exactly the number of bytes requested
 * except on error.	 An exception to this is when the 'direct_io'
 * mount option is specified (see read operation).
 *
 * Unless FUSE_CAP_HANDLE_KILLPRIV is disabled, this method is
 * expected to reset the setuid and setgid bits.
 */
int adafs_write(const char* p, const char* buf, size_t size, off_t offset, struct fuse_file_info* fi) {
    ADAFS_DATA->logger->info("##### FUSE FUNC ###### adafs_write() enter: name '{}' buf {} size {} offset {}", p, buf,
                             size, offset);
    // TODO implement
    return 0;
}

/** Change the size of a file
 *
 * `fi` will always be NULL if the file is not currenly open, but
 * may also be NULL if the file is open.
 *
 * Unless FUSE_CAP_HANDLE_KILLPRIV is disabled, this method is
 * expected to reset the setuid and setgid bits.
 */
int adafs_truncate(const char* p, off_t offset, struct fuse_file_info* fi) {
    ADAFS_DATA->logger->info("##### FUSE FUNC ###### adafs_truncate() enter: name '{}' offset {}", p, offset);

    // TODO implement
    return 0;
}
 No newline at end of file
+5 −0
Original line number Diff line number Diff line
@@ -82,6 +82,11 @@ static void init_adafs_ops(fuse_operations* ops) {
    ops->mkdir = adafs_mkdir;
    ops->rmdir = adafs_rmdir;

    // I/O
    ops->read = adafs_read;
    ops->write = adafs_write;
    ops->truncate = adafs_truncate;

    ops->flush = adafs_flush;

    // access