• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ devname函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: ptsname

/*
 * ptsname():  return the pathname of the slave pseudo-terminal device
 *             associated with the specified master.
 */
char*
ptsname(int fildes) {
    static char slave[] = _PATH_DEV PTS_PREFIX "XY";
    static char new_slave[] = _PATH_DEV NEWPTS_PREFIX "4294967295";
    char* retval;
    struct stat sbuf;
    retval = NULL;

    if (_fstat(fildes, &sbuf) == 0) {
        if (!ISPTM(sbuf)) {
            errno = EINVAL;
        } else {
            if (!is_pts(fildes)) {
                (void)snprintf(slave, sizeof(slave),
                               _PATH_DEV PTS_PREFIX "%s",
                               devname(sbuf.st_rdev, S_IFCHR) +
                               strlen(PTM_PREFIX));
                retval = slave;
            } else {
                (void)snprintf(new_slave, sizeof(new_slave),
                               _PATH_DEV NEWPTS_PREFIX "%s",
                               devname(sbuf.st_rdev, S_IFCHR) +
                               strlen(PTM_PREFIX));
                retval = new_slave;
            }
        }
    }

    return (retval);
}
开发者ID:mysticTot,项目名称:learn_c,代码行数:34,代码来源:grantpt.c


示例2: pipetapfd

static int pipetapfd(struct chan *chan, struct fd_tap *tap, int cmd)
{
	int ret;
	Pipe *p;
	int which = 1;
	uint64_t kludge;

	p = chan->aux;
	kludge = (uint64_t)p;
#define DEVPIPE_LEGAL_DATA_TAPS (FDTAP_FILT_READABLE | FDTAP_FILT_WRITABLE | \
                                 FDTAP_FILT_HANGUP | FDTAP_FILT_ERROR)

	switch (NETTYPE(chan->qid.path)) {
	case Qdata0:
		which = 0;
		/* fall through */
	case Qdata1:
		kludge |= which;

		if (tap->filter & ~DEVPIPE_LEGAL_DATA_TAPS) {
			set_errno(ENOSYS);
			set_errstr("Unsupported #%s data tap %p, must be %p", devname(),
			           tap->filter, DEVPIPE_LEGAL_DATA_TAPS);
			return -1;
		}
		spin_lock(&p->tap_lock);
		switch (cmd) {
		case (FDTAP_CMD_ADD):
			if (SLIST_EMPTY(&p->data_taps[which]))
				qio_set_wake_cb(p->q[which], pipe_wake_cb, (void *)kludge);
			SLIST_INSERT_HEAD(&p->data_taps[which], tap, link);
			ret = 0;
			break;
		case (FDTAP_CMD_REM):
			SLIST_REMOVE(&p->data_taps[which], tap, fd_tap, link);
			if (SLIST_EMPTY(&p->data_taps[which]))
				qio_set_wake_cb(p->q[which], 0, (void *)kludge);
			ret = 0;
			break;
		default:
			set_errno(ENOSYS);
			set_errstr("Unsupported #%s data tap command %p", devname(), cmd);
			ret = -1;
		}
		spin_unlock(&p->tap_lock);
		return ret;
	default:
		set_errno(ENOSYS);
		set_errstr("Can't tap #%s file type %d", devname(),
		           NETTYPE(chan->qid.path));
		return -1;
	}
}
开发者ID:GanShun,项目名称:akaros,代码行数:53,代码来源:pipe.c


示例3: open_tun_any

static int open_tun_any(char *dev_name, size_t dev_name_size)
{
	int fd;
	struct stat buf;

	/* Open lowest unused tun device */
	if ((fd = open("/dev/tun", O_RDWR)) != -1) {
		fstat(fd, &buf);
		printf("Using %s\n", devname(buf.st_rdev, S_IFCHR));
		if (dev_name != NULL)
			strlcpy(dev_name, devname(buf.st_rdev, S_IFCHR), dev_name_size);
		return fd;
	}
	return -1;
}
开发者ID:MarvellCan,项目名称:marvell_first,代码行数:15,代码来源:tun.c


示例4: pipegen

static int
pipegen(struct chan *c, char *unused,
		struct dirtab *tab, int ntab, int i, struct dir *dp)
{
	int id, len;
	struct qid qid;
	Pipe *p;

