当前位置: 首页>>代码示例>>C++>>正文


C++ proc_dostring函数代码示例

本文整理汇总了C++中proc_dostring函数的典型用法代码示例。如果您正苦于以下问题:C++ proc_dostring函数的具体用法?C++ proc_dostring怎么用?C++ proc_dostring使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了proc_dostring函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: schar_read_proc_2

static int schar_read_proc_2(ctl_table *ctl, int write, struct file *file,
			   void *buffer, size_t *lenp, loff_t *ppos)
{
	int len = 0;

	/* someone is writing data to us */
	/* v2.6remove
 	if (write) {
		char *tmp = (char *) get_free_page(GFP_KERNEL);
		//	MSG("proc: someone wrote %u bytes\n", (unsigned)*lenp);
		if (tmp) {
			free_page((unsigned long)tmp);
			file->f_pos += *lenp;
		}
		return 0;
	}
	v2.6remove */
	len += sprintf(schar_proc_string_2, "GIGABIT DRIVER ETH2: mm \n\n");
	len += sprintf(schar_proc_string_2+len, " RECEIVE: \n");
	len += sprintf(schar_proc_string_2+len, "  recieve\t\t%ld packets\n",proc_rpackets_2);
      len += sprintf(schar_proc_string_2+len, "  receive    \t\t\t%04d%09ld bytes\n",proc_rbytesH_2,proc_rbytesL_2); 
      len += sprintf(schar_proc_string_2+len, "  memory  \t\t\t%09ld bytes\n",(BIGPHYS_PAGES_2*PAGE_SIZE));
      len += sprintf(schar_proc_string_2+len, "  rate  \t\t\t%6ld KBits/s \n",proc_rate_2/1000);
      len += sprintf(schar_proc_string_2+len, "  loop %d count %ld\n\n",ring_loop_2,ring_pnt_2);
	len += sprintf(schar_proc_string_2+len, " TRANSMIT: \n");
      len += sprintf(schar_proc_string_2+len, "  transmit\t\t%d packets \n",proc_tpackets_2);
      len += sprintf(schar_proc_string_2+len, "  transmit    \t\t\t%d%08ld bytes\n\n",proc_tbytesH_2,proc_tbytesL_2); 
  	len += sprintf(schar_proc_string_2+len, " ERROR STATISTICS: \n");
      len += sprintf(schar_proc_string_2+len, "  missing packets \t\t%ld\n",proc_pmissing_2);
	*lenp = len;
	return proc_dostring(ctl, write, file, buffer, lenp, ppos);
}
开发者ID:andrewpeck,项目名称:emu,代码行数:32,代码来源:eth_hook_2.c

示例2: schar_read_proc

static int schar_read_proc(ctl_table *ctl, int write, struct file *file,
			   void *buffer, size_t *lenp, loff_t *ppos)
{
	int len = 0;
	
	//	MSG("proc: %s\n", write ? "write" : "read");

	/* someone is writing data to us */
	/* v2.6remove
	if (write) {
		char *tmp = (char *) get_free_page(GFP_KERNEL);
		//	MSG("proc: someone wrote %u bytes\n", (unsigned)*lenp);
		if (tmp) {
		        free_page((unsigned long)tmp);
			file->f_pos += *lenp;
		}
		return 0;
	}
	v2.6remove */
	len += sprintf(schar_proc_string, "GIGABIT DRIVER SIMPLE JTAG\n\n");
	len += sprintf(schar_proc_string+len, " LEFT TO READ: \n");
        len += sprintf(schar_proc_string+len," pack_left\t\t%d packets\n",pack_left); 
	len += sprintf(schar_proc_string+len, " RECEIVE: \n");
	len += sprintf(schar_proc_string+len, "  recieve\t\t%ld packets\n",proc_rpackets);
        len += sprintf(schar_proc_string+len, "  receive    \t\t\t%02d%09ld bytes\n",proc_rbytesH,proc_rbytesL); 
        len += sprintf(schar_proc_string+len, "  memory  \t\t\t%09d bytes\n",MMT_BUF_SIZE);
 	len += sprintf(schar_proc_string+len, " TRANSMIT: \n");
        len += sprintf(schar_proc_string+len, "  transmit\t\t%d packets \n",proc_tpackets);
        len += sprintf(schar_proc_string+len, "  transmit    \t\t\t%02d%09ld bytes\n\n",proc_tbytesH,proc_tbytesL); 
	*lenp = len;
	return proc_dostring(ctl, write, file, buffer, lenp, ppos);
	
	
}
开发者ID:khotilov,项目名称:TAMUDrivers,代码行数:34,代码来源:eth_hook.c

