Example #1
0
/*
 * Reclaim an inode so that it can be used for other purposes.
 */
int
ffs_reclaim(void *v)
{
	struct vop_reclaim_args *ap = v;
	struct vnode *vp = ap->a_vp;
	struct inode *ip = VTOI(vp);
	int error;

	if ((error = ufs_reclaim(vp, ap->a_p)) != 0)
		return (error);

	if (ip->i_din1 != NULL) {
#ifdef FFS2
		if (ip->i_ump->um_fstype == UM_UFS2)
			pool_put(&ffs_dinode2_pool, ip->i_din2);
		else
#endif
			pool_put(&ffs_dinode1_pool, ip->i_din1);
	}

	pool_put(&ffs_ino_pool, ip);

	vp->v_data = NULL;

	return (0);
}
Example #2
0
int
fusefs_mkdir(void *v)
{
	struct vop_mkdir_args *ap = v;
	struct vnode *dvp = ap->a_dvp;
	struct vnode **vpp = ap->a_vpp;
	struct componentname *cnp = ap->a_cnp;
	struct vattr *vap = ap->a_vap;
	struct proc *p = cnp->cn_proc;
	struct vnode *tdp = NULL;
	struct fusefs_node *ip;
	struct fusefs_mnt *fmp;
	struct fusebuf *fbuf;
	int error = 0;

	DPRINTF("fusefs_mkdir %s\n", cnp->cn_nameptr);

	ip = VTOI(dvp);
	fmp = (struct fusefs_mnt *)ip->ufs_ino.i_ump;


	if (!fmp->sess_init || (fmp->undef_op & UNDEF_MKDIR)) {
		error = ENOSYS;
		goto out;
	}

	fbuf = fb_setup(FUSEFDSIZE + cnp->cn_namelen + 1, ip->ufs_ino.i_number,
	    FBT_MKDIR, p);

	fbuf->fb_io_mode = MAKEIMODE(vap->va_type, vap->va_mode);
	memcpy(fbuf->fb_dat, cnp->cn_nameptr, cnp->cn_namelen);
	fbuf->fb_dat[cnp->cn_namelen] = '\0';

	error = fb_queue(fmp->dev, fbuf);
	if (error) {
		if (error == ENOSYS)
			fmp->undef_op |= UNDEF_MKDIR;

		pool_put(&fusefs_fbuf_pool, fbuf);
		goto out;
	}

	if ((error = VFS_VGET(fmp->mp, fbuf->fb_ino, &tdp))) {
		pool_put(&fusefs_fbuf_pool, fbuf);
		goto out;
	}

	tdp->v_type = IFTOVT(fbuf->fb_io_mode);
	VTOI(tdp)->vtype = tdp->v_type;

	if (dvp != NULL && dvp->v_type == VDIR)
		VTOI(tdp)->parent = ip->ufs_ino.i_number;

	*vpp = tdp;
	VN_KNOTE(ap->a_dvp, NOTE_WRITE | NOTE_LINK);
	pool_put(&fusefs_fbuf_pool, fbuf);
out:
	vput(dvp);
	return (error);
}
Example #3
0
static int mysqlfs_chown(const char *path, uid_t uid, gid_t gid)
{
    int ret;
    long inode;
    MYSQL *dbconn;

    log_printf(LOG_D_CALL, "mysql_chown(\"%s\", %ld, %ld)\n", path, uid, gid);

    if ((dbconn = pool_get()) == NULL)
      return -EMFILE;

    inode = query_inode(dbconn, path);
    if (inode < 0) {
        pool_put(dbconn);
        return inode;
    }

    ret = query_chown(dbconn, inode, uid, gid);
    if(ret){
        log_printf(LOG_ERROR, "Error: query_chown()\n");
        pool_put(dbconn);
        return -EIO;
    }

    pool_put(dbconn);

    return ret;
}
Example #4
0
static int mysqlfs_chmod(const char* path, mode_t mode)
{
    int ret;
    long inode;
    MYSQL *dbconn;

    log_printf(LOG_D_CALL, "mysql_chmod(\"%s\", 0%3o)\n", path, mode);

    if ((dbconn = pool_get()) == NULL)
      return -EMFILE;

    inode = query_inode(dbconn, path);
    if (inode < 0) {
        pool_put(dbconn);
        return inode;
    }

    ret = query_chmod(dbconn, inode, mode);
    if(ret){
        log_printf(LOG_ERROR, "Error: query_chmod()\n");
        pool_put(dbconn);
        return -EIO;
    }

    pool_put(dbconn);

    return ret;
}
Example #5
0
/*
 * Reclaim an inode so that it can be used for other purposes.
 */
int
ext2fs_reclaim(void *v)
{
	struct vop_reclaim_args *ap = v;
	struct vnode *vp = ap->a_vp;
	struct inode *ip;
#ifdef DIAGNOSTIC
	extern int prtactive;

	if (prtactive && vp->v_usecount != 0) 
		vprint("ext2fs_reclaim: pushing active", vp);
#endif

	/*
	 * Remove the inode from its hash chain.
	 */
	ip = VTOI(vp);
	ufs_ihashrem(ip);

	/*
	 * Purge old data structures associated with the inode.
	 */
	cache_purge(vp);
	if (ip->i_devvp)
		vrele(ip->i_devvp);

	if (ip->i_e2din != NULL)
		pool_put(&ext2fs_dinode_pool, ip->i_e2din);

	pool_put(&ext2fs_inode_pool, ip);

	vp->v_data = NULL;

	return (0);
}
Example #6
0
static int mysqlfs_utime(const char *path, struct utimbuf *time)
{
    int ret;
    long inode;
    MYSQL *dbconn;

    log_printf(LOG_D_CALL, "mysql_utime(\"%s\")\n", path);

    if ((dbconn = pool_get()) == NULL)
      return -EMFILE;

    inode = query_inode(dbconn, path);
    if (inode < 0) {
        pool_put(dbconn);
        return inode;
    }

    ret = query_utime(dbconn, inode, time);
    if (ret < 0) {
        log_printf(LOG_ERROR, "Error: query_utime()\n");
        pool_put(dbconn);
        return -EIO;
    }

    pool_put(dbconn);

    return 0;
}
Example #7
0
struct mbuf *
m_free(struct mbuf *m)
{
	struct mbuf *n;
	int s;

	s = splvm();
	mbstat.m_mtypes[m->m_type]--;
	if (m->m_flags & M_PKTHDR)
		m_tag_delete_chain(m);
	if (m->m_flags & M_EXT) {
		if (MCLISREFERENCED(m))
			_MCLDEREFERENCE(m);
		else if (m->m_flags & M_CLUSTER)
			pool_put(&mclpool, m->m_ext.ext_buf);
		else if (m->m_ext.ext_free)
			(*(m->m_ext.ext_free))(m->m_ext.ext_buf,
			    m->m_ext.ext_size, m->m_ext.ext_arg);
		else
			free(m->m_ext.ext_buf,m->m_ext.ext_type);
		m->m_ext.ext_size = 0;
	}
	m->m_flags = 0;
	n = m->m_next;
	pool_put(&mbpool, m);
	splx(s);

	return (n);
}
Example #8
0
static int mysqlfs_symlink(const char *from, const char *to)
{
    int ret;
    int inode;
    MYSQL *dbconn;

    log_printf(LOG_D_CALL, "%s(\"%s\" -> \"%s\")\n", __func__, from, to);

    ret = mysqlfs_mknod(to, S_IFLNK | 0755, 0);
    if (ret < 0)
      return ret;

    if ((dbconn = pool_get()) == NULL)
      return -EMFILE;

    inode = query_inode(dbconn, to);
    if(inode < 0){
        pool_put(dbconn);
        return -ENOENT;
    }

    ret = query_write(dbconn, inode, from, strlen(from), 0);
    if (ret > 0) ret = 0;

    pool_put(dbconn);

    return ret;
}
Example #9
0
int
fusefs_write(void *v)
{
	struct vop_write_args *ap = v;
	struct vnode *vp = ap->a_vp;
	struct uio *uio = ap->a_uio;
	struct proc *p = uio->uio_procp;
	struct fusefs_node *ip;
	struct fusefs_mnt *fmp;
	struct fusebuf *fbuf = NULL;
	size_t len, diff;
	int error=0;

	DPRINTF("fusefs_write\n");

	ip = VTOI(vp);
	fmp = (struct fusefs_mnt *)ip->ufs_ino.i_ump;

	DPRINTF("write inode=%i, offset=%llu, resid=%x\n",
	    ip->ufs_ino.i_number, uio->uio_offset, uio->uio_resid);

	if (uio->uio_resid == 0)
		return (error);

	while (uio->uio_resid > 0) {
		len = MIN(uio->uio_resid, FUSELEN);
		fbuf = fb_setup(FUSEFDSIZE + len, ip->ufs_ino.i_number,
		    FBT_WRITE, p);

		fbuf->fb_io_fd = fusefs_fd_get(ip, FUFH_WRONLY);
		fbuf->fb_io_off = uio->uio_offset;
		fbuf->fb_io_len = len;

		if ((error = uiomove(fbuf->fb_dat, len, uio))) {
			DPRINTF("uio error %i", error);
			break;
		}

		error = fb_queue(fmp->dev, fbuf);

		if (error)
			break;

		diff = len - fbuf->fb_io_len;
		if (diff < 0) {
			error = EINVAL;
			break;
		}

		uio->uio_resid += diff;
		uio->uio_offset -= diff;

		pool_put(&fusefs_fbuf_pool, fbuf);
		fbuf = NULL;
	}

	if (fbuf)
		pool_put(&fusefs_fbuf_pool, fbuf);
	return (error);
}
Example #10
0
static int mysqlfs_mkdir(const char *path, mode_t mode){
    int ret;
    MYSQL *dbconn;
    long inode;
    char dir_path[PATH_MAX];

    log_printf(LOG_D_CALL, "mysqlfs_mkdir(\"%s\", 0%o)\n", path, mode);
    
    if(!(strlen(path) < PATH_MAX)){
        log_printf(LOG_ERROR, "Error: Filename too long\n");
        return -ENAMETOOLONG;
    }
    strncpy(dir_path, path, PATH_MAX);
    dirname(dir_path);

    if ((dbconn = pool_get()) == NULL)
      return -EMFILE;

    inode = query_inode(dbconn, dir_path);
    if(inode < 0){
        pool_put(dbconn);
        return -ENOENT;
    }

    ret = query_mkdir(dbconn, path, mode, inode);
    if(ret < 0){
        log_printf(LOG_ERROR, "Error: query_mkdir()\n");
        pool_put(dbconn);
        return ret;
    }

    pool_put(dbconn);
    return 0;
}
Example #11
0
static int mysqlfs_readlink(const char *path, char *buf, size_t size)
{
    int ret;
    long inode;
    MYSQL *dbconn;

    log_printf(LOG_D_CALL, "%s(\"%s\")\n", __func__, path);

    if ((dbconn = pool_get()) == NULL)
      return -EMFILE;

    inode = query_inode(dbconn, path);
    if(inode < 0){
        pool_put(dbconn);
        return -ENOENT;
    }

    memset (buf, 0, size);
    ret = query_read(dbconn, inode, buf, size, 0);
    log_printf(LOG_DEBUG, "readlink(%s): %s [%zd -> %d]\n", path, buf, size, ret);
    pool_put(dbconn);

    if (ret > 0) ret = 0;
    return ret;
}
Example #12
0
int
fusefs_symlink(void *v)
{
	struct vop_symlink_args *ap = v;
	struct vnode **vpp = ap->a_vpp;
	struct componentname *cnp = ap->a_cnp;
	struct vnode *dvp = ap->a_dvp;
	struct proc *p = cnp->cn_proc;
	char *target = ap->a_target;
	struct fusefs_node *dp;
	struct fusefs_mnt *fmp;
	struct fusebuf *fbuf;
	struct vnode *tdp;
	int error = 0;
	int len;

	DPRINTF("fusefs_symlink\n");
	dp = VTOI(dvp);
	fmp = (struct fusefs_mnt *)dp->ufs_ino.i_ump;

	if (!fmp->sess_init  || (fmp->undef_op & UNDEF_SYMLINK)) {
		error = ENOSYS;
		goto bad;
	}

	len = strlen(target) + 1;

	fbuf = fb_setup(FUSEFDSIZE + len + cnp->cn_namelen + 1,
	    dp->ufs_ino.i_number, FBT_SYMLINK, p);

	memcpy(fbuf->fb_dat, cnp->cn_nameptr, cnp->cn_namelen);
	fbuf->fb_dat[cnp->cn_namelen] = '\0';
	memcpy(&fbuf->fb_dat[cnp->cn_namelen + 1], target, len);

	error = fb_queue(fmp->dev, fbuf);
	if (error) {
		if (error == ENOSYS)
			fmp->undef_op |= UNDEF_SYMLINK;

		pool_put(&fusefs_fbuf_pool, fbuf);
		goto bad;
	}

	if ((error = VFS_VGET(fmp->mp, fbuf->fb_ino, &tdp))) {
		pool_put(&fusefs_fbuf_pool, fbuf);
		goto bad;
	}

	tdp->v_type = VLNK;
	VTOI(tdp)->vtype = tdp->v_type;
	VTOI(tdp)->parent = dp->ufs_ino.i_number;

	*vpp = tdp;
	pool_put(&fusefs_fbuf_pool, fbuf);
	vput(tdp);
bad:
	vput(dvp);
	return (error);
}
Example #13
0
/*
 * When an attempt at a new connection is noted on a socket
 * which accepts connections, sonewconn is called.  If the
 * connection is possible (subject to space constraints, etc.)
 * then we allocate a new structure, properly linked into the
 * data structure of the original socket, and return this.
 * Connstatus may be 0 or SS_ISCONNECTED.
 *
 * Must be called at splsoftnet()
 */
struct socket *
sonewconn(struct socket *head, int connstatus)
{
	struct socket *so;
	int soqueue = connstatus ? 1 : 0;

	splsoftassert(IPL_SOFTNET);

	if (mclpools[0].pr_nout > mclpools[0].pr_hardlimit * 95 / 100)
		return (NULL);
	if (head->so_qlen + head->so_q0len > head->so_qlimit * 3)
		return (NULL);
	so = pool_get(&socket_pool, PR_NOWAIT|PR_ZERO);
	if (so == NULL)
		return (NULL);
	so->so_type = head->so_type;
	so->so_options = head->so_options &~ SO_ACCEPTCONN;
	so->so_linger = head->so_linger;
	so->so_state = head->so_state | SS_NOFDREF;
	so->so_proto = head->so_proto;
	so->so_timeo = head->so_timeo;
	so->so_pgid = head->so_pgid;
	so->so_euid = head->so_euid;
	so->so_ruid = head->so_ruid;
	so->so_egid = head->so_egid;
	so->so_rgid = head->so_rgid;
	so->so_cpid = head->so_cpid;
	so->so_siguid = head->so_siguid;
	so->so_sigeuid = head->so_sigeuid;

	/*
	 * Inherit watermarks but those may get clamped in low mem situations.
	 */
	if (soreserve(so, head->so_snd.sb_hiwat, head->so_rcv.sb_hiwat)) {
		pool_put(&socket_pool, so);
		return (NULL);
	}
	so->so_snd.sb_wat = head->so_snd.sb_wat;
	so->so_snd.sb_lowat = head->so_snd.sb_lowat;
	so->so_snd.sb_timeo = head->so_snd.sb_timeo;
	so->so_rcv.sb_wat = head->so_rcv.sb_wat;
	so->so_rcv.sb_lowat = head->so_rcv.sb_lowat;
	so->so_rcv.sb_timeo = head->so_rcv.sb_timeo;

	soqinsque(head, so, soqueue);
	if ((*so->so_proto->pr_usrreq)(so, PRU_ATTACH, NULL, NULL, NULL,
	    curproc)) {
		(void) soqremque(so, soqueue);
		pool_put(&socket_pool, so);
		return (NULL);
	}
	if (connstatus) {
		sorwakeup(head);
		wakeup(&head->so_timeo);
		so->so_state |= connstatus;
	}
	return (so);
}
Example #14
0
int
fusefs_read(void *v)
{
	struct vop_read_args *ap = v;
	struct vnode *vp = ap->a_vp;
	struct uio *uio = ap->a_uio;
	struct proc *p = uio->uio_procp;
	struct fusefs_node *ip;
	struct fusefs_mnt *fmp;
	struct fusebuf *fbuf = NULL;
	size_t size;
	int error=0;

	DPRINTF("fusefs_read\n");

	ip = VTOI(vp);
	fmp = (struct fusefs_mnt *)ip->ufs_ino.i_ump;

	DPRINTF("read inode=%i, offset=%llu, resid=%x\n",
	    ip->ufs_ino.i_number, uio->uio_offset, uio->uio_resid);

	if (uio->uio_resid == 0)
		return (error);
	if (uio->uio_offset < 0)
		return (EINVAL);

	while (uio->uio_resid > 0) {
		fbuf = fb_setup(FUSEFDSIZE, ip->ufs_ino.i_number, FBT_READ, p);

		size = MIN(uio->uio_resid, FUSELEN);
		fbuf->fb_io_fd = fusefs_fd_get(ip, FUFH_RDONLY);
		fbuf->fb_io_off = uio->uio_offset;
		fbuf->fb_io_len = size;

		error = fb_queue(fmp->dev, fbuf);

		if (error)
			break;

		error = uiomove(fbuf->fb_dat, MIN(size, fbdatsize(fbuf)), uio);
		if (error)
			break;

		if (fbdatsize(fbuf) < size)
			break;

		pool_put(&fusefs_fbuf_pool, fbuf);
		fbuf = NULL;
	}

	if (fbuf)
		pool_put(&fusefs_fbuf_pool, fbuf);

	return (error);
}
Example #15
0
static int mysqlfs_open(const char *path, struct fuse_file_info *fi)
{
    MYSQL *dbconn;
    long inode;
    int ret;

    log_printf(LOG_D_CALL, "mysqlfs_open(\"%s\")\n", path);

#ifdef STATUSDIR
    /* take a short-circuit for the bogus virtual files */
    if (0 == strncmp (path, status_pathname, len_status_pathname))
    {
        char *a = (char *) path + len_status_pathname;

        log_printf(LOG_D_CALL, "%s(\"%s\")(@%d)\n", __FUNCTION__, a, __LINE__);
        if (0 == strcmp (a, "/txt"))
        {
            fi->fh = inode_status_txt;
            return 0;
        }
        else if (0 == strcmp (a, "/xml"))
        {
            fi->fh = inode_status_xml;
            return 0;
        }

        /* otherwise, fall-thru to a inode-lookup failure */
    }
#endif

    if ((dbconn = pool_get()) == NULL)
      return -EMFILE;

    inode = query_inode(dbconn, path);
    if(inode < 0){
        pool_put(dbconn);
        return -ENOENT;
    }

    /* Save inode for future use. Lets us skip path->inode translation.  */
    fi->fh = inode;

    log_printf(LOG_D_OTHER, "inode(\"%s\") = %d\n", path, fi->fh);

    ret = query_inuse_inc(dbconn, inode, 1);
    if (ret < 0) {
        pool_put(dbconn);
        return ret;
    }

    pool_put(dbconn);

    return 0;
}
Example #16
0
static int mysqlfs_unlink(const char *path)
{
    int ret;
    long inode, parent, nlinks;
    char name[PATH_MAX];
    MYSQL *dbconn;

    log_printf(LOG_D_CALL, "mysqlfs_unlink(\"%s\")\n", path);

    if ((dbconn = pool_get()) == NULL)
      return -EMFILE;

    ret = query_inode_full(dbconn, path, name, sizeof(name),
			   &inode, &parent, &nlinks);
    if (ret < 0) {
        if (ret != -ENOENT)
            log_printf(LOG_ERROR, "Error: query_inode_full(%s): %s\n",
		       path, strerror(ret));
	goto err_out;
    }

    ret = query_rmdirentry(dbconn, name, parent);
    if (ret < 0) {
        log_printf(LOG_ERROR, "Error: query_rmdirentry()\n");
	goto err_out;
    }

    /* Only the last unlink() must set deleted flag. 
     * This is a shortcut - query_set_deleted() wouldn't
     * set the flag if there is still an existing direntry
     * anyway. But we'll save some DB processing here. */
    if (nlinks > 1)
        return 0;
    
    ret = query_set_deleted(dbconn, inode);
    if (ret < 0) {
        log_printf(LOG_ERROR, "Error: query_set_deleted()\n");
	goto err_out;
    }

    ret = query_purge_deleted(dbconn, inode);
    if (ret < 0) {
        log_printf(LOG_ERROR, "Error: query_purge_deleted()\n");
	goto err_out;
    }

    pool_put(dbconn);

    return 0;

err_out:
    pool_put(dbconn);
    return ret;
}
Example #17
0
static int mysqlfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
                           off_t offset, struct fuse_file_info *fi)
{
    (void) offset;
    (void) fi;
    int ret;
    MYSQL *dbconn;
    long inode;

    log_printf(LOG_D_CALL, "mysqlfs_readdir(\"%s\")\n", path);

#ifdef STATUSDIR
    if (0 == strcmp (path, status_pathname))
    {
        /* if printing the bogus "status" directory, dump the content and get out */
        log_printf(LOG_D_CALL, "mysqlfs_readdir(\"%s\")(@%d)\n", path, __LINE__);
        filler(buf, ".", NULL, 0);
        filler(buf, "..", NULL, 0);
        filler(buf, "txt", NULL, 0);
        filler(buf, "xml", NULL, 0);

        return 0;
    }
#endif

    if ((dbconn = pool_get()) == NULL)
      return -EMFILE;

    inode = query_inode(dbconn, path);
    if(inode < 0){
        log_printf(LOG_ERROR, "Error: query_inode()\n");
        pool_put(dbconn);
        return inode;
    }

    
    filler(buf, ".", NULL, 0);
    filler(buf, "..", NULL, 0);

#ifdef STATUSDIR
    /* stuff in the bogus status subdir */
    if (0 == strcmp (path, "/"))
    {
        log_printf(LOG_D_CALL, "mysqlfs_readdir(\"%s\")(@%d)\n", path, __LINE__);
        filler(buf, status_pathname+1, NULL, 0);
    }
#endif


    ret = query_readdir(dbconn, inode, buf, filler);
    pool_put(dbconn);

    return 0;
}
Example #18
0
void
session_free (session_t * s)
{
  if (CLIB_DEBUG)
    {
      u8 thread_index = s->thread_index;
      clib_memset (s, 0xFA, sizeof (*s));
      pool_put (session_main.wrk[thread_index].sessions, s);
      return;
    }
  SESSION_EVT_DBG (SESSION_EVT_FREE, s);
  pool_put (session_main.wrk[s->thread_index].sessions, s);
}
Example #19
0
int
fusefs_remove(void *v)
{
	struct vop_remove_args *ap = v;
	struct vnode *vp = ap->a_vp;
	struct vnode *dvp = ap->a_dvp;
	struct componentname *cnp = ap->a_cnp;
	struct proc *p = cnp->cn_proc;
	struct fusefs_node *ip;
	struct fusefs_node *dp;
	struct fusefs_mnt *fmp;
	struct fusebuf *fbuf;
	int error = 0;

	DPRINTF("fusefs_remove\n");

	ip = VTOI(vp);
	dp = VTOI(dvp);
	fmp = (struct fusefs_mnt *)ip->ufs_ino.i_ump;

	if (!fmp->sess_init || (fmp->undef_op & UNDEF_REMOVE)) {
		error = ENOSYS;
		goto out;
	}

	fbuf = fb_setup(FUSEFDSIZE + cnp->cn_namelen + 1, dp->ufs_ino.i_number,
	    FBT_UNLINK, p);
	memcpy(fbuf->fb_dat, cnp->cn_nameptr, cnp->cn_namelen);
	fbuf->fb_dat[cnp->cn_namelen] = '\0';

	error = fb_queue(fmp->dev, fbuf);
	if (error) {
		if (error == ENOSYS)
			fmp->undef_op |= UNDEF_REMOVE;

		pool_put(&fusefs_fbuf_pool, fbuf);
		goto out;
	}

	VN_KNOTE(vp, NOTE_DELETE);
	VN_KNOTE(dvp, NOTE_WRITE);
	pool_put(&fusefs_fbuf_pool, fbuf);
out:
	if (dvp == vp)
		vrele(vp);
	else
		vput(vp);
	vput(dvp);
	return (error);
}
Example #20
0
static int mysqlfs_read(const char *path, char *buf, size_t size, off_t offset,
                        struct fuse_file_info *fi)
{
    int ret;
    MYSQL *dbconn;

    log_printf(LOG_D_CALL, "mysqlfs_read(\"%s\" %[email protected]%llu)\n", path, size, offset);

#ifdef STATUSDIR
    /* take a short-circuit for the bogus virtual files */
    if (0 == strncmp (path, status_pathname, len_status_pathname))
    {
        char *a = (char *) path + len_status_pathname;
        log_printf(LOG_D_CALL, "%s(\"%s\")(@%d)\n", __FUNCTION__, a, __LINE__);
        return mysqlfs_status_read(a, buf, size, offset, fi);
    }
#endif
    /* see http://www.macosxhints.com/article.php?story=20060814124808745 */
    if ( (0 < theopts->osxnospotlight) && (0 == strcmp (path, "/.metadata_never_index")))
    {
        char *a = PACKAGE_STRING;				/* in case I cannot point directly to static content */
        int l = MIN(strlen(PACKAGE_STRING)-offset,size);	/* tossaway length calc */
        strncpy (buf, a+offset, l);
        return l;
    }

    if ((dbconn = pool_get()) == NULL)
      return -EMFILE;

    ret = query_read(dbconn, fi->fh, buf, size, offset);
    pool_put(dbconn);

    return ret;
}
Example #21
0
void
ata_free_xfer(struct ata_channel *chp, struct ata_xfer *xfer)
{
	struct atac_softc *atac = chp->ch_atac;
	int s;

	if (xfer->c_flags & C_WAITACT) {
		/* Someone is waiting for this xfer, so we can't free now */
		xfer->c_flags |= C_FREE;
		wakeup(xfer);
		return;
	}

#if NATA_PIOBM		/* XXX wdc dependent code */
	if (xfer->c_flags & C_PIOBM) {
		struct wdc_softc *wdc = CHAN_TO_WDC(chp);

		/* finish the busmastering PIO */
		(*wdc->piobm_done)(wdc->dma_arg,
		    chp->ch_channel, xfer->c_drive);
		chp->ch_flags &= ~(ATACH_DMA_WAIT | ATACH_PIOBM_WAIT | ATACH_IRQ_WAIT);
	}
#endif

	if (atac->atac_free_hw)
		(*atac->atac_free_hw)(chp);
	s = splbio();
	pool_put(&ata_xfer_pool, xfer);
	splx(s);
}
Example #22
0
void
vnet_ldc_reset(struct ldc_conn *lc)
{
	struct vnet_softc *sc = lc->lc_sc;
	int i;

	timeout_del(&sc->sc_handshake_to);
	sc->sc_tx_prod = sc->sc_tx_cons = 0;
	sc->sc_peer_state = VIO_DP_STOPPED;
	sc->sc_vio_state = 0;
	vnet_link_state(sc);

	sc->sc_lm->lm_next = 1;
	sc->sc_lm->lm_count = 1;
	for (i = 1; i < sc->sc_lm->lm_nentries; i++)
		sc->sc_lm->lm_slot[i].entry = 0;

	for (i = 0; i < sc->sc_vd->vd_nentries; i++) {
		if (sc->sc_vsd[i].vsd_buf) {
			pool_put(&sc->sc_pool, sc->sc_vsd[i].vsd_buf);
			sc->sc_vsd[i].vsd_buf = NULL;
		}
		sc->sc_vd->vd_desc[i].hdr.dstate = VIO_DESC_FREE;
	}
}
Example #23
0
void bn_clean(bn_t a) {
#if ALLOC == DYNAMIC
	if (a != NULL) {
		if (a->dp != NULL) {
#if OPSYS == WINDOWS && ALIGN > 1
			_aligned_free(a->dp);
#else
			free(a->dp);
#endif
			a->dp = NULL;
		}
		a->alloc = 0;
	}
#endif
#if ALLOC == STATIC
	if (a != NULL && a->dp != NULL) {
		pool_put(a->dp);
		a->dp = NULL;
	}
#endif
	if (a != NULL) {
		a->used = 0;
		a->sign = BN_POS;
	}
}
Example #24
0
void
rtfree(struct rtentry *rt)
{
	struct ifaddr	*ifa;

	if (rt == NULL)
		panic("rtfree");

	rt->rt_refcnt--;

	if (rt->rt_refcnt <= 0 && (rt->rt_flags & RTF_UP) == 0) {
		if (rt->rt_nodes->rn_flags & (RNF_ACTIVE | RNF_ROOT))
			panic("rtfree 2");
		rttrash--;
		if (rt->rt_refcnt < 0) {
			printf("rtfree: %p not freed (neg refs)\n", rt);
			return;
		}
		rt_timer_remove_all(rt);
		ifa = rt->rt_ifa;
		if (ifa)
			IFAFREE(ifa);
		rtlabel_unref(rt->rt_labelid);
		Free(rt_key(rt));
		pool_put(&rtentry_pool, rt);
	}
}
Example #25
0
struct mbuf *
m_free(struct mbuf *m)
{
	struct mbuf *n;

	if (m == NULL)
		return (NULL);

	mtx_enter(&mbstatmtx);
	mbstat.m_mtypes[m->m_type]--;
	mtx_leave(&mbstatmtx);

	n = m->m_next;
	if (m->m_flags & M_ZEROIZE) {
		m_zero(m);
		/* propagate M_ZEROIZE to the next mbuf in the chain */
		if (n)
			n->m_flags |= M_ZEROIZE;
	}
	if (m->m_flags & M_PKTHDR)
		m_tag_delete_chain(m);
	if (m->m_flags & M_EXT)
		m_extfree(m);

	pool_put(&mbpool, m);

	return (n);
}
Example #26
0
void
rtfree(struct rtentry *rt)
{
	struct ifaddr	*ifa;

	if (rt == NULL)
		panic("rtfree");

	rt->rt_refcnt--;

	if (rt->rt_refcnt <= 0 && (rt->rt_flags & RTF_UP) == 0) {
		if (rt->rt_refcnt == 0 && (rt->rt_nodes->rn_flags & RNF_ACTIVE))
			return; /* route still active but currently down */
		if (rt->rt_nodes->rn_flags & (RNF_ACTIVE | RNF_ROOT))
			panic("rtfree 2");
		rttrash--;
		if (rt->rt_refcnt < 0) {
			printf("rtfree: %p not freed (neg refs)\n", rt);
			return;
		}
		rt_timer_remove_all(rt);
		ifa = rt->rt_ifa;
		if (ifa)
			IFAFREE(ifa);
		rtlabel_unref(rt->rt_labelid);
#ifdef MPLS
		if (rt->rt_flags & RTF_MPLS)
			free(rt->rt_llinfo, M_TEMP);
#endif
		Free(rt_key(rt));
		pool_put(&rtentry_pool, rt);
	}
}
Example #27
0
static void
bt_freetrim(vmem_t *vm, int freelimit)
{
	bt_t *t;
	LIST_HEAD(, vmem_btag) tofree;

	LIST_INIT(&tofree);

	VMEM_LOCK(vm);
	while (vm->vm_nfreetags > freelimit) {
		bt_t *bt = LIST_FIRST(&vm->vm_freetags);
		LIST_REMOVE(bt, bt_freelist);
		vm->vm_nfreetags--;
		if (bt >= static_bts
		    && bt < static_bts + sizeof(static_bts)) {
			mutex_enter(&vmem_btag_lock);
			LIST_INSERT_HEAD(&vmem_btag_freelist, bt, bt_freelist);
			vmem_btag_freelist_count++;
			mutex_exit(&vmem_btag_lock);
			VMEM_EVCNT_DECR(static_bt_inuse);
		} else {
			LIST_INSERT_HEAD(&tofree, bt, bt_freelist);
		}
	}

	VMEM_UNLOCK(vm);
	while (!LIST_EMPTY(&tofree)) {
		t = LIST_FIRST(&tofree);
		LIST_REMOVE(t, bt_freelist);
		pool_put(&vmem_btag_pool, t);
	}
}
Example #28
0
void
tmpfs_dirent_put(struct tmpfs_mount *mp, struct tmpfs_dirent *de)
{

	tmpfs_mem_decr(mp, sizeof(struct tmpfs_dirent));
	pool_put(&tmpfs_dirent_pool, de);
}
Example #29
0
File: o.c Project: yhcting/ylib
void
yodestroy(struct yo *yo) {
	struct o *o = (struct o *)yo;
        oclear(o);
	if (unlikely(!pool_put(o)))
                yfree(o);
}
Example #30
0
static void
close_netmap_if(netmap_main_t * nm, netmap_if_t * nif)
{
  if (nif->unix_file_index != ~0) {
    unix_file_del(&unix_main, unix_main.file_pool + nif->unix_file_index);
    nif->unix_file_index = ~0;
  }

  if (nif->fd > -1)
    close(nif->fd);

  if (nif->mem_region)
    {
      netmap_mem_region_t * reg = &nm->mem_regions[nif->mem_region];
      if (--reg->refcnt == 0)
	{
	  munmap(reg->mem, reg->region_size);
	  reg->region_size = 0;
	}
    }


  mhash_unset(&nm->if_index_by_host_if_name, nif->host_if_name, &nif->if_index);
  vec_free(nif->host_if_name);
  vec_free(nif->req);

  memset(nif, 0, sizeof(*nif));
  pool_put(nm->interfaces, nif);
}