	if (i == DEVDOTDOT) {
		devdir(c, c->qid, devname(), 0, eve, 0555, dp);
		return 1;
	}
	i++;	/* skip . */
	if (tab == 0 || i >= ntab)
		return -1;
	tab += i;
	p = c->aux;
	switch (NETTYPE(tab->qid.path)) {
		case Qdata0:
			len = qlen(p->q[0]);
			break;
		case Qdata1:
			len = qlen(p->q[1]);
			break;
		default:
			len = tab->length;
			break;
	}
	id = NETID(c->qid.path);
	qid.path = NETQID(id, tab->qid.path);
	qid.vers = 0;
	qid.type = QTFILE;
	devdir(c, qid, tab->name, len, eve, tab->perm, dp);
	return 1;
}
开发者ID:GanShun,项目名称:akaros,代码行数:35,代码来源:pipe.c


示例5: AttachHandler

static int CCONV AttachHandler (CPhidgetHandle device, void *userptr) {

    int serialNumber;
    const char *name;

    LocalErrorCatcher(
        CPhidget_getDeviceName(device, &name));
    LocalErrorCatcher(
        CPhidget_getSerialNumber(device, &serialNumber));

    PhidgetsDeviceManager* obj = (PhidgetsDeviceManager*)userptr;

    QString devname(name);


    // If the device name contains motor control in its name then emit a motor control card signal
    if(devname.contains("Motor Control"))
    {
        obj->pushToMotorControlCardSerials(serialNumber);
       // emit obj->motorCard(serialNumber);

    }
    else if(devname.contains("InterfaceKit"))
    {
        obj->setInterfaceKitSerial(serialNumber);
    }



    printf("Hello Device %s, Serial Number: %d\n", name, serialNumber);

    return 0;
}
开发者ID:hkaraoguz,项目名称:PhidgetsGUI,代码行数:33,代码来源:phidgetsdevicemanager.cpp


示例6: tap_open

int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required)
{
    int fd;
    char *dev;
    struct stat s;

#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
    /* if no ifname is given, always start the search from tap0. */
    int i;
    char dname[100];

    for (i = 0; i < 10; i++) {
        if (*ifname) {
            snprintf(dname, sizeof dname, "/dev/%s", ifname);
        } else {
            snprintf(dname, sizeof dname, "/dev/tap%d", i);
        }
        TFR(fd = open(dname, O_RDWR));
        if (fd >= 0) {
            break;
        }
        else if (errno == ENXIO || errno == ENOENT) {
            break;
        }
        if (*ifname) {
            break;
        }
    }
    if (fd < 0) {
        error_report("warning: could not open %s (%s): no virtual network emulation",
                     dname, strerror(errno));
        return -1;
    }
#else
    TFR(fd = open("/dev/tap", O_RDWR));
    if (fd < 0) {
        fprintf(stderr, "warning: could not open /dev/tap: no virtual network emulation\n");
        return -1;
    }
#endif

    fstat(fd, &s);
    dev = devname(s.st_rdev, S_IFCHR);
    pstrcpy(ifname, ifname_size, dev);

    if (*vnet_hdr) {
        /* BSD doesn't have IFF_VNET_HDR */
        *vnet_hdr = 0;

        if (vnet_hdr_required && !*vnet_hdr) {
            error_report("vnet_hdr=1 requested, but no kernel "
                         "support for IFF_VNET_HDR available");
            close(fd);
            return -1;
        }
    }
    fcntl(fd, F_SETFL, O_NONBLOCK);
    return fd;
}
开发者ID:EgoIncarnate,项目名称:qemu-rr,代码行数:59,代码来源:tap-bsd.c


示例7: stat2proc

