예제 #1
0
int op_create (const char *path, mode_t mode, struct fuse_file_info *fi)
{
	int rt;
	ext2_filsys e2fs = current_ext2fs();

	debugf("enter");
	debugf("path = %s, mode: 0%o", path, mode);

	if (op_open(path, fi) == 0) {
		debugf("leave");
		return 0;
	}

	rt = do_create(e2fs, path, mode, 0, NULL);
	if (rt != 0) {
		return rt;
	}

	if (op_open(path, fi)) {
		debugf("op_open(path, fi); failed");
		return -EIO;
	}

	debugf("leave");
	return 0;
}
예제 #2
0
파일: player.c 프로젝트: ayoucai/cmus
static int change_sf(int drop)
{
	int old_sf = buffer_sf;
	CHANNEL_MAP(old_channel_map);
	channel_map_copy(old_channel_map, buffer_channel_map);

	set_buffer_sf();
	if (buffer_sf != old_sf || !channel_map_equal(buffer_channel_map, old_channel_map, sf_get_channels(buffer_sf))) {
		/* reopen */
		int rc;

		if (drop)
			op_drop();
		op_close();
		rc = op_open(buffer_sf, buffer_channel_map);
		if (rc) {
			player_op_error(rc, "opening audio device");
			__consumer_status_update(CS_STOPPED);
			__producer_stop();
			return rc;
		}
	} else if (consumer_status == CS_PAUSED) {
		op_drop();
		op_unpause();
	}
	__consumer_status_update(CS_PLAYING);
	return 0;
}
예제 #3
0
파일: player.c 프로젝트: ayoucai/cmus
/*
 * change output plugin without stopping playback
 */
void player_set_op(const char *name)
{
	int rc;

	player_lock();

	/* drop needed because close drains the buffer */
	if (consumer_status == CS_PAUSED)
		op_drop();

	if (consumer_status == CS_PLAYING || consumer_status == CS_PAUSED)
		op_close();

	if (name) {
		d_print("setting op to '%s'\n", name);
		rc = op_select(name);
	} else {
		/* first initialized plugin */
		d_print("selecting first initialized op\n");
		rc = op_select_any();
	}
	if (rc) {
		__consumer_status_update(CS_STOPPED);

		__producer_stop();
		if (name)
			player_op_error(rc, "selecting output plugin '%s'", name);
		else
			player_op_error(rc, "selecting any output plugin");
		player_unlock();
		return;
	}

	if (consumer_status == CS_PLAYING || consumer_status == CS_PAUSED) {
		set_buffer_sf();
		rc = op_open(buffer_sf, buffer_channel_map);
		if (rc) {
			__consumer_status_update(CS_STOPPED);
			__producer_stop();
			player_op_error(rc, "opening audio device");
			player_unlock();
			return;
		}
		if (consumer_status == CS_PAUSED)
			op_pause();
	}

	player_unlock();
}
예제 #4
0
파일: player.c 프로젝트: ayoucai/cmus
static void __consumer_play(void)
{
	if (consumer_status == CS_PLAYING) {
		op_drop();
	} else if (consumer_status == CS_STOPPED) {
		int rc;

		set_buffer_sf();
		rc = op_open(buffer_sf, buffer_channel_map);
		if (rc) {
			player_op_error(rc, "opening audio device");
		} else {
			__consumer_status_update(CS_PLAYING);
		}
	} else if (consumer_status == CS_PAUSED) {
		op_unpause();
		__consumer_status_update(CS_PLAYING);
	}
}
예제 #5
0
bool	open_source_file (void)
{

	static readonly unsigned char open_params_list[] =
        {
		(unsigned char)iop_readonly,
                (unsigned char)iop_eol
        };

	mstr		fstr;
	int		status, n,index;
	parse_blk	pblk;
	char		*p, buff[MAX_FBUFF + 1];
	time_t		clock;
	struct stat	statbuf;
	mval		val;
	mval		pars;
	error_def	(ERR_FILEPARSE);

	memset(&pblk, 0, sizeof(pblk));
	pblk.buffer = buff;
	pblk.buff_size = MAX_FBUFF;
	pblk.fop = F_SYNTAXO;
	fstr.addr = (char *)source_file_name;
	fstr.len = source_name_len;
	status = parse_file(&fstr, &pblk);
	if (!(status & 1))
		rts_error(VARLSTCNT(5) ERR_FILEPARSE, 2, fstr.len, fstr.addr, status);

	pars.mvtype = MV_STR;
	pars.str.len = sizeof(open_params_list);
	pars.str.addr = (char *)open_params_list;
	val.mvtype = MV_STR;
	val.str.len = source_name_len;
	val.str.addr = (char *)source_file_name;
	op_open(&val, &pars, 0, 0);
	dev_in_use = io_curr_device;	/*	save list file info in use if it is opened	*/
	op_use(&val, &pars);
	compile_src_dev = io_curr_device;

	if (tt_so_do_once)
	{
		clock = time(0);
		memcpy(&routine_name[0], "MDEFAULT", sizeof("MDEFAULT") - 1);
		memcpy(&module_name[0], "MDEFAULT", sizeof("MDEFAULT") - 1);
	} else
	{
		STAT_FILE((char *)&source_file_name[0], &statbuf, status);
		assert(status == 0);
		clock = statbuf.st_mtime;
		p = pblk.l_name;
		n = pblk.b_name;
		if (n > sizeof(mident))
			n = sizeof(mident);
		index = 0;
		if ('_' == *p)
		{
			routine_name[index] = '%';
			module_name[index] = '_';
			p++; index++;
		}
		for (; index < n; index++)
			routine_name[index] = module_name[index] = *p++;
		for (; index < (sizeof(mident)); index++ )
			routine_name[index] = module_name[index] = 0;
	}
	p = (char *)GTM_CTIME(&clock);
	memcpy (rev_time_buf, p + 4, sizeof(rev_time_buf));

	io_curr_device = dev_in_use;	/*	set it back to make open_list_file save the device	*/
	return TRUE;
}
예제 #6
0
void open_ceprep_file(void)
{
#ifdef VMS
/* stub except for VMS */
#ifdef __ALPHA
# pragma member_alignment save
# pragma nomember_alignment
#endif
	static readonly struct
	{
		unsigned char	newversion;
		unsigned char	wrap;
		unsigned char	width;
		int4		v_width;
		unsigned char	eol;
	} open_params_list =
	{
		(unsigned char)	iop_newversion,
		(unsigned char)	iop_wrap,
		(unsigned char)	iop_recordsize,
		(int4)		MAX_SRCLINE,
		(unsigned char)	iop_eol
	};
#ifdef __ALPHA
# pragma member_alignment restore
#endif
	int		mname_len;
	uint4		status;
	char		charspace, ceprep_name_buff[sizeof(mident) + sizeof(".MCI") - 1], fname[255];
	mval		file, params;
	struct NAM	ceprep_nam;	/* name block for file access block for compiler escape preprocessor output */

	/* Create cepreprocessor output file. */
	ceprep_fab = cc$rms_fab;
	ceprep_fab.fab$l_dna = ceprep_name_buff;
	mname_len = mid_len(module_name);
	assert(mname_len <= sizeof(mident));
	if (0 == mname_len)
	{
		memcpy(ceprep_name_buff, "MDEFAULT.MCI", sizeof("MDEFAULT.MCI") - 1);
		ceprep_fab.fab$b_dns = sizeof("MDEFAULT.MCI") - 1;
	} else
	{
		memcpy(ceprep_name_buff, module_name, mname_len);
		memcpy(&ceprep_name_buff[mname_len], ".MCI", sizeof(".MCI") - 1);
		ceprep_fab.fab$b_dns = mname_len + sizeof(".MCI") - 1;
	}
	if (MV_DEFINED(&cmd_qlf.ceprep_file))
	{
		ceprep_fab.fab$b_fns = cmd_qlf.ceprep_file.str.len;
		ceprep_fab.fab$l_fna = cmd_qlf.ceprep_file.str.addr;
	}
	ceprep_nam = cc$rms_nam;
	ceprep_nam.nam$l_esa = fname;
	ceprep_nam.nam$b_ess = sizeof(fname);
	ceprep_nam.nam$b_nop = (NAM$M_SYNCHK);
	ceprep_fab.fab$l_nam = &ceprep_nam;
	ceprep_fab.fab$l_fop = FAB$M_NAM;
	if (RMS$_NORMAL != (status = sys$parse(&ceprep_fab, 0, 0)))
		rts_error(VARLSTCNT(1) status);
	file.mvtype = params.mvtype = MV_STR;
	file.str.len = ceprep_nam.nam$b_esl;
	file.str.addr = fname;
	params.str.len = sizeof(open_params_list);
	params.str.addr = &open_params_list;
	op_open(&file, &params, CEPREP_OPEN_TIMEOUT, 0);
	params.str.len = 1;
	charspace = (char)iop_eol;
	params.str.addr = &charspace;
	dev_in_use = io_curr_device;
	op_use(&file, &params);
#endif
	return;
}
예제 #7
0
bool	open_source_file (void)
{
	mstr		fstr;
	int		status, n;
	parse_blk	pblk;
	char		*p, buff[MAX_FBUFF + 1];
	time_t		clock;
	struct stat	statbuf;
	mval		val;
	mval		pars;
	unsigned short	clen;

	memset(&pblk, 0, SIZEOF(pblk));
	pblk.buffer = buff;
	pblk.buff_size = MAX_FBUFF;
	pblk.fop = F_SYNTAXO;
	fstr.addr = (char *)source_file_name;
	fstr.len = source_name_len;
	status = parse_file(&fstr, &pblk);
	if (!(status & 1))
		rts_error_csa(CSA_ARG(NULL) VARLSTCNT(5) ERR_FILEPARSE, 2, fstr.len, fstr.addr, status);
	pars.mvtype = MV_STR;
	pars.str.len = SIZEOF(open_params_list);
	pars.str.addr = (char *)open_params_list;
	val.mvtype = MV_STR;
	val.str.len = source_name_len;
	val.str.addr = (char *)source_file_name;
	op_open(&val, &pars, 0, 0);
	dev_in_use = io_curr_device;	/*	save list file info in use if it is opened	*/
	op_use(&val, &pars);
	compile_src_dev = io_curr_device;
	if (tt_so_do_once)
	{
		clock = time(0);
		p = "MDEFAULT";
		n = STR_LIT_LEN("MDEFAULT");
	} else
	{
		STAT_FILE((char *)source_file_name, &statbuf, status);
		assert(status == 0);
		clock = statbuf.st_mtime;
		p = pblk.l_name;
		n = pblk.b_name;
		if (n > MAX_MIDENT_LEN)
			n = MAX_MIDENT_LEN;
	}
	/* routine_name is the internal name of the routine (with '%' translated to '_') which can be
	 * different from module_name if the NAMEOFRTN parm is used (by trigger compilation code).
	 * module_name is the external file name of the module (file.m, file.o).
	 * int_module_name is the external symbol that gets exposed (in the GTM context) and is normally
	 * the same as module_name except when NAMEOFRTN is specified in which case it takes on the
	 * untranslated value of routine_name.
	 */
	memcpy(module_name.addr, p, n);
	module_name.len = n;
	if (!(cmd_qlf.qlf & CQ_NAMEOFRTN))
	{
		memcpy(routine_name.addr, p, n);
		routine_name.len = n;
	} else
	{	/* Routine name specified */
		clen = MAX_MIDENT_LEN;
		cli_get_str("NAMEOFRTN", routine_name.addr, &clen);
		routine_name.len = MIN(clen, MAX_MIDENT_LEN);
		cmd_qlf.qlf &= ~CQ_NAMEOFRTN;	/* Can only be used for first module in list */
	}
	memcpy(int_module_name.addr, routine_name.addr, routine_name.len);
	int_module_name.len = routine_name.len;
	if ('_' == *routine_name.addr)
		routine_name.addr[0] = '%';
	GTM_CTIME(p, &clock);
	memcpy(rev_time_buf, p + 4, REV_TIME_BUFF_LEN);
	io_curr_device = dev_in_use;	/*	set it back to make open_list_file save the device	*/
	return TRUE;
}