Пример #1
0
static int fs_open(const char *name, struct fuse_file_info *fi)
{
    struct ext_file_info *xfi = malloc(sizeof(struct ext_file_info));
    int res;

    if (!xfi)
	return -ENOMEM;

    /* Make sure dvd is open */
    if ((res = inc_refcnt(&mi)) < 0)
	return res;

    if (find_file(&mi, name, xfi)) {
	fi->fh = xfi;

	xfi->cache = NULL;
	xfi->cache_len = 0;
	xfi->cache_off = 0;
	
	/* If it's an IFO, read the whole file into the cache */
	if (IS_IFO(xfi->domain) && (xfi->cache = malloc(xfi->fi->len))) {
	    DVDFileSeek(xfi->fi->fd, 0);
	    if (DVDReadBytes(xfi->fi->fd, xfi->cache, xfi->fi->len) == xfi->fi->len) {
#ifdef FIX_IFO
		FIX_IFO(xfi->title, xfi->cache, xfi->fi->len);
#endif
	    } else {
		free(xfi->cache);
		xfi->cache = NULL;
	    }
	}
	return 0;
    }
   else {
       while (*name == '/')
           ++name;
       if (strcmp(name , ".volume_id") == 0) {
           fi->fh = xfi;

           xfi->cache = NULL;
           xfi->cache_len = 0;
           xfi->cache_off = 0;

           if(xfi->cache = malloc(VOL_ID_SIZE+1)) {
               xfi->fi=&mi.vol_id_info;
               xfi->fi->fd=-1; //read will not work unless fd is set
               memcpy(xfi->cache,mi.vol_id,VOL_ID_SIZE+1);
               fprintf(stderr,"%s\n",xfi->cache);
               return 0;
           }
       }
   }

    /* Failed so release our reference to dvd */
    dec_refcnt(&mi);

    free(xfi);
    return -ENOENT;
}
Пример #2
0
static int fs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
                         off_t offset, struct fuse_file_info *fi)
{
    int domain, title, res;

    /* Make sure dvd is open */
    if ((res = inc_refcnt(&mi)) < 0)
	return res;

    /* Standard directory entries */
    filler(buf, ".", NULL, 0);
    filler(buf, "..", NULL, 0);

    if (strcmp(path, "/") == 0) {
       /* Dummy file for volume id */
       if(mi.vol_id_info.len>0) {
           filler(buf, ".volume_id", NULL ,0);
       }
        filler(buf, "VIDEO_TS", NULL, 0);
    } else if (strcmp(path, "/VIDEO_TS") == 0) {
        for (title = 0; title <= mi.num_title; ++title) {
	    for (domain = MIN_DOMAIN; domain <= MAX_DOMAIN; ++domain) {
	        char name[15];

	        if (title > 0) {
		    sprintf(name, "VTS_%02d_0.VOB", title);
	        } else {
		    if (domain == DVD_READ_TITLE_VOBS)
		            continue;
		    strcpy(name, "VIDEO_TS.VOB");
	        }
	        if (domain == DVD_READ_TITLE_VOBS) {
		    int partnum;
		    for (partnum = 1; partnum < 10; ++partnum) {
		        name[7] = partnum + '0';
		        if (!add_to_dir(buf, filler, name))
			    break;
		    }
	        } else {
		    switch(domain) {
		    case DVD_READ_INFO_BACKUP_FILE:
		        strcpy(name+9, "BUP");
		        break;
		    case DVD_READ_INFO_FILE:
		        strcpy(name+9, "IFO");
		        break;
		    }
		    (void) add_to_dir(buf, filler, name);
	        }
	    }
        }
    }

    /* Release our reference to dvd */
    dec_refcnt(&mi);

    return 0;
}
Пример #3
0
static int fs_getattr(const char *name, struct stat *stbuf)
{
    struct ext_file_info xfi;
    int res = 0;

    /* Make sure dvd is open */
    if ((res = inc_refcnt(&mi)) < 0)
	return res;

    /* Init stat struct */
    memset(stbuf, 0, sizeof(struct stat));
    stbuf->st_mtime = stbuf->st_atime = stbuf->st_ctime = file_time;

    if (find_file(&mi, name, &xfi)) {
	stbuf->st_mode = 0100444;
	stbuf->st_nlink = 1;
	stbuf->st_size = xfi.fi->len;
	if (xfi.partnum) {
		stbuf->st_size -= PART_TO_OFFSET(xfi.partnum, part_size);
		if (stbuf->st_size > part_size)
			stbuf->st_size = part_size;
	}
    } else {
	while (*name == '/')
	    ++name;

	if (name[0] == '\0' || (name[0] == '.' && (name[1] == '\0' ||
                 (name[1] == '.' && name[2] == '\0'))))
	{
	    stbuf->st_mode = 040555;
	    stbuf->st_nlink = 2;
	    stbuf->st_size = 512;
	}
	else if (strcmp(name, "VIDEO_TS") == 0) {
	    stbuf->st_mode = 040555;
	    stbuf->st_nlink = 2;
	    stbuf->st_size = 512;
	}
   else if (strcmp(name , ".volume_id") == 0) {
       stbuf->st_mode = 0100444;
       stbuf->st_nlink = 1;
       stbuf->st_size = mi.vol_id_info.len;
   }
	else {
	    res = -ENOENT;
	}
    }

    /* Release our reference to dvd */
    dec_refcnt(&mi);

    return res;
}
Пример #4
0
static int fs_release(const char *path, struct fuse_file_info *fi) {
    if (fi->fh) {
	struct ext_file_info *xfi = fi->fh;

	if (xfi->cache != NULL) {
	    free(xfi->cache);
	    xfi->cache = NULL;
	}
	free(xfi);
	fi->fh = NULL;

	/* Release this file's reference to the dvd */
	dec_refcnt(&mi);
    }
    return 0;
}
Пример #5
0
int64_t pap_putmsg32(int fildes, struct strbuf32 * ctlptr, struct strbuf32
                     * dataptr, int *flagsp)
{
    struct strbuf32 kctlptr;
    dl_promiscon_req_t *kpromiscon;

    inc_refcnt();

    dcmn_err((CE_CONT, "putmsg() syscall.\n"));

    rw_enter(&config_rwlock, RW_READER);

    if (!config.ppromisc ||
        copyin(ctlptr, &kctlptr, sizeof(struct strbuf)) != 0)
        goto err;

    mutex_enter(&promisc_lock);

    kpromiscon = (dl_promiscon_req_t *) kmem_alloc(kctlptr.len, KM_SLEEP);
    if (!kpromiscon)
        goto err_and_unlock;

    /*
     * There is something strange about kctlptr.buf. GCC says:
     * "... arg 1 of `copyin' makes pointer from integer without a cast"
     * Probably a typical 32 vs. 64bit casting problem. Fix me later.
     */
    if (copyin(kctlptr.buf, kpromiscon, kctlptr.len) != 0)
        goto err_and_free;

    check_promisc(fildes, kpromiscon);

  err_and_free:
    kmem_free(kpromiscon, kctlptr.len);
  err_and_unlock:
    mutex_exit(&promisc_lock);
  err:

    rw_exit(&config_rwlock);
    dec_refcnt();

    return syscalls32[PUTMSG].sc(fildes, ctlptr, dataptr, flagsp);
}
Пример #6
0
int64_t pap_putmsg(int fildes, struct strbuf * ctlptr, struct strbuf
                   * dataptr, int *flagsp)
{
    struct strbuf kctlptr;
    dl_promiscon_req_t *kpromiscon;

    inc_refcnt();

    dcmn_err((CE_CONT, "putmsg() syscall.\n"));

    rw_enter(&config_rwlock, RW_READER);

    if (!config.ppromisc ||
        copyin(ctlptr, &kctlptr, sizeof(struct strbuf)) != 0)
        goto err;

    mutex_enter(&promisc_lock);

    kpromiscon = (dl_promiscon_req_t *) kmem_alloc(kctlptr.len, KM_SLEEP);
    if (!kpromiscon)
        goto err_and_unlock;

    if (copyin(kctlptr.buf, kpromiscon, kctlptr.len) != 0)
        goto err_and_free;

    check_promisc(fildes, kpromiscon);

  err_and_free:
    kmem_free(kpromiscon, kctlptr.len);
  err_and_unlock:
    mutex_exit(&promisc_lock);
  err:

    rw_exit(&config_rwlock);
    dec_refcnt();

    return syscalls[PUTMSG].sc(fildes, ctlptr, dataptr, flagsp);
}