Esempio n. 1
0
int main(int argc, char *argv[])
{
    int err;
    if(argc < 3) {
        usage( argv );
        exit(EINVAL);
    };
    
    err = openlogfile();
    if(err != ERR_NON)
        goto out;

    DBG (("firs argument %s %d", argv[1], argc));
    DBG (("sec argument %s ", argv[2]));
    FDBG ("fir argument %s ", argv[1]);
    FDBG ("sec argument %s ", argv[2]);
    init();
    if( mount_disk_img( argv[1])!= ERR_NON)
        goto out;

    return call_fuse_main(argc, argv);

out:
    return ERR_GEN;
}
Esempio n. 2
0
static int disk_img_info(const char *filename)
{
    BlockDriver *drv;
    BlockDriverState *bs;

    bs = bdrv_new("");
    if (!bs)
        FDBG("Not enough memory");
    drv = NULL;
    if (bdrv_open2(bs, filename, 0, drv) < 0) {
        FDBG("Could not open '%s'", filename);
    }
    bdrv_get_format(bs, disk_img_data.img_format, (sizeof(char) * 128));
    bdrv_delete(bs);
    return 0;
}
Esempio n. 3
0
static int disk_img_getattr(const char *path, 
                            struct stat *stbuf)
{
    int err = 0;

    memset(stbuf, 0, sizeof(struct stat));
    if(strcasecmp(path, "/") == 0) 
    {
        stbuf->st_mode = S_IFDIR | 0755;
        stbuf->st_nlink = 2;
    }
    else if(strcasecmp(path, disk_img_data.raw_filename) == 0) 
    {
        stbuf->st_mode = S_IFREG | 0666;
        stbuf->st_nlink = 1;

        stbuf->st_size   = disk_img_data.raw_stat.st_size;
        stbuf->st_mtime  = disk_img_data.raw_stat.st_mtime;
        stbuf->st_atime  = disk_img_data.raw_stat.st_atime;
        stbuf->st_ctime  = disk_img_data.raw_stat.st_ctime;
        stbuf->st_blocks = disk_img_data.raw_stat.st_blocks;

        /* stbuf->st_uid = getuid(); */
        /* stbuf->st_gid = getgid(); */
        stbuf->st_uid = fuse_get_context()->uid;
        stbuf->st_gid = fuse_get_context()->gid;
    }
    else
        err = ENOENT;
    FDBG("  ");
    return err;
}
Esempio n. 4
0
MyEvent::MyEvent() {
    start=time(NULL);
    done=0;
    MutexGuard mg( serlock );
    serial = ++ser;
    f=ser + 1000 ;
    hooked = false;
    FDBG( "MyEvent", "Ctor",(unsigned long int)this );
};
Esempio n. 5
0
static BlockDriverState *bdrv_new_open(const char *filename,
                                       const char *fmt)
{
    BlockDriverState *bs;
    BlockDriver *drv;

    bs = bdrv_new("");
    if (!bs)
        FDBG("Not enough memory");
    if (fmt) {
        drv = bdrv_find_format(fmt);
        if (!drv)
            FDBG("Unknown file format '%s'", fmt);
    } else {
        drv = NULL;
    }
    if (bdrv_open2(bs, filename, 0, drv) < 0) {
        FDBG("Could not open '%s'", filename);
    }
    return bs;
}
Esempio n. 6
0
static int disk_img_read(const char *path, 
                         char       *buf, 
                         size_t     size,
                         off_t      offset,
                         struct fuse_file_info *fi)
{
    int     err;
    int     nb_sectors = size >> SHIFT_SECTOR;
    int64_t start_sec = offset >> SHIFT_SECTOR;

    FDBG("offset: %lu --> path %s", (unsigned long)offset, path); 
    if(strcasecmp(path, disk_img_data.raw_filename) != 0)
        return -ENOENT;

    FDBG("offset: %lu --> path %s", (unsigned long)offset, path); 
    FDBG("offset: %lu --> buffer %s", (unsigned long)offset, buf); 
    FDBG("offset: %lu --> size: %lu sec start %lu fh %d", (unsigned long)offset,
            (unsigned long)size, (signed long)start_sec, (int)fi->fh);
    err = bdrv_read(disk_img_data.img_bs, start_sec, (uint8_t*) buf,
            nb_sectors);
    FDBG("DATA : %s", buf);
    FDBG("Exit code : %d", err);

    return size;
}
Esempio n. 7
0
static int disk_img_write(const char *path, 
                         char       *buf, 
                         size_t     size,
                         off_t      offset,
                         struct fuse_file_info *fi)
{
    int err;
    int nb_sectors = size >> SHIFT_SECTOR;
    int start_sec = offset >> SHIFT_SECTOR;

    FDBG("path %s" , path ); 
    if(strcasecmp(path, disk_img_data.raw_filename) != 0)
        return -ENOENT;

    FDBG("path %s" , path ); 
    FDBG("buffer %s" , buf ); 
    FDBG("size: %d offset %lld fh %lld" ,  size , offset , fi->fh ); 
    err = bdrv_write(disk_img_data.img_bs, start_sec, (uint8_t*) buf,
            nb_sectors);
    //FDBG("DATA : %s", buf);
    FDBG("Exit code : %d", err);

    return size;
}
Esempio n. 8
0
MyEvent::~MyEvent() {
    FDBG( "MyEvent", "Dtor",(unsigned long int)this);
};