/* return 1 if it works, or 0 for failure */
static gboolean
stat2proc (pid_t        pid,
           CkProcessStat *P)
{
        struct kinfo_proc2 p;
        char              *ttname;
        int               num;
        int               tty_maj;
        int               tty_min;

        if (! get_kinfo_proc (pid, &p)) {
                return FALSE;
        }

        num = KI_MAXCOMLEN;
        if (num >= sizeof(P->cmd)) {
                num = sizeof(P->cmd) - 1;
        }

        memcpy (P->cmd, p.p_comm, num);

        P->cmd[num]   = '\0';
        P->pid        = p.p_pid;
        P->ppid       = p.p_ppid;
        P->pgrp       = p.p__pgid;
        P->session    = p.p_sid;
        P->rss        = p.p_vm_rssize;
        P->vsize      = p.p_vm_dsize + p.p_vm_dsize + p.p_vm_ssize; /* XXX */
        P->start_time = p.p_ustart_sec;
        P->wchan      = (unsigned long) p.p_wchan;
        P->state      = p.p_stat;
        P->nice       = p.p_nice;
        P->flags      = p.p_realflag;
        P->tpgid      = p.p_tpgid;
        P->processor  = p.p_cpuid;
        P->nlwp       = p.p_nlwps;

        /* we like it Linux-encoded :-) */
        tty_maj = major (p.p_tdev);
        tty_min = minor (p.p_tdev);
        P->tty = DEV_ENCODE (tty_maj,tty_min);

        snprintf (P->tty_text, sizeof(P->tty_text), "%3d,%-3d", tty_maj, tty_min);

        if (p.p_tdev != NODEV && (ttname = devname (p.p_tdev, S_IFCHR)) != NULL) {
                memcpy (P->tty_text, ttname, sizeof(P->tty_text));
        }

        if (p.p_tdev == NODEV) {
                /* XXXJDM nasty hack */
                memcpy (P->tty_text, "/dev/ttyE4", sizeof(P->tty_text));
        }

        if (P->pid != pid) {
                return FALSE;
        }

        return TRUE;
}
开发者ID:carriercomm,项目名称:pkgsrc-wip,代码行数:60,代码来源:ck-sysdeps-netbsd.c


示例8: error

static struct chan *rootattach(char *spec)
{
	struct chan *c;
	if (*spec)
		error(EINVAL, ERROR_FIXME);
	c = devattach(devname(), spec);
	mkqid(&c->qid, roottab[0].qid.path, roottab[0].qid.vers, QTDIR);
	return c;
}
开发者ID:anandab,项目名称:akaros,代码行数:9,代码来源:root.c


示例9: TunName

/* Get the name of the tun device using file descriptor */
void TunName(int tunfd, char *name) {
  struct stat sbuf;
  char *internal_buffer;
  
  if (fstat(tunfd,&sbuf) != -1) {
    internal_buffer = devname(sbuf.st_rdev, S_IFCHR);
    strcpy(name,internal_buffer);
  }
}
开发者ID:springware,项目名称:92u10,代码行数:10,代码来源:tsp_tun.c


示例10: kprofattach

static struct chan*
kprofattach(char *spec)
{
	// Did we initialise completely?
	if ( !(oprof_alarms && kprof.buf && kprof.systrace) )
		error(ENOMEM, NULL);

	return devattach(devname(), spec);
}
开发者ID:AlffiTheBerry,项目名称:akaros,代码行数:9,代码来源:kprof.c


示例11: SYSTEM_SWAP_SIZE

int	SYSTEM_SWAP_SIZE(AGENT_REQUEST *request, AGENT_RESULT *result)
{
/*
 *  FreeBSD 7.0 i386
 */
#ifdef XSWDEV_VERSION	/* defined in <vm/vm_param.h> */
	char		*swapdev, *mode;
	int		mib[16], *mib_dev;
	size_t		sz, mib_sz;
	struct xswdev	xsw;
	zbx_uint64_t	total = 0, used = 0;

	if (2 < request->nparam)
		return SYSINFO_RET_FAIL;

	swapdev = get_rparam(request, 0);
	mode = get_rparam(request, 1);

	sz = ARRSIZE(mib);
	if (-1 == sysctlnametomib("vm.swap_info", mib, &sz))
		return FAIL;

	mib_sz = sz + 1;
	mib_dev = &(mib[sz]);

	*mib_dev = 0;
	sz = sizeof(xsw);

	while (-1 != sysctl(mib, mib_sz, &xsw, &sz, NULL, 0))
	{
		if (NULL == swapdev || '\0' == *swapdev || 0 == strcmp(swapdev, "all")	/* default parameter */
				|| 0 == strcmp(swapdev, devname(xsw.xsw_dev, S_IFCHR)))
		{
			total += (zbx_uint64_t)xsw.xsw_nblks;
			used += (zbx_uint64_t)xsw.xsw_used;
		}
		(*mib_dev)++;
	}

	if (NULL == mode || '\0' == *mode || 0 == strcmp(mode, "free"))	/* default parameter */
		SET_UI64_RESULT(result, (total - used) * getpagesize());
	else if (0 == strcmp(mode, "total"))
		SET_UI64_RESULT(result, total * getpagesize());
	else if (0 == strcmp(mode, "used"))
		SET_UI64_RESULT(result, used * getpagesize());
	else if (0 == strcmp(mode, "pfree"))
		SET_DBL_RESULT(result, total ? ((double)(total - used) * 100.0 / (double)total) : 0.0);
	else if (0 == strcmp(mode, "pused"))
		SET_DBL_RESULT(result, total ? ((double)used * 100.0 / (double)total) : 0.0);
	else
		return SYSINFO_RET_FAIL;

	return SYSINFO_RET_OK;
#else
	return SYSINFO_RET_FAIL;
#endif
}
开发者ID:Metalaria,项目名称:Zabbix_,代码行数:57,代码来源:swap.c


