Back to index

avfs  1.0.1
Functions
operutil.h File Reference
#include "avfs.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int av_file_open (vfile *vf, ventry *ve, int flags, avmode_t mode)
int av_file_close (vfile *vf)
avssize_t av_file_read (vfile *vf, char *buf, avsize_t nbyte)
avssize_t av_file_pread (vfile *vf, char *buf, avsize_t nbyte, avoff_t offset)
avssize_t av_file_write (vfile *vf, const char *buf, avsize_t nbyte)
avssize_t av_file_pwrite (vfile *vf, const char *buf, avsize_t nbyte, avoff_t offset)
int av_file_truncate (vfile *vf, avoff_t length)
int av_file_getattr (vfile *vf, struct avstat *buf, int attrmask)
int av_file_setattr (vfile *vf, struct avstat *buf, int attrmask)
avoff_t av_file_lseek (vfile *vf, avoff_t offset, int whence)
int av_open (ventry *ve, int flags, avmode_t mode, vfile **resp)
int av_close (vfile *vf)
int av_fd_open_entry (ventry *ve, int flags, avmode_t mode)
int av_fd_open (const char *path, int flags, avmode_t mode)
int av_fd_close (int fd)
avssize_t av_fd_read (int fd, void *buf, avsize_t nbyte)
avssize_t av_fd_write (int fd, const char *buf, avsize_t nbyte)
avoff_t av_fd_lseek (int fd, avoff_t offset, int whence)
int av_fd_readdir (int fd, struct avdirent *buf, avoff_t *posp)
int av_fd_getattr (int fd, struct avstat *buf, int attrmask)
int av_fd_setattr (int fd, struct avstat *buf, int attrmask)
int av_fd_truncate (int fd, avoff_t length)

Function Documentation

int av_close ( vfile *  vf)

Definition at line 236 of file oper.c.

{
    int res = 0;

    if(vf != NULL) {
        res = av_file_close(vf);
        av_unref_obj(vf);
    }

    return res;
}

Here is the call graph for this function:

int av_fd_close ( int  fd)

Definition at line 111 of file fdops.c.

