Back to index

avfs  1.0.1
Defines | Functions | Variables
avfsd.c File Reference
#include <fuse.h>
#include <virtual.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <pthread.h>

Go to the source code of this file.

Defines

#define FUSE_USE_VERSION   26

Functions

static int avfsd_getattr (const char *path, struct stat *stbuf)
static int avfsd_readlink (const char *path, char *buf, size_t size)
static int avfsd_readdir (const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi)
static int avfsd_mknod (const char *path, mode_t mode, dev_t rdev)
static int avfsd_mkdir (const char *path, mode_t mode)
static int avfsd_unlink (const char *path)
static int avfsd_rmdir (const char *path)
static int avfsd_symlink (const char *from, const char *to)
static int avfsd_rename (const char *from, const char *to)
static int avfsd_link (const char *from, const char *to)
static int avfsd_chmod (const char *path, mode_t mode)
static int avfsd_chown (const char *path, uid_t uid, gid_t gid)
static int avfsd_truncate (const char *path, off_t size)
static int avfsd_utime (const char *path, struct utimbuf *buf)
static int avfsd_open (const char *path, struct fuse_file_info *fi)
static int avfsd_read (const char *path, char *buf, size_t size, off_t offset, struct fuse_file_info *fi)
static int avfsd_write (const char *path, const char *buf, size_t size, off_t offset, struct fuse_file_info *fi)
static int avfsd_release (const char *path, struct fuse_file_info *fi)
static int avfsd_access (const char *path, int mask)
static int avfsd_create (const char *path, mode_t mode, struct fuse_file_info *fi)
int main (int argc, char *argv[])

Variables

struct fusefuse
static pthread_mutex_t avfsd_mutexlock = PTHREAD_MUTEX_INITIALIZER
static struct fuse_operations

Define Documentation

#define FUSE_USE_VERSION   26

Definition at line 10 of file avfsd.c.


Function Documentation

static int avfsd_access ( const char *  path,
int  mask 
) [static]

Definition at line 265 of file avfsd.c.

{
    int res;

    res = virt_access(path, mask);
    if (res == -1)
        return -errno;

    return 0;
}

Here is the call graph for this function:

static int avfsd_chmod ( const char *  path,
mode_t  mode 
) [static]

Definition at line 153 of file avfsd.c.

{
    int res;

    res = virt_chmod(path, mode);
    if (res == -1)
        return -errno;

    return 0;
}

Here is the call graph for this function:

static int avfsd_chown ( const char *  path,
uid_t  uid,
gid_t  gid 
) [static]

Definition at line 164 of file avfsd.c.

{
    int res;

    res = virt_lchown(path, uid, gid);
    if (res == -1)
        return -errno;

    return 0;
}

Here is the call graph for this function:

static int avfsd_create ( const char *  path,
mode_t  mode,
struct fuse_file_info *  fi 
) [static]

Definition at line 276 of file avfsd.c.

{
    int res;

    /* open will handle the O_CREAT flag */
    res = virt_open(path, fi->flags | O_CREAT | O_TRUNC, mode);
    if (res == -1)
        return -errno;

    fi->fh = res;
    return 0;
}

Here is the call graph for this function:

static int avfsd_getattr ( const char *  path,
struct stat stbuf 
) [static]

Definition at line 27 of file avfsd.c.

{
    int res;

    res = virt_lstat(path, stbuf);
    if (res == -1)
        return -errno;

    return 0;
}

Here is the call graph for this function:

static int avfsd_link ( const char *  from,
const char *  to 
) [static]

Definition at line 142 of file avfsd.c.

{
    int res;

    res = virt_link(from, to);
    if (res == -1)
        return -errno;

    return 0;
}

Here is the call graph for this function:

static int avfsd_mkdir ( const char *  path,
mode_t  mode 
) [static]

Definition at line 87 of file avfsd.c.

{
    int res;

    res = virt_mkdir(path, mode);
    if (res == -1)
        return -errno;

    return 0;
}

Here is the call graph for this function:

static int avfsd_mknod ( const char *  path,
mode_t  mode,
dev_t  rdev 
) [static]

Definition at line 76 of file avfsd.c.

{
    int res;

    res = virt_mknod(path, mode, rdev);
    if (res == -1)
        return -errno;

    return 0;
}

Here is the call graph for this function:

static int avfsd_open ( const char *  path,
struct fuse_file_info *  fi 
) [static]

Definition at line 198 of file avfsd.c.

{
    int res;

    res = virt_open(path, fi->flags, 0);
    if (res == -1)
        return -errno;

    fi->fh = res;
    return 0;
}

Here is the call graph for this function:

static int avfsd_read ( const char *  path,
char *  buf,
size_t  size,
off_t  offset,
struct fuse_file_info *  fi 
) [static]