示例12: dm_format_dev

int dm_format_dev(char *buf, int bufsize, uint32_t dev_major,
		  uint32_t dev_minor)
{
	int r;
	uint32_t major, dm_major;
	char *name;
	mode_t mode;
	dev_t dev;
	size_t val_len,i;
	struct kinfo_drivers *kd;

	mode = 0;

	nbsd_get_dm_major(&dm_major, DM_BLOCK_MAJOR);

	if (bufsize < 8)
		return 0;

	if (sysctlbyname("kern.drivers",NULL,&val_len,NULL,0) < 0) {
		printf("sysctlbyname failed");
		return 0;
	}

	if ((kd = malloc (val_len)) == NULL){
		printf("malloc kd info error\n");
		return 0;
	}

	if (sysctlbyname("kern.drivers", kd, &val_len, NULL, 0) < 0) {
		printf("sysctlbyname failed kd");
		return 0;
	}

	for (i = 0, val_len /= sizeof(*kd); i < val_len; i++){
		if (kd[i].d_cmajor == dev_major) {
			major = kd[i].d_bmajor;
			break;
		}
	}

	dev = MKDEV(major,dev_minor);

	mode |= S_IFBLK;

	if ((name = devname(dev,mode)) == NULL)
		name = get_dev_name(kd[i].d_name, major, dev_minor);

	r = snprintf(buf, (size_t) bufsize, "/dev/%s",name);

	free(kd);

	if (r < 0 || r > bufsize - 1 || name == NULL)
		return 0;

	return 1;
}
开发者ID:ajinkya93,项目名称:netbsd-src,代码行数:56,代码来源:libdm-nbsd-iface.c


示例13: regressattach

static struct chan*
regressattach(char *spec)
{
	uint32_t n;

	regress.monitor = qopen(2 << 20, 0, 0, 0);
	if (! regress.monitor) {
		printk("monitor allocate failed. No monitor output\n");
	}
	return devattach(devname(), spec);
}
开发者ID:GanShun,项目名称:akaros,代码行数:11,代码来源:regress.c


示例14: udev_device_get_devnode