{
    int res;
    vfile *vf;

    res = get_file(fd, &vf);
    if(res == 0) {
        res = av_file_close(vf);
        put_file(vf);

        AV_LOCK(files_lock);
        file_table[fd] = NULL;
        AV_UNLOCK(files_lock);

        av_unref_obj(vf);
    }

    return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int av_fd_getattr ( int  fd,
struct avstat buf,
int  attrmask 
)

Definition at line 219 of file fdops.c.

{
    int res;
    vfile *vf;

    res = get_file(fd, &vf);
    if(res == 0) {
        res = av_file_getattr(vf, buf, attrmask);
       put_file(vf);
    }

    return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

avoff_t av_fd_lseek ( int  fd,
avoff_t  offset,
int  whence 
)

Definition at line 181 of file fdops.c.

{
    avoff_t res;
    vfile *vf;

    res = get_file(fd, &vf);
    if(res == 0) {
        if((vf->flags & AVO_DIRECTORY) != 0)
            res = dir_lseek(vf, offset, whence);
        else
            res = av_file_lseek(vf, offset, whence);
       put_file(vf);
    }

    return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int av_fd_open ( const char *  path,
int  flags,
avmode_t  mode 
)

Definition at line 96 of file fdops.c.

{
    int res;
    ventry *ve;
    
    res = av_get_ventry(path, !(flags & AVO_NOFOLLOW), &ve);
    if(res < 0)
        return res;

    res = av_fd_open_entry(ve, flags, mode);
    av_free_ventry(ve);

    return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int av_fd_open_entry ( ventry *  ve,
int  flags,
avmode_t  mode 
)

Definition at line 74 of file fdops.c.

{
    int res;
    int fd;
    vfile *vf;

    AV_NEW_OBJ(vf, free_vfile);
    AV_INITLOCK(vf->lock);
    res = av_file_open(vf, ve, flags, mode);
    if(res < 0) {
        av_unref_obj(vf);
        return res;
    }

    AV_LOCK(files_lock);
    fd = find_unused();
    file_table[fd] = vf;
    AV_UNLOCK(files_lock);

    return fd;
}

Here is the call graph for this function:

Here is the caller graph for this function:

avssize_t av_fd_read ( int  fd,
void *  buf,
avsize_t  nbyte 
)

Definition at line 131 of file fdops.c.

{
    avssize_t res;
    vfile *vf;

    res = get_file(fd, &vf);
    if(res == 0) {
        res = av_file_read(vf, buf, nbyte);
        put_file(vf);
    }

    return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int av_fd_readdir ( int  fd,
struct avdirent buf,
avoff_t posp 
)

Definition at line 198 of file fdops.c.

{
    int res;
    vfile *vf;

    res = get_file(fd, &vf);
    if(res == 0) {
        struct avfs *avfs = vf->mnt->avfs;

       *posp = vf->ptr;
        AVFS_LOCK(avfs);
       res = avfs->readdir(vf, buf);
        AVFS_UNLOCK(avfs);


       put_file(vf);
    }

    return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int av_fd_setattr ( int  fd,
struct avstat buf,
int  attrmask 
)

Definition at line 233 of file fdops.c.

{
    int res;
    vfile *vf;

    res = get_file(fd, &vf);
    if(res == 0) {
        res = av_file_setattr(vf, buf, attrmask);
       put_file(vf);
    }

    return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int av_fd_truncate ( int  fd,
avoff_t  length 
)

Definition at line 247 of file fdops.c.

{
    int res;
    vfile *vf;

    res = get_file(fd, &vf);
    if(res == 0) {
        res = av_file_truncate(vf, length);
       put_file(vf);
    }

    return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

avssize_t av_fd_write ( int  fd,
const char *  buf,
avsize_t  nbyte 
)

Definition at line 145 of file fdops.c.

{
    avssize_t res;
    vfile *vf;

    res = get_file(fd, &vf);
    if(res == 0) {
        res = av_file_write(vf, buf, nbyte);
        put_file(vf);
    }

    return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int av_file_close ( vfile *  vf)

Definition at line 61 of file oper.c.

{
    int res;
    struct avfs *avfs = vf->mnt->avfs;

    AVFS_LOCK(avfs);
    res = avfs->close(vf);
    AVFS_UNLOCK(avfs);

    av_free_vmount(vf->mnt);
    vf->mnt = NULL;

    return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int av_file_getattr ( vfile *  vf,
struct avstat buf,
int  attrmask 
)

Definition at line 171 of file oper.c.

{
    int res;
    struct avfs *avfs = vf->mnt->avfs;
    
    AVFS_LOCK(avfs);
    res = avfs->getattr(vf, buf, attrmask);
    AVFS_UNLOCK(avfs);

    return res;
}

Here is the caller graph for this function:

avoff_t av_file_lseek ( vfile *  vf,
avoff_t  offset,
int  whence 
)

Definition at line 195 of file oper.c.

{
    avoff_t res;
    struct avfs *avfs = vf->mnt->avfs;
    
    AVFS_LOCK(avfs);
    res = avfs->lseek(vf, offset, whence);
    AVFS_UNLOCK(avfs);

    return res;
}

Here is the caller graph for this function:

int av_file_open ( vfile *  vf,
ventry *  ve,
int  flags,
avmode_t  mode 
)

Definition at line 27 of file oper.c.

{
    int res;
    struct avfs *avfs = ve->mnt->avfs;

    res = av_copy_vmount(ve->mnt, &vf->mnt);
    if(res < 0)
       return res;

    if((flags & AVO_EXCL) != 0 && (flags & AVO_CREAT) == 0)
        flags &= ~AVO_EXCL;

    if((flags & AVO_TRUNC) != 0 && !AV_ISWRITE(flags)) {
        if((flags & AVO_ACCMODE) == AVO_RDONLY)
            flags = (flags & ~AVO_ACCMODE) | AVO_RDWR;
        else
            flags = (flags & ~AVO_ACCMODE) | AVO_WRONLY;
    }        

    AVFS_LOCK(avfs);
    res = avfs->open(ve, flags, (mode & 07777), &vf->data);
    AVFS_UNLOCK(avfs);
    if(res < 0) {
       av_free_vmount(vf->mnt);
        vf->mnt = NULL;
        return res;
    }

    vf->ptr = 0;
    vf->flags = flags;

    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

avssize_t av_file_pread ( vfile *  vf,
char *  buf,
avsize_t  nbyte,
avoff_t  offset 
)

Definition at line 93 of file oper.c.

{
    int res;
    
    res = check_file_access(vf, AVO_RDONLY);
    if(res == 0) {
        avoff_t sres;
        struct avfs *avfs = vf->mnt->avfs;

        AVFS_LOCK(avfs);
        sres = avfs->lseek(vf, offset, AVSEEK_SET);
        if(sres < 0)
            res = sres;
        else
            res = avfs->read(vf, buf, nbyte);
        AVFS_UNLOCK(avfs);
    }

    return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

avssize_t av_file_pwrite ( vfile *  vf,
const char *  buf,
avsize_t  nbyte,
avoff_t  offset 
)

Definition at line 131 of file oper.c.

{
    int res;

    res = check_file_access(vf, AVO_WRONLY);
    if(res == 0) {
        avoff_t sres;
        struct avfs *avfs = vf->mnt->avfs;

        AVFS_LOCK(avfs);
        sres = avfs->lseek(vf, offset, AVSEEK_SET);
        if(sres < 0)
            res = sres;
        else
            res = avfs->write(vf, buf, nbyte);
        AVFS_UNLOCK(avfs);
    }

    return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

avssize_t av_file_read ( vfile *  vf,
char *  buf,
avsize_t  nbyte 
)

Definition at line 76 of file oper.c.

{
    int res;

    res = check_file_access(vf, AVO_RDONLY);
    if(res == 0) {
        struct avfs *avfs = vf->mnt->avfs;

        AVFS_LOCK(avfs);
        res = avfs->read(vf, buf, nbyte);
        AVFS_UNLOCK(avfs);
    }

    return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int av_file_setattr ( vfile *  vf,
struct avstat buf,
int  attrmask 
)

Definition at line 183 of file oper.c.

{
    int res;
    struct avfs *avfs = vf->mnt->avfs;

    AVFS_LOCK(avfs);
    res = avfs->setattr(vf, buf, attrmask);
    AVFS_UNLOCK(avfs);

    return res;
}

Here is the caller graph for this function:

int av_file_truncate ( vfile *  vf,
avoff_t  length 
)

Definition at line 153 of file oper.c.

{
    int res;
    struct avfs *avfs = vf->mnt->avfs;

    if(length < 0)
        return -EINVAL;

    res = check_file_access(vf, AVO_WRONLY);
    if(res == 0) {
        AVFS_LOCK(avfs);
        res = avfs->truncate(vf, length);
        AVFS_UNLOCK(avfs);
    }

    return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

avssize_t av_file_write ( vfile *  vf,
const char *  buf,
avsize_t  nbyte 
)

Definition at line 114 of file oper.c.

{
    int res;

    res = check_file_access(vf, AVO_WRONLY);
    if(res == 0) {
        struct avfs *avfs = vf->mnt->avfs;
        
        AVFS_LOCK(avfs);
        res = avfs->write(vf, buf, nbyte);
        AVFS_UNLOCK(avfs);
    }
    
    return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int av_open ( ventry *  ve,
int  flags,
avmode_t  mode,
vfile **  resp 
)

Definition at line 215 of file oper.c.

{
    int res;
    vfile *vf;

    AV_NEW_OBJ(vf, file_destroy);
    AV_INITLOCK(vf->lock);
    res = av_file_open(vf, ve, flags, mode);
    if(res < 0) {
        AV_FREELOCK(vf->lock);
        av_unref_obj(vf);
    }
    else 
        *resp = vf;

    return res;
}

Here is the call graph for this function: