Beispiel #1
0
static void
makeonenode(char *buf, size_t len, devmajor_t blk, devmajor_t chr,
    devminor_t dmin, const char *base, int c1, int c2)
{
	char cstr1[2] = {0,0}, cstr2[2] = {0,0};
	register_t rv;
	int error;

	if (c1 != -1) {
		cstr1[0] = '0' + c1;
		cstr1[1] = '\0';
	}

	if (c2 != -1) {
		cstr2[0] = 'a' + c2;
		cstr2[1] = '\0';

	}

	/* block device */
	snprintf(buf, len, "/dev/%s%s%s", base, cstr1, cstr2);
	if (blk != NODEVMAJOR) {
		switch (doesitexist(buf, true, blk, dmin)) {
		case DIFFERENT:
			aprint_verbose("mkdevnodes: block device %s "
			    "already exists\n", buf);
			break;
		case NOTEXIST:
			if ((error = do_sys_mknod(curlwp, buf, 0600 | S_IFBLK,
			    makedev(blk, dmin), &rv, UIO_SYSSPACE)) != 0)
				aprint_verbose("mkdevnodes: failed to "
				    "create %s: %d\n", buf, error);
			break;
		case SAME:
			/* done */
			break;
		}
		snprintf(buf, len, "/dev/r%s%s%s", base, cstr1, cstr2);
	}

	switch (doesitexist(buf, true, chr, dmin)) {
	case DIFFERENT:
		aprint_verbose("mkdevnodes: character device %s "
		    "already exists\n", buf);
		break;
	case NOTEXIST:
		if ((error = do_sys_mknod(curlwp, buf, 0600 | S_IFCHR,
		    makedev(chr, dmin), &rv, UIO_SYSSPACE)) != 0)
			aprint_verbose("mkdevnodes: failed to "
			    "create %s: %d\n", buf, error);
		break;
	case SAME:
		/* yeehaa */
		break;
	}
}
Beispiel #2
0
static int
makedevnodes(dev_t devtype, const char *basename, char minchar,
	devmajor_t maj, devminor_t minnum, int nnodes)
{
	int error = 0;
	char *devname, *p;
	size_t devlen;
	register_t retval;

	devlen = strlen(basename) + 1 + 1; /* +letter +0 */
	devname = kmem_zalloc(devlen, KM_SLEEP);
	strlcpy(devname, basename, devlen);
	p = devname + devlen-2;

	for (; nnodes > 0; nnodes--, minchar++, minnum++) {
		KASSERT(minchar <= 'z');
		*p = minchar;

		if ((error = do_sys_mknod(curlwp, devname, 0666 | devtype,
		    makedev(maj, minnum), &retval, UIO_SYSSPACE))) {
			if (error == EEXIST)
				error = 0;
			else
				goto out;
		}
	}

 out:
	kmem_free(devname, devlen);
	return error;
}
int
compat_50_netbsd32_mknod(struct lwp *l,
    const struct compat_50_netbsd32_mknod_args *uap, register_t *retval)
{
	/* {
		syscallarg(netbsd32_charp) path;
		syscallarg(mode_t) mode;
		syscallarg(uint32_t) dev;
	} */
	return do_sys_mknod(l, SCARG_P32(uap, path), SCARG(uap, mode),
	    SCARG(uap, dev), retval, UIO_USERSPACE);
}
Beispiel #4
0
/* realqvik(tm) "devfs" */
static int
makeonedevnode(dev_t devtype, const char *devname,
	devmajor_t majnum, devminor_t minnum)
{
	register_t retval;
	int error;

	error = do_sys_mknod(curlwp, devname, 0666 | devtype,
	    makedev(majnum, minnum), &retval, UIO_SYSSPACE);
	if (error == EEXIST) /* XXX: should check it's actually the same */
		error = 0;

	return error;
}