Commit f913614b authored by Julius Athenstaedt's avatar Julius Athenstaedt Committed by Ramon Nou
Browse files

cleanup and refactoring, fix lookup_count

parent 054fbcfe
Loading
Loading
Loading
Loading
+25 −64
Original line number Diff line number Diff line
@@ -97,6 +97,31 @@ struct __dirstream {
#include <client/preload_context.hpp>
#include <client/user_functions.hpp>

// TODO do we really need the stat here? no i dont think so
struct Inode {
    std::string path;
    struct stat st;
    uint64_t lookup_count;
};

enum {
    CACHE_NEVER,
    CACHE_NORMAL,
    CACHE_ALWAYS,
};

struct u_data {
    pthread_mutex_t mutex;
    int debug;
    int writeback;
    int flock;
    int xattr;
    char* source;
    double timeout;
    int cache;
    int timeout_set;
};

struct GkfsDir { // Hypothetical structure that might be used if DIR is cast
    int fd;
    long int tell_pos; // for telldir/seekdir
@@ -104,68 +129,4 @@ struct GkfsDir { // Hypothetical structure that might be used if DIR is cast
    // other members libc DIR might have
};

/*
 * Creates files on the underlying file system in response to a FUSE_MKNOD
 * operation
 */
static inline int
mknod_wrapper(int dirfd, const char* path, const char* link, int mode,
              dev_t rdev) {
    fuse_log(FUSE_LOG_DEBUG, "mknod_wrapper \n");
    int res = -1;

    if(S_ISREG(mode)) {
        // res = lol_openat(dirfd, path, mode, O_CREAT | O_EXCL | O_WRONLY);
        fuse_log(FUSE_LOG_DEBUG, "lol_openat internal %s\n", res);
        if(res >= 0)
            res = gkfs::syscall::gkfs_close(res);
    } else if(S_ISDIR(mode)) {
        // GKFS_PATH_OPERATION(create, dirfd, path, mode | S_IFDIR)
        //  res = gkfs::syscall::gkfs_create(resolved, mode | S_IFDIR);
        //   res = mkdirat(dirfd, path, mode);
    } else if(S_ISLNK(mode) && link != NULL) {
        fuse_log(FUSE_LOG_ERR, "fifo in mknod_wrapper not supported\n");
        errno = ENOTSUP;
        return -1;
        // res = symlinkat(link, dirfd, path);
    } else if(S_ISFIFO(mode)) {
        fuse_log(FUSE_LOG_ERR, "fifo in mknod_wrapper not supported\n");
        errno = ENOTSUP;
        return -1;
        // res = mkfifoat(dirfd, path, mode);
#ifdef __FreeBSD__
    } else if(S_ISSOCK(mode)) {
        struct sockaddr_un su;
        int fd;

        if(strlen(path) >= sizeof(su.sun_path)) {
            errno = ENAMETOOLONG;
            return -1;
        }
        fd = socket(AF_UNIX, SOCK_STREAM, 0);
        if(fd >= 0) {
            /*
             * We must bind the socket to the underlying file
             * system to create the socket file, even though
             * we'll never listen on this socket.
             */
            su.sun_family = AF_UNIX;
            strncpy(su.sun_path, path, sizeof(su.sun_path));
            res = bindat(dirfd, fd, (struct sockaddr*) &su, sizeof(su));
            if(res == 0)
                close(fd);
        } else {
            res = -1;
        }
#endif
    } else {
        fuse_log(FUSE_LOG_ERR, "mknodat in mknod_wrapper not supported\n");
        errno = ENOTSUP;
        return -1;
        // res = mknodat(dirfd, path, mode, rdev);
    }

    return res;
}

#endif // GKFS_CLIENT_FUSE_CONTEXT_HPP
+291 −265

File changed.

Preview size limit exceeded, changes collapsed.

+12 −0
Original line number Diff line number Diff line
@@ -45,7 +45,19 @@ def test_read(gkfs_daemon, fuse_client):
    file = gkfs_daemon.mountdir / "file"
    file2 = gkfs_daemon.mountdir / "file2"

    dir = gkfs_daemon.mountdir / "dir"

    sh.bash("-c", "echo baum > " + str(file))
    assert sh.ls(fuse_client.mountdir) == "file\n"
    assert sh.cat(file) == "baum\n"
    sh.touch(str(file2))
    assert sh.wc("-c", str(file2)) == "0 " + str(file2) + "\n"
    sh.truncate("-s", "20", str(file2))
    assert sh.wc("-c", str(file2)) == "20 " + str(file2) + "\n"
    sh.mkdir(str(dir))
    assert sh.ls(fuse_client.mountdir) == "dir  file  file2\n"
    sh.cd(str(dir))
    assert sh.pwd() == str(dir) + "\n"
    sh.mkdir("-p", "fu/bar")
    assert sh.ls() == "fu\n"
    sh.cd("fu")