Commit c1ad07f9 authored by Ramon Nou's avatar Ramon Nou Committed by Ramon Nou
Browse files

Disable unused code - Remove statvfs (unused)

Check Parents
parent 72be2450
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -411,6 +411,7 @@ gkfs_statfs(struct statfs* buf) {
    return 0;
    return 0;
}
}


#ifdef ENABLE_UNUSED_FUNCTIONS
/**
/**
 * gkfs wrapper for statvfs() system calls
 * gkfs wrapper for statvfs() system calls
 * errno may be set
 * errno may be set
@@ -444,6 +445,7 @@ gkfs_statvfs(struct statvfs* buf) {
            ST_NOATIME | ST_NODIRATIME | ST_NOSUID | ST_NODEV | ST_SYNCHRONOUS;
            ST_NOATIME | ST_NODIRATIME | ST_NOSUID | ST_NODEV | ST_SYNCHRONOUS;
    return 0;
    return 0;
}
}
#endif


/**
/**
 * gkfs wrapper for lseek() system calls with available file descriptor
 * gkfs wrapper for lseek() system calls with available file descriptor
@@ -1094,7 +1096,7 @@ gkfs_getdents64(unsigned int fd, struct linux_dirent64* dirp,




#ifdef HAS_SYMLINKS
#ifdef HAS_SYMLINKS

#ifdef ENABLE_UNUSED_FUNCTIONS
/**
/**
 * gkfs wrapper for make symlink() system calls
 * gkfs wrapper for make symlink() system calls
 * errno may be set
 * errno may be set
@@ -1177,7 +1179,7 @@ gkfs_readlink(const std::string& path, char* buf, int bufsize) {
    std::strcpy(buf + CTX->mountdir().size(), md->target_path().c_str());
    std::strcpy(buf + CTX->mountdir().size(), md->target_path().c_str());
    return path_size;
    return path_size;
}
}

#endif
#endif
#endif


} // namespace gkfs::syscall
} // namespace gkfs::syscall
+22 −12
Original line number Original line Diff line number Diff line
@@ -75,6 +75,10 @@ def test_open_error(gkfs_daemon, gkfs_client):
    ret = gkfs_client.open(file2, os.O_CREAT | os.O_WRONLY)
    ret = gkfs_client.open(file2, os.O_CREAT | os.O_WRONLY)
    assert ret.retval == 10000
    assert ret.retval == 10000


    # Truncate the file
    ret = gkfs_client.open(file2, os.O_TRUNC | os.O_WRONLY)
    assert ret.retval == 10000
   


    # Open unexistent file
    # Open unexistent file
    ret = gkfs_client.open(file3, os.O_WRONLY)
    ret = gkfs_client.open(file3, os.O_WRONLY)
@@ -127,16 +131,22 @@ def test_statfs(gkfs_daemon, gkfs_client):
    assert ret.statfsbuf.f_ffree == 0
    assert ret.statfsbuf.f_ffree == 0
 
 


def test_statvfs(gkfs_daemon, gkfs_client):
def test_check_parents(gkfs_daemon, gkfs_client):
    # Statfs check most of the outputs
    file = gkfs_daemon.mountdir / "dir" / "file"
    file2 = gkfs_daemon.mountdir / "file2"
    file3 = gkfs_daemon.mountdir / "file2" / "file3"


    ret = gkfs_client.statvfs(gkfs_daemon.mountdir)  
    # Parent directory does not exist
    assert ret.retval == 0
    ret = gkfs_client.open(file, os.O_CREAT | os.O_WRONLY)
    assert ret.statvfsbuf.f_bsize != 0
    assert ret.retval == -1
    assert ret.statvfsbuf.f_blocks != 0
    assert ret.errno == errno.ENOENT
    assert ret.statvfsbuf.f_bfree != 0

    assert ret.statvfsbuf.f_bavail != 0
    # Create file
    assert ret.statvfsbuf.f_files == 0
    ret = gkfs_client.open(file2, os.O_CREAT | os.O_WRONLY)
    assert ret.statvfsbuf.f_ffree == 0
    assert ret.retval == 10000


    # Create file over a file
    ret = gkfs_client.open(file3, os.O_CREAT | os.O_WRONLY)
    assert ret.retval == -1
    assert ret.errno == errno.ENOTDIR
+0 −1
Original line number Original line Diff line number Diff line
@@ -65,7 +65,6 @@ add_executable(gkfs.io
    gkfs.io/unlink.cpp
    gkfs.io/unlink.cpp
    gkfs.io/access.cpp
    gkfs.io/access.cpp
    gkfs.io/statfs.cpp
    gkfs.io/statfs.cpp
    gkfs.io/statvfs.cpp
)
)


include(FetchContent)
include(FetchContent)
+0 −3
Original line number Original line Diff line number Diff line
@@ -102,9 +102,6 @@ access_init(CLI::App& app);
void
void
statfs_init(CLI::App& app);
statfs_init(CLI::App& app);


void
statvfs_init(CLI::App& app);

// UTIL
// UTIL
void
void
file_compare_init(CLI::App& app);
file_compare_init(CLI::App& app);
+0 −1
Original line number Original line Diff line number Diff line
@@ -59,7 +59,6 @@ init_commands(CLI::App& app) {
    truncate_init(app);
    truncate_init(app);
    access_init(app);
    access_init(app);
    statfs_init(app);
    statfs_init(app);
    statvfs_init(app);
    // utils
    // utils
    file_compare_init(app);
    file_compare_init(app);
    chdir_init(app);
    chdir_init(app);
Loading