Commit 83e5b825 authored by sevenuz's avatar sevenuz Committed by Julius Athenstaedt
Browse files

lseek

parent cc7991a0
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -251,6 +251,18 @@ open_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) {
    fuse_reply_open(req, fi);
}

static void
lseek_handler(fuse_req_t req, fuse_ino_t ino, off_t off, int whence,
             struct fuse_file_info* fi) {
    fuse_log(FUSE_LOG_DEBUG, "lseek handler \n");
    int lc = gkfs::syscall::gkfs_lseek(fi->fh, off, whence);
    if(lc < 0) {
        fuse_reply_err(req, 1);
        return;
    }
    fuse_reply_lseek(req, lc);
}

static void
read_handler(fuse_req_t req, fuse_ino_t ino, size_t size, off_t off,
             struct fuse_file_info* fi) {
@@ -657,6 +669,7 @@ init_ll_ops(fuse_lowlevel_ops* ops) {
    ops->release = release_handler;
    // ops->fsync
    // ops->write_buf
    ops->lseek = lseek_handler;

    // xattr
    // ops->setxattr
@@ -695,7 +708,6 @@ init_ll_ops(fuse_lowlevel_ops* ops) {
    // ops->retrive_reply
    // ops->fallocate
    // ops->copy_file_range
    // ops->lseek
    // ops->tmpfile
    // ops->statx
}
+2 −2
Original line number Diff line number Diff line
@@ -809,7 +809,7 @@ gkfs_statvfs(struct statvfs* buf) {
 * @param fd
 * @param offset
 * @param whence
 * @return 0 on success, -1 on failure
 * @return position on success, -1 on failure
 */
off_t
gkfs_lseek(unsigned int fd, off_t offset, unsigned int whence) {
@@ -822,7 +822,7 @@ gkfs_lseek(unsigned int fd, off_t offset, unsigned int whence) {
 * @param gkfs_fd
 * @param offset
 * @param whence
 * @return 0 on success, -1 on failure
 * @return position on success, -1 on failure
 */
off_t
gkfs_lseek(shared_ptr<gkfs::filemap::OpenFile> gkfs_fd, off_t offset,
+13 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ from harness.logger import logger

nonexisting = "nonexisting"

# somehow are multiple test causing an error in the fuse client...
def test_read(gkfs_daemon, fuse_client):

    file = gkfs_daemon.mountdir / "file"
@@ -66,3 +67,15 @@ def test_read(gkfs_daemon, fuse_client):
    sh.rmdir("foo")
    sh.rm(str(file2))
    assert sh.ls(fuse_client.mountdir) == "dir  file\n"

    # lseek test
    path = gkfs_daemon.mountdir / "lseek_file"
    with open(path, "wb") as f:
        f.write(b"HelloWorld")  # 10 bytes
    fd = os.open(path, os.O_RDONLY)
    pos = os.lseek(fd, 5, os.SEEK_SET)  # absolute seek
    assert pos == 5
    data = os.read(fd, 5)
    assert data == b"World"
    os.close(fd)
    os.remove(path)