示例3: proc_tcp_fastopen_key

static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
				 void __user *buffer, size_t *lenp,
				 loff_t *ppos)
{
	struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
	struct tcp_fastopen_context *ctxt;
	int ret;
	u32  user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */

	tbl.data = kmalloc(tbl.maxlen, GFP_KERNEL);
	if (!tbl.data)
		return -ENOMEM;

	rcu_read_lock();
	ctxt = rcu_dereference(tcp_fastopen_ctx);
	if (ctxt)
		memcpy(user_key, ctxt->key, TCP_FASTOPEN_KEY_LENGTH);
	else
		memset(user_key, 0, sizeof(user_key));
	rcu_read_unlock();

	snprintf(tbl.data, tbl.maxlen, "%08x-%08x-%08x-%08x",
		user_key[0], user_key[1], user_key[2], user_key[3]);
	ret = proc_dostring(&tbl, write, buffer, lenp, ppos);

	if (write && ret == 0) {
		if (sscanf(tbl.data, "%x-%x-%x-%x", user_key, user_key + 1,
			   user_key + 2, user_key + 3) != 4) {
			ret = -EINVAL;
			goto bad_key;
		}
		/* Generate a dummy secret but don't publish it. This
		 * is needed so we don't regenerate a new key on the
		 * first invocation of tcp_fastopen_cookie_gen
		 */
		tcp_fastopen_init_key_once(false);
		tcp_fastopen_reset_cipher(user_key, TCP_FASTOPEN_KEY_LENGTH);
	}

bad_key:
	pr_debug("proc FO key set 0x%x-%x-%x-%x <- 0x%s: %u\n",
	       user_key[0], user_key[1], user_key[2], user_key[3],
	       (char *)tbl.data, ret);
	kfree(tbl.data);
	return ret;
}