const char *
udev_device_get_devnode(struct udev_device *udev_device)
{
	dev_t devnum;

	devnum = udev_device_get_devnum(udev_device);
	if (devnum == 0)
		return 0;

	return devname(devnum, S_IFCHR);
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:11,代码来源:devattr_device.c


示例15: TunName

// --------------------------------------------------------------------------
// TunName: Get the name of the tun device using file descriptor.
//
void TunName(int tunfd, char *name, size_t name_len )
{
    struct stat sbuf;
    char *unsafe_buffer;

    if( fstat( tunfd, &sbuf ) != -1 )
    {
        unsafe_buffer = devname(sbuf.st_rdev, S_IFCHR);
        strncpy( name, unsafe_buffer, name_len );
    }
}
开发者ID:h4ck3rm1k3,项目名称:gw6c-debian,代码行数:14,代码来源:tsp_tun.c


示例16: main

int main()
{
  int rssi;
  char name[248];

  if ( 0 == devname( BLUETOOTH_DEVICE, name, 248 ) ) {
    printf( "Unit = %s Devicename = %s\n", BLUETOOTH_DEVICE, name );
  }
  read_rssi( BLUETOOTH_DEVICE, &rssi );
  printf( "Unit = %s RSSI = %d\n", BLUETOOTH_DEVICE, rssi );

  return 0;
}
开发者ID:davidlcamlin,项目名称:vscp_software,代码行数:13,代码来源:btproximity.c


示例17: longtname

void
longtname(const struct kinfo_proc *kp, VARENT *ve)
{
	VAR *v;
	dev_t dev;
	char *ttname;

	v = ve->var;
	dev = kp->p_tdev;
	if (dev == NODEV || (ttname = devname(dev, S_IFCHR)) == NULL)
		(void)printf("%-*s", v->width, "??");
	else
		(void)printf("%-*s", v->width, ttname);
}
开发者ID:Open343,项目名称:bitrig,代码行数:14,代码来源:print.c


示例18: show

static void
show(int v, int n)
{
	struct vnd_user vnu;
	char *dev;
	struct statvfs *mnt;
	int i, nmount;

	vnu.vnu_unit = n;
	if (ioctl(v, VNDIOCGET, &vnu) == -1)
		err(1, "VNDIOCGET");

	if (vnu.vnu_ino == 0) {
		printf("vnd%d: not in use\n", vnu.vnu_unit);
		return;
	}

	printf("vnd%d: ", vnu.vnu_unit);

	dev = devname(vnu.vnu_dev, S_IFBLK);
	if (dev != NULL)
		nmount = getmntinfo(&mnt, MNT_NOWAIT);
	else {
		mnt = NULL;
		nmount = 0;
	}

	if (mnt != NULL) {
		for (i = 0; i < nmount; i++) {
			if (strncmp(mnt[i].f_mntfromname, "/dev/", 5) == 0 &&
			    strcmp(mnt[i].f_mntfromname + 5, dev) == 0)
				break;
		}
		if (i < nmount)
			printf("%s (%s) ", mnt[i].f_mntonname,
			    mnt[i].f_mntfromname);
		else
			printf("%s ", dev);
	}
	else if (dev != NULL)
		printf("%s ", dev);
	else
		printf("dev %llu,%llu ",
		    (unsigned long long)major(vnu.vnu_dev),
		    (unsigned long long)minor(vnu.vnu_dev));

	printf("inode %llu\n", (unsigned long long)vnu.vnu_ino);
}
开发者ID:marklee77,项目名称:frankenlibc,代码行数:48,代码来源:vnconfig.c


示例19: devname

void BusAssignmentManager::State::listAttachedPCIDevices(std::vector<ComPtr<IPCIDeviceAttachment> > &aAttached)
{
    aAttached.resize(mPCIMap.size());

    size_t i = 0;
    ComObjPtr<PCIDeviceAttachment> dev;
    for (PCIMap::const_iterator it = mPCIMap.begin(); it !=  mPCIMap.end(); ++it, ++i)
    {
        dev.createObject();
        com::Bstr devname(it->second.szDevName);
        dev->init(NULL, devname,
                  it->second.HostAddress.valid() ? it->second.HostAddress.asLong() : -1,
                  it->first.asLong(), it->second.HostAddress.valid());
        dev.queryInterfaceTo(aAttached[i].asOutParam());
    }
}
开发者ID:sobomax,项目名称:virtualbox_64bit_edd,代码行数:16,代码来源:BusAssignmentManager.cpp


示例20: ERRSTACK

/*
 *  create a pipe, no streams are created until an open
 */
static struct chan *pipeattach(char *spec)
{
	ERRSTACK(2);
	Pipe *p;
	struct chan *c;

	c = devattach(devname(), spec);
	p = kzmalloc(sizeof(Pipe), 0);
	if (p == 0)
		error(ENOMEM, ERROR_FIXME);
	if (waserror()) {
		freepipe(p);
		nexterror();
	}
	p->pipedir = kzmalloc(sizeof(pipedir), 0);
	if (p->pipedir == 0)
		error(ENOMEM, ERROR_FIXME);
	memmove(p->pipedir, pipedir, sizeof(pipedir));
	kstrdup(&p->user, current->user);
	kref_init(&p->ref, pipe_release, 1);
	qlock_init(&p->qlock);

	p->q[0] = qopen(pipealloc.pipeqsize, Qcoalesce, 0, 0);
	if (p->q[0] == 0)
		error(ENOMEM, ERROR_FIXME);
	p->q[1] = qopen(pipealloc.pipeqsize, Qcoalesce, 0, 0);
	if (p->q[1] == 0)
		error(ENOMEM, ERROR_FIXME);
	poperror();

	spin_lock(&(&pipealloc)->lock);
	p->path = ++pipealloc.path;
	spin_unlock(&(&pipealloc)->lock);

	c->qid.path = NETQID(2 * p->path, Qdir);
	c->qid.vers = 0;
	c->qid.type = QTDIR;
	c->aux = p;
	c->dev = 0;

	/* taps. */
	SLIST_INIT(&p->data_taps[0]);	/* already = 0; set to be futureproof */
	SLIST_INIT(&p->data_taps[1]);
	spinlock_init(&p->tap_lock);
	return c;
}
开发者ID:GanShun,项目名称:akaros,代码行数:49,代码来源:pipe.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ devopen函数代码示例发布时间:2022-05-30
下一篇:
C++ devm_snd_soc_register_component函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap