本文整理汇总了C++中devattach函数的典型用法代码示例。如果您正苦于以下问题:C++ devattach函数的具体用法?C++ devattach怎么用?C++ devattach使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了devattach函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sdattach
static Chan*
sdattach(char* spec)
{
Chan *c;
char *p;
SDev *sdev;
int idno, subno;
if(*spec == '\0'){
c = devattach(sddevtab.dc, spec);
mkqid(&c->qid, QID(0, 0, 0, Qtopdir), 0, QTDIR);
return c;
}
if(spec[0] != 's' || spec[1] != 'd')
error(Ebadspec);
idno = spec[2];
subno = strtol(&spec[3], &p, 0);
if(p == &spec[3])
error(Ebadspec);
if((sdev=sdgetdev(idno)) == nil)
error(Enonexist);
if(sdgetunit(sdev, subno) == nil){
decref(&sdev->r);
error(Enonexist);
}
c = devattach(sddevtab.dc, spec);
mkqid(&c->qid, QID(sdev->idno, subno, 0, Qunitdir), 0, QTDIR);
c->dev = (sdev->idno << UnitLOG) + subno;
decref(&sdev->r);
return c;
}
示例2: srvattach
static Chan*
srvattach(char *spec)
{
Chan *c;
SrvFile *d;
char srvname[16];
qlock(&dev.l);
if(waserror()){
qunlock(&dev.l);
nexterror();
}
if(spec[0] != '\0'){
for(d = dev.devices; d != nil; d = d->devlist){
if(strcmp(spec, d->spec) == 0){
if(!srvcanattach(d))
error(Eperm);
c = devattach('s', spec);
c->aux = d;
c->qid = d->qid;
d->ref++;
poperror();
qunlock(&dev.l);
return c;
}
}
}
d = malloc(sizeof(SrvFile));
if(d == nil)
error(Enomem);
d->ref = 1;
kstrdup(&d->spec, spec);
kstrdup(&d->user, up->env->user);
snprint(srvname, sizeof(srvname), "srv%ld", up->env->pgrp->pgrpid);
kstrdup(&d->name, srvname);
d->perm = DMDIR|0770;
mkqid(&d->qid, dev.pathgen++, 0, QTDIR);
d->devlist = dev.devices;
dev.devices = d;
poperror();
qunlock(&dev.l);
c = devattach('s', spec);
c->aux = d;
c->qid = d->qid;
return c;
}
示例3: fsattach
static Chan*
fsattach(char *spec)
{
struct stat st;
Chan *c;
UnixFd *ufd;
int dev;
dev = 1;
if(spec && spec[0]){
snprint(up->genbuf, sizeof up->genbuf, "no file system #%C%s", FsChar, spec);
error(up->genbuf);
}
if(stat("/", &st) < 0)
oserror();
c = devattach(FsChar, 0);
ufd = mallocz(sizeof(UnixFd), 1);
ufd->path = newpath("/");
ufd->fd = -1;
c->aux = ufd;
c->dev = dev;
c->qid = fsqid(&st);
if(Trace)
print("fsattach /\n");
return c;
}
示例4: consattach
static Chan*
consattach(char *spec)
{
static int kp;
if(kp == 0 && !dflag) {
int i;
kp = 1;
if(eventfiles != NULL) {
for(i = 0; eventfiles[i] != NULL; i++) {
int *event_num = malloc(sizeof(int));
char buf[40];
snprintf(buf, 40, "events%d", i);
if(i >= MAX_EVENTFDS) {
// temporary
fprintf(stderr, "too many event devices\n");
break;
}
eventfds[i] = open(eventfiles[i], O_RDONLY);
if(eventfds[i] == -1) {
perror("could not open event device");
}
*event_num = i;
kproc(buf, eventslave, event_num, 0);
}
}
kproc("kbd", kbdslave, 0, 0);
}
return devattach('c', spec);
}
示例5: pipeattach
/*
* create a pipe, no streams are created until an open
*/
static Chan*
pipeattach(char *spec)
{
Pipe *p;
Chan *c;
c = devattach('|', spec);
p = malloc(sizeof(Pipe));
if(p == 0)
exhausted("memory");
p->ref = 1;
p->q[0] = qopen(Pipeqsize, 0, 0, 0);
if(p->q[0] == 0){
free(p);
exhausted("memory");
}
p->q[1] = qopen(Pipeqsize, 0, 0, 0);
if(p->q[1] == 0){
free(p->q[0]);
free(p);
exhausted("memory");
}
lock(&pipealloc);
p->path = ++pipealloc.path;
unlock(&pipealloc);
mkqid(&c->qid, PIPEQID(2*p->path, Qdir), 0, QTDIR);
c->aux = p;
c->devno = 0;
return c;
}
示例6: lm78attach
static Chan*
lm78attach(char* spec)
{
lm78enable();
return devattach(lm78devtab.dc, spec);
}
示例7: pmcattach
static Chan *
pmcattach(char *spec)
{
if (pmctab == nil)
error(Enomem);
return devattach(L'ε', spec);
}
示例8: vgaattach
static Chan*
vgaattach(char* spec)
{
if(*spec && strcmp(spec, "0"))
error(Eio);
return devattach('v', spec);
}
示例9: eiaattach
static Chan*
eiaattach(char *spec)
{
if(eiadir == nil)
error(Enodev);
return devattach(Devchar, spec);
}
示例10: mouseattach
static Chan*
mouseattach(char *spec)
{
if(!conf.monitor)
error(Egreg);
curs = arrow;
Cursortocursor(&arrow);
return devattach('m', spec);
}
示例11: 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;
}
示例12: 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);
}
示例13: consattach
static Chan*
consattach(char *spec)
{
static int kp;
if(kp == 0 && !dflag) {
kp = 1;
kproc("kbd", kbdslave, 0, 0);
}
return devattach('c', spec);
}
示例14: 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);
}
示例15: ipattach
Chan *
ipattach(char *spec)
{
Chan *c;
c = devattach('I', spec);
c->qid.path = QID(0, 0, Qtopdir);
c->qid.type = QTDIR;
c->qid.vers = 0;
return c;
}