Definition at line 210 of file avfsd.c.

{
    int res;

    (void) path;

    pthread_mutex_lock( &avfsd_mutexlock );
    if (virt_lseek(fi->fh, offset, SEEK_SET) == -1) {
        pthread_mutex_unlock( &avfsd_mutexlock );
        return -errno;
    }

    res = virt_read(fi->fh, buf, size);
    pthread_mutex_unlock( &avfsd_mutexlock );

    if (res == -1)
        return -errno;

    return res;
}

Here is the call graph for this function:

static int avfsd_readdir ( const char *  path,
void *  buf,
fuse_fill_dir_t  filler,
off_t  offset,
struct fuse_file_info *  fi 
) [static]

Definition at line 51 of file avfsd.c.

{
    DIR *dp;
    struct dirent *de;

    (void) offset;
    (void) fi;
    dp = virt_opendir(path);
    if (dp == NULL)
        return -errno;

    while((de = virt_readdir(dp)) != NULL) {
        struct stat st;
        memset(&st, 0, sizeof(st));
        st.st_ino = de->d_ino;
        st.st_mode = de->d_type << 12;
        if (filler(buf, de->d_name, &st, 0))
            break;
    }

    virt_closedir(dp);
    return 0;
}

Here is the call graph for this function:

static int avfsd_readlink ( const char *  path,
char *  buf,
size_t  size 
) [static]

Definition at line 38 of file avfsd.c.

{
    int res;

    res = virt_readlink(path, buf, size - 1);
    if (res == -1)
        return -errno;

    buf[res] = '\0';
    return 0;
}

Here is the call graph for this function:

static int avfsd_release ( const char *  path,
struct fuse_file_info *  fi 
) [static]

Definition at line 254 of file avfsd.c.

{
    (void) path;

    pthread_mutex_lock( &avfsd_mutexlock );
    virt_close(fi->fh);
    pthread_mutex_unlock( &avfsd_mutexlock );

    return 0;
}

Here is the call graph for this function:

static int avfsd_rename ( const char *  from,
const char *  to 
) [static]

Definition at line 131 of file avfsd.c.

{
    int res;

    res = virt_rename(from, to);
    if (res == -1)
        return -errno;

    return 0;
}

Here is the call graph for this function:

static int avfsd_rmdir ( const char *  path) [static]

Definition at line 109 of file avfsd.c.

{
    int res;

    res = virt_rmdir(path);
    if (res == -1)
        return -errno;

    return 0;
}

Here is the call graph for this function:

static int avfsd_symlink ( const char *  from,
const char *  to 
) [static]

Definition at line 120 of file avfsd.c.

{
    int res;

    res = virt_symlink(from, to);
    if (res == -1)
        return -errno;

    return 0;
}

Here is the call graph for this function:

static int avfsd_truncate ( const char *  path,
off_t  size 
) [static]

Definition at line 175 of file avfsd.c.

{
    int res;

    res = virt_truncate(path, size);
    if (res == -1)
        return -errno;

    return 0;
}

Here is the call graph for this function:

static int avfsd_unlink ( const char *  path) [static]

Definition at line 98 of file avfsd.c.

{
    int res;

    res = virt_unlink(path);
    if (res == -1)
        return -errno;

    return 0;
}

Here is the call graph for this function:

static int avfsd_utime ( const char *  path,
struct utimbuf *  buf 
) [static]

Definition at line 186 of file avfsd.c.

{
    int res;

    res = virt_utime(path, buf);
    if (res == -1)
        return -errno;

    return 0;
}

Here is the call graph for this function:

static int avfsd_write ( const char *  path,
const char *  buf,
size_t  size,
off_t  offset,
struct fuse_file_info *  fi 
) [static]

Definition at line 232 of file avfsd.c.

{
    int res;

    (void) path;

    pthread_mutex_lock( &avfsd_mutexlock );
    if (virt_lseek(fi->fh, offset, SEEK_SET) == -1) {
        pthread_mutex_unlock( &avfsd_mutexlock );
        return -errno;
    }

    res = virt_write(fi->fh, buf, size);
    pthread_mutex_unlock( &avfsd_mutexlock );

    if (res == -1)
        return -errno;

    return res;
}

Here is the call graph for this function:

int main ( int  argc,
char *  argv[] 
)

Definition at line 312 of file avfsd.c.

{
    fuse_main(argc, argv, &avfsd_oper, NULL);
    return 0;
}

Variable Documentation

pthread_mutex_t avfsd_mutexlock = PTHREAD_MUTEX_INITIALIZER [static]

Definition at line 25 of file avfsd.c.

struct fuse* fuse

Definition at line 23 of file avfsd.c.

struct fuse_operations [static]
Initial value:

Definition at line 289 of file avfsd.c.