Back to index

avfs  1.0.1
Classes | Defines | Functions | Variables
utils.h File Reference
#include "cmd.h"
#include "client.h"
#include <dlfcn.h>
#include <pthread.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  fileinfo

Defines

#define _GNU_SOURCE   /* necessary to get definition of RTLD_NEXT */
#define AVFS_DTABLE_SIZE   1024
#define ISVIRTUAL(fd)   (__av_dtable[fd].isvirtual)
#define FD_OK(fd)   ((fd) >= 0 && (fd) < AVFS_DTABLE_SIZE)
#define SERVERFH(fd)   (__av_dtable[fd].serverfh)

Functions

int __av_get_abs_path (const char *path, char *pathbuf, const char **resp)
int __av_path_local (const char *path)
static void * __av_get_real (const char *name)
static int __av_maybe_local (const char *path)
static int __av_is_local (int res, const char *path)

Variables

char __av_cwd [PATHBUF_LEN]
pthread_mutex_t __av_cwdlock
int __av_virtcwd

Class Documentation

struct fileinfo

Definition at line 86 of file dispatch.c.

Collaboration diagram for fileinfo:
Class Members
int holderfd
int isvirtual
time_t lasttime
char * name
struct fileinfo * next
struct openfile * ofs
unsigned int parunique
char * path
struct fileinfo * prev
int serverfh
unsigned int unique
int use

Define Documentation

#define _GNU_SOURCE   /* necessary to get definition of RTLD_NEXT */

Definition at line 9 of file utils.h.

#define AVFS_DTABLE_SIZE   1024

Definition at line 16 of file utils.h.

#define FD_OK (   fd)    ((fd) >= 0 && (fd) < AVFS_DTABLE_SIZE)

Definition at line 30 of file utils.h.

#define ISVIRTUAL (   fd)    (__av_dtable[fd].isvirtual)

Definition at line 29 of file utils.h.

#define SERVERFH (   fd)    (__av_dtable[fd].serverfh)

Definition at line 31 of file utils.h.


Function Documentation

int __av_get_abs_path ( const char *  path,
char *  pathbuf,
const char **  resp 
)

Definition at line 103 of file utils.c.

{
    int res;

    if(path[0] == '/') {
        if(strchr(path, ':') != NULL) {
            const char *s;

            for(s = path; *s == '/'; s++);
            if(try_convert_path(s, pathbuf)) {
                *resp = pathbuf;
                return 0;
            }
        }
        *resp = path;
        return 0;
    }

    if(strchr(path, ':') != NULL) {
        if(try_convert_path(path, pathbuf)) {
            *resp = pathbuf;
            return 0;
        }
    }

    pthread_mutex_lock(&__av_cwdlock);
    res = make_abs_path(path, pathbuf);
    pthread_mutex_unlock(&__av_cwdlock);
    if(res == 0)
        *resp = pathbuf;

    return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void* __av_get_real ( const char *  name) [inline, static]

Definition at line 36 of file utils.h.

{
    void *res;
    int errnosave = errno;
    
    res = dlsym(RTLD_NEXT, name);
    errno = errnosave;

    return res;
}

Here is the caller graph for this function:

static int __av_is_local ( int  res,
const char *  path 
) [inline, static]

Definition at line 61 of file utils.h.

{
    if(res != -1 || errno != ENOENT || __av_path_local(path))
        return 1;
    else
        return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int __av_maybe_local ( const char *  path) [inline, static]

Definition at line 47 of file utils.h.

{
    int isvirtual;
    
    pthread_mutex_lock(&__av_cwdlock);
    isvirtual = __av_virtcwd;
    pthread_mutex_unlock(&__av_cwdlock);

    if(!isvirtual || path == NULL || path[0] == '/')
        return 1;
    else
        return 0;
}

Here is the caller graph for this function:

int __av_path_local ( const char *  path)

Definition at line 38 of file utils.c.

{
    if(strchr(path, VDEV_SEP_CHAR) == NULL) {
        if(strchr(path, ':') == NULL)
            return 1;
        else if(path_valid_virtual(path))
            return 0;
        else
            return 1;
    }
    else
        return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 17 of file utils.c.

pthread_mutex_t __av_cwdlock

Definition at line 18 of file utils.c.

Definition at line 19 of file utils.c.