static struct ctl_table ipv4_table[] = {
	{
		.procname	= "tcp_timestamps",
		.data		= &sysctl_tcp_timestamps,
		.maxlen		= sizeof(int),
		.mode		= 0644,
		.proc_handler	= proc_dointvec
	},
	{
		.procname	= "tcp_window_scaling",
开发者ID:19Dan01,项目名称:linux,代码行数:57,代码来源:sysctl_net_ipv4.c

示例4: t1_proc_dostring

// TODO: functions are almost the same, should abstract them to wrapper with proc_handler and data printer parameters
static int t1_proc_dostring(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) {
    int result;

    LOG(LC_PROC, 0, "t1: gona read %s from procfs entry, old value is: %s\n", table->procname, (char*)table->data);
    result = proc_dostring(table, write, buffer, lenp, ppos);
    LOG(LC_PROC, 0, "t1: read %s from procfs, new value is: %s\n", table->procname, (char*)table->data);
    
    return result;
}
开发者ID:eddyz87,项目名称:kernel-dev-exercises,代码行数:10,代码来源:procfs.c

示例5: proc_peer_state

/* /proc/sys entry point for injecting up/down nid event
 * <up|down> <nid>
 */
static int
proc_peer_state(struct ctl_table *table, int write, void __user *buffer,
		size_t *lenp, loff_t *ppos)
{
	int             rc;
	int             nid;
	int             node_down;
	char            command[10];
	ENTRY;

	rc = proc_dostring(table, write, buffer, lenp, ppos);

	if (!write) {
		/* read */
		RETURN(rc);
	}

	if (kgnilnd_data.kgn_init != GNILND_INIT_ALL) {
		rc = -EINVAL;
		RETURN(rc);
	}

	/* convert to nid, up/down values */
	rc = sscanf(kgnilnd_sysctl.ksd_peer_state, "%s %d", command, &nid);
	CDEBUG(D_INFO, "command %s, nid %d\n", command, nid);

	if (rc != 2) {
		CDEBUG(D_ERROR, "invalid parameter\n");
		RETURN(rc);
	} else {
		switch (command[0]) {
		case 'd': /* down */
			node_down = 1;
			CDEBUG(D_INFO, "take node %d down\n", nid);
			break;
		case 'u': /* up */
			node_down = 0;
			CDEBUG(D_INFO, "bring node %d up\n", nid);
			break;
		default:
			CDEBUG(D_ERROR, "invalid command %s\n", command);
			RETURN(-EINVAL);
		}
	}

	CDEBUG(D_INFO, "proc_peer_state: reporting node_down %d, nid %d\n",
		      node_down, nid);
	rc = kgnilnd_report_node_state(nid, node_down);

	if (rc) {
		rc = -EINVAL;
	}

	RETURN(rc);
}
开发者ID:EMSL-MSC,项目名称:lustre-release,代码行数:58,代码来源:gnilnd_sysctl.c

示例6: nf_log_proc_dostring

static int nf_log_proc_dostring(struct ctl_table *table, int write,
			 void __user *buffer, size_t *lenp, loff_t *ppos)
{
	const struct nf_logger *logger;
	char buf[NFLOGGER_NAME_LEN];
	int r = 0;
	int tindex = (unsigned long)table->extra1;
	struct net *net = current->nsproxy->net_ns;

	if (write) {
		struct ctl_table tmp = *table;

		tmp.data = buf;
		r = proc_dostring(&tmp, write, buffer, lenp, ppos);
		if (r)
			return r;

		if (!strcmp(buf, "NONE")) {
			nf_log_unbind_pf(net, tindex);
			return 0;
		}
		mutex_lock(&nf_log_mutex);
		logger = __find_logger(tindex, buf);
		if (logger == NULL) {
			mutex_unlock(&nf_log_mutex);
			return -ENOENT;
		}
		rcu_assign_pointer(net->nf.nf_loggers[tindex], logger);
		mutex_unlock(&nf_log_mutex);
	} else {
		mutex_lock(&nf_log_mutex);
		logger = nft_log_dereference(net->nf.nf_loggers[tindex]);
		if (!logger)
			table->data = "NONE";
		else
			table->data = logger->name;
		r = proc_dostring(table, write, buffer, lenp, ppos);
		mutex_unlock(&nf_log_mutex);
	}

	return r;
}
开发者ID:AK101111,项目名称:linux,代码行数:42,代码来源:nf_log.c

示例7: proc_do_uts_string

/*
 *	Special case of dostring for the UTS structure. This has locks
 *	to observe. Should this be in kernel/sys.c ????
 */
static int proc_do_uts_string(ctl_table *table, int write, struct file *filp,
		  void __user *buffer, size_t *lenp, loff_t *ppos)
{
	struct ctl_table uts_table;
	int r;
	memcpy(&uts_table, table, sizeof(uts_table));
	uts_table.data = get_uts(table, write);
	r = proc_dostring(&uts_table,write,filp,buffer,lenp, ppos);
	put_uts(table, write, uts_table.data);
	return r;
}
开发者ID:LouZiffer,项目名称:m900_kernel_cupcake-SDX,代码行数:15,代码来源:utsname_sysctl.c

示例8: proc_do_rss_key

static int proc_do_rss_key(struct ctl_table *table, int write,
			   void __user *buffer, size_t *lenp, loff_t *ppos)
{
	struct ctl_table fake_table;
	char buf[NETDEV_RSS_KEY_LEN * 3];

	snprintf(buf, sizeof(buf), "%*phC", NETDEV_RSS_KEY_LEN, netdev_rss_key);
	fake_table.data = buf;
	fake_table.maxlen = sizeof(buf);
	return proc_dostring(&fake_table, write, buffer, lenp, ppos);
}
开发者ID:513855417,项目名称:linux,代码行数:11,代码来源:sysctl_net_core.c

示例9: ipv4_ping_group_range

/* Validate changes from /proc interface. */
static int ipv4_ping_group_range(ctl_table *table, int write,
				 void __user *buffer,
				 size_t *lenp, loff_t *ppos)
{
	struct user_namespace *user_ns = current_user_ns();
	int ret;
	gid_t urange[2];
	kgid_t low, high;
	ctl_table tmp = {
		.data = &urange,
		.maxlen = sizeof(urange),
		.mode = table->mode,
		.extra1 = &ip_ping_group_range_min,
		.extra2 = &ip_ping_group_range_max,
	};

	inet_get_ping_group_range_table(table, &low, &high);
	urange[0] = from_kgid_munged(user_ns, low);
	urange[1] = from_kgid_munged(user_ns, high);
	ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);

	if (write && ret == 0) {
		low = make_kgid(user_ns, urange[0]);
		high = make_kgid(user_ns, urange[1]);
		if (!gid_valid(low) || !gid_valid(high) ||
		    (urange[1] < urange[0]) || gid_lt(high, low)) {
			low = make_kgid(&init_user_ns, 1);
			high = make_kgid(&init_user_ns, 0);
		}
		set_ping_group_range(table, low, high);
	}

	return ret;
}

static int proc_tcp_congestion_control(ctl_table *ctl, int write,
				       void __user *buffer, size_t *lenp, loff_t *ppos)
{
	char val[TCP_CA_NAME_MAX];
	ctl_table tbl = {
		.data = val,
		.maxlen = TCP_CA_NAME_MAX,
	};
	int ret;

	tcp_get_default_congestion_control(val);

	ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
	if (write && ret == 0)
		ret = tcp_set_default_congestion_control(val);
	return ret;
}
开发者ID:bjayesh,项目名称:chandra,代码行数:53,代码来源:sysctl_net_ipv4.c

示例10: proc_dolasatstring

/* And the same for proc */
int proc_dolasatstring(ctl_table *table, int write,
		       void *buffer, size_t *lenp, loff_t *ppos)
{
	int r;

	r = proc_dostring(table, write, buffer, lenp, ppos);
	if ((!write) || r)
		return r;

	lasat_write_eeprom_info();

	return 0;
}
开发者ID:Aircell,项目名称:asp-kernel,代码行数:14,代码来源:sysctl.c

示例11: proc_dolasatstring

/* And the same for proc */
int proc_dolasatstring(ctl_table *table, int write, struct file *filp,
                       void *buffer, size_t *lenp, loff_t *ppos)
{
    int r;
    mutex_lock(&lasat_info_mutex);
    r = proc_dostring(table, write, filp, buffer, lenp, ppos);
    if ( (!write) || r) {
        mutex_unlock(&lasat_info_mutex);
        return r;
    }
    lasat_write_eeprom_info();
    mutex_unlock(&lasat_info_mutex);
    return 0;
}
开发者ID:b3rnik,项目名称:dsl-n55u-bender,代码行数:15,代码来源:sysctl.c

示例12: do_devname

static int do_devname(struct ctl_table *table, int write,
		      void __user *buffer, size_t *lenp, loff_t *ppos)
{
	int ret;

	ret = proc_dostring(table, write, buffer, lenp, ppos);
	if (ret == 0 && write) {
		struct ias_value *val;

		val = irias_new_string_value(sysctl_devname);
		if (val)
			irias_object_change_attribute("Device", "DeviceName", val);
	}
	return ret;
}
开发者ID:020gzh,项目名称:linux,代码行数:15,代码来源:irsysctl.c

示例13: proc_do_uts_string

/*
 *	Special case of dostring for the UTS structure. This has locks
 *	to observe. Should this be in kernel/sys.c ????
 */
static int proc_do_uts_string(ctl_table *table, int write,
		  void __user *buffer, size_t *lenp, loff_t *ppos)
{
	struct ctl_table uts_table;
	int r;
	memcpy(&uts_table, table, sizeof(uts_table));
	uts_table.data = get_uts(table, write);
	r = proc_dostring(&uts_table,write,buffer,lenp, ppos);
	put_uts(table, write, uts_table.data);

	if (write)
		proc_sys_poll_notify(table->poll);

	return r;
}
开发者ID:badwtg1111,项目名称:linux-2.6,代码行数:19,代码来源:utsname_sysctl.c

示例14: do_devname

static int do_devname(ctl_table *table, int write, struct file *filp,
		      void *buffer, size_t *lenp)
{
	int ret;

	ret = proc_dostring(table, write, filp, buffer, lenp);
	if (ret == 0 && write) {
		struct ias_value *val;

		val = irias_new_string_value(sysctl_devname);
		if (val)
			irias_object_change_attribute("Device", "DeviceName", val);
	}
	return ret;
}
开发者ID:fgeraci,项目名称:cs518-sched,代码行数:15,代码来源:irsysctl.c

示例15: proc_tcp_available_congestion_control

static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
						 int write,
						 void __user *buffer, size_t *lenp,
						 loff_t *ppos)
{
	struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
	int ret;

	tbl.data = kmalloc(tbl.maxlen, GFP_USER);
	if (!tbl.data)
		return -ENOMEM;
	tcp_get_available_congestion_control(tbl.data, TCP_CA_BUF_MAX);
	ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
	kfree(tbl.data);
	return ret;
}
开发者ID:Cool-Joe,项目名称:imx23-audio,代码行数:16,代码来源:sysctl_net_ipv4.c


注:本文中的proc_dostring函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。