Esempio n. 1
0
/* The input function for a log buffer.  */
static int
ms_buffer_input (void *closure, char *data, size_t need, size_t size,
		 size_t *got)
{
    struct ms_buffer *mb = closure;
    int status;

    assert (mb->cur->input);
    status = (*mb->cur->input) (mb->cur->closure, data, need, size, got);
    if (status == -1)
    {
	Node *p;
	/* EOF.  Set up the next buffer in line but return success and no
	 * data since our caller may have selected on the target to find
	 * ready data before calling us.
	 *
	 * If there are no more buffers, return EOF.
	 */
	if (list_isempty (mb->bufs)) return -1;
	buf_shutdown (mb->cur);
	buf_free (mb->cur);
	p = mb->bufs->list->next;
	mb->cur = p->data;
	p->delproc = NULL;
	p->data = NULL;
	delnode (p);
	if (!buf_empty_p (mb->cur)) buf_append_buffer (mb->buf, mb->cur);
	ms_buffer_block (closure, mb->block);
	*got = 0;
	status = 0;
    }

    return status;
}
Esempio n. 2
0
/* FsMountVol : mount the file system volume */
INT32 FsMountVol(struct super_block *sb)
{
	INT32 err, drv;

	sm_P(&z_sem);

	for (drv = 0; drv < MAX_DRIVE; drv++) {
		if (!fs_struct[drv].mounted) break;
	}

	if (drv >= MAX_DRIVE) {
		err = FFS_ERROR;
		goto ret_unlock;
	}

	sm_P(&(fs_struct[drv].v_sem));

	err = buf_init(sb);
	if (!err) {
		err = ffsMountVol(sb, drv);
	}

	sm_V(&(fs_struct[drv].v_sem));

	if (!err) {
		fs_struct[drv].mounted = TRUE;
		fs_struct[drv].sb = sb;
	} else {
		buf_shutdown(sb);
	}
ret_unlock:
	sm_V(&z_sem);

	return(err);
} /* end of FsMountVol */
Esempio n. 3
0
/* The shutdown function for a log buffer.  */
static int
log_buffer_shutdown (struct buffer *buf)
{
    struct log_buffer *lb = buf->closure;

    log_buffer_closelog (buf);
    return buf_shutdown (lb->buf);
}
Esempio n. 4
0
/* The shutdown function for a multi-source buffer.  */
static int
ms_buffer_shutdown (struct buffer *buf)
{
    struct ms_buffer *mb = buf->closure;
    Node *p;
    int err = 0;

    assert (mb->cur);
    err += buf_shutdown (mb->cur);
    buf_free (mb->cur);
    for (p = mb->bufs->list->next; p != mb->bufs->list; p = p->next)
    {
	assert (p);
	err += buf_shutdown (p->data);
    }

    dellist (&mb->bufs);
    return err;
}
Esempio n. 5
0
/* FsMountVol : mount the file system volume */
int FsMountVol(struct super_block *sb)
{
	int err;

	sm_P(&z_sem);

	err = buf_init(sb);
	if (!err)
		err = ffsMountVol(sb);
	else
		buf_shutdown(sb);

	sm_V(&z_sem);

	return err;
} /* end of FsMountVol */
Esempio n. 6
0
INT32 FsMountVol(struct super_block *sb)
{
	INT32 err, drv;

	sm_P(&z_sem);

	for (drv = 0; drv < MAX_DRIVE; drv++) {
		if (!fs_struct[drv].mounted) break;
	}

	if (drv >= MAX_DRIVE) {

		/*
		 * LGE_CHANGE_S
		 * Date     : 2015.03.05
		 * Author   : [email protected]
		 * Comment  : Release semaphore (z_sem) in error condition.
		 *  In case of attaching storage more than MAX_DRIVE(2),
		 *  mount fails and no more access on exFAT.
		 */
		printk(KERN_ERR "%s: drv : %d, MAX_DRIVE : %d\n",
				__func__, drv, MAX_DRIVE);
		sm_V(&z_sem);
		return FFS_ERROR;
	}

	sm_P(&(fs_struct[drv].v_sem));

	err = buf_init(sb);
	if (!err) {
		err = ffsMountVol(sb, drv);
	}

	sm_V(&(fs_struct[drv].v_sem));

	if (!err) {
		fs_struct[drv].mounted = TRUE;
		fs_struct[drv].sb = sb;
	} else {
		buf_shutdown(sb);
	}

	sm_V(&z_sem);

	return(err);
}
Esempio n. 7
0
/* Shut down an output buffer.  */
static int
compress_buffer_shutdown_output (struct buffer *buf)
{
    struct compress_buffer *cb = buf->closure;
    int zstatus, status;

    /* This is only used within the while loop below, but allocated here for
     * efficiency.
     */
    static char *buffer = NULL;
    if (!buffer)
	buffer = pagealign_xalloc (BUFFER_DATA_SIZE);

    do
    {
	cb->zstr.avail_out = BUFFER_DATA_SIZE;
	cb->zstr.next_out = (unsigned char *) buffer;

	zstatus = deflate (&cb->zstr, Z_FINISH);
	if (zstatus != Z_OK && zstatus != Z_STREAM_END)
	{
	    compress_error (0, zstatus, &cb->zstr, "deflate finish");
	    return EIO;
	}

	if (cb->zstr.avail_out != BUFFER_DATA_SIZE)
	    buf_output (cb->buf, buffer,
			BUFFER_DATA_SIZE - cb->zstr.avail_out);
    } while (zstatus != Z_STREAM_END);

    zstatus = deflateEnd (&cb->zstr);
    if (zstatus != Z_OK)
    {
	compress_error (0, zstatus, &cb->zstr, "deflateEnd");
	return EIO;
    }

    status = buf_flush (cb->buf, 1);
    if (status != 0)
	return status;

    return buf_shutdown (cb->buf);
}
Esempio n. 8
0
/* FsUmountVol : unmount the file system volume */
int FsUmountVol(struct super_block *sb)
{
	int err;
	FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);

	sm_P(&z_sem);

	/* acquire the lock for file system critical section */
	sm_P(&p_fs->v_sem);

	err = ffsUmountVol(sb);
	buf_shutdown(sb);

	/* release the lock for file system critical section */
	sm_V(&p_fs->v_sem);

	sm_V(&z_sem);

	return err;
} /* end of FsUmountVol */
Esempio n. 9
0
/* Shut down an input buffer.  */
static int
compress_buffer_shutdown_input (struct buffer *buf)
{
    struct compress_buffer *cb = buf->closure;
    int zstatus;

    /* Don't make any attempt to pick up trailing data since we are shutting
     * down.  If the client doesn't know we are shutting down, we might not
     * see the EOF we are expecting.
     */

    zstatus = inflateEnd (&cb->zstr);
    if (zstatus != Z_OK)
    {
	compress_error (0, zstatus, &cb->zstr, "inflateEnd");
	return EIO;
    }

    return buf_shutdown (cb->buf);
}
Esempio n. 10
0
INT32 FsUmountVol(struct super_block *sb)
{
	INT32 err;
	FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);

	sm_P(&z_sem);

	sm_P(&(fs_struct[p_fs->drv].v_sem));

	err = ffsUmountVol(sb);
	buf_shutdown(sb);

	sm_V(&(fs_struct[p_fs->drv].v_sem));

	fs_struct[p_fs->drv].mounted = FALSE;
	fs_struct[p_fs->drv].sb = NULL;

	sm_V(&z_sem);

	return(err);
}
Esempio n. 11
0
/* FsUmountVol : unmount the file system volume */
INT32 FsUmountVol(struct super_block *sb)
{
	INT32 err;
	FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);

	sm_P(&z_sem);

	/* acquire the lock for file system critical section */
	sm_P(&(fs_struct[p_fs->drv].v_sem));

	err = ffsUmountVol(sb);
	buf_shutdown(sb);

	/* release the lock for file system critical section */
	sm_V(&(fs_struct[p_fs->drv].v_sem));

	fs_struct[p_fs->drv].mounted = FALSE;
	fs_struct[p_fs->drv].sb = NULL;

	sm_V(&z_sem);

	return(err);
} /* end of FsUmountVol */