Exemplo n.º 1
0
ATF_TC_BODY(multilayer, tc)
{
	struct union_args unionargs;

	rump_init();

	if (rump_sys_mkdir("/Tunion", 0777) == -1)
		atf_tc_fail_errno("mkdir mp1");
	if (rump_sys_mkdir("/Tunion2", 0777) == -1)
		atf_tc_fail_errno("mkdir mp2");
	if (rump_sys_mkdir("/Tunion2/A", 0777) == -1)
		atf_tc_fail_errno("mkdir A");
	if (rump_sys_mkdir("/Tunion2/B", 0777) == -1)
		atf_tc_fail_errno("mkdir B");

	unionargs.target = __UNCONST("/Tunion2/A");
	unionargs.mntflags = UNMNT_BELOW;

	if (rump_sys_mount(MOUNT_UNION, "/Tunion", 0,
	    &unionargs, sizeof(unionargs)) == -1)
		atf_tc_fail_errno("union mount");

	unionargs.target = __UNCONST("/Tunion2/B");
	unionargs.mntflags = UNMNT_BELOW;

	rump_sys_mount(MOUNT_UNION, "/Tunion", 0,&unionargs,sizeof(unionargs));
}
Exemplo n.º 2
0
int
lfs_fstest_mount(const atf_tc_t *tc, void *buf, const char *path, int flags)
{
	struct lfstestargs *args = buf;
	int res;

	res = rump_sys_mkdir(path, 0777);
	if (res == -1)
		return res;

	res = rump_sys_mount(MOUNT_LFS, path, flags, &args->ta_uargs,
	    sizeof(args->ta_uargs));
	if (res == -1)
		return res;

	strcpy(args->ta_mntpath, path);
	res = pthread_create(&args->ta_cleanerthread, NULL, cleaner, args);
	if (res)
		return res;

	/* wait for cleaner to initialize */
	sem_wait(&args->ta_cleanerloop);

	return 0;
}
Exemplo n.º 3
0
ATF_TC_BODY(devnull2, tc)
{
	struct union_args unionargs;
	int fd, res;

	rump_init();

	if (rump_sys_mkdir("/mp", 0777) == -1)
		atf_tc_fail_errno("mkdir mp");

	unionargs.target = __UNCONST("/dev");
	unionargs.mntflags = UNMNT_BELOW;

	if (rump_sys_mount(MOUNT_UNION, "/mp", 0,
	    &unionargs, sizeof(unionargs)) == -1)
		atf_tc_fail_errno("union mount");

	fd = rump_sys_open("/mp/null", O_WRONLY | O_CREAT | O_APPEND);
	if (fd == -1)
		atf_tc_fail_errno("open");

	res = rump_sys_write(fd, &fd, sizeof(fd));
	if (res != sizeof(fd))
		atf_tc_fail("write");
}
Exemplo n.º 4
0
int
msdosfs_fstest_mount(const atf_tc_t *tc, void *buf, const char *path, int flags)
{
	int res;
	struct msdosfstestargs *args = buf;

	res = rump_sys_mkdir(path, 0777);
	if (res == -1)
		return res;

	res = rump_sys_mount(MOUNT_MSDOS, path, flags, &args->ta_uargs,
	    sizeof(args->ta_uargs));
	return res;
}
Exemplo n.º 5
0
static void
mountptyfs(const char *mp, int flags)
{
	struct ptyfs_args args;

	if (rump_sys_mkdir(mp, 0777) == -1) {
		if (errno != EEXIST)
			atf_tc_fail_errno("null create %s", mp);
	}
	memset(&args, 0, sizeof(args));
	args.version = PTYFS_ARGSVERSION;
	args.mode = 0777;
	if (rump_sys_mount(MOUNT_PTYFS, mp, flags, &args, sizeof(args)) == -1)
		atf_tc_fail_errno("could not mount ptyfs");
}
Exemplo n.º 6
0
int
main(int argc, char *argv[])
{
	struct rump_ufs_args args;
	char imgpath[MAXPATHLEN+1];
	union u u;
	char buf[8192];
	int fd;

	/*
	 * the driver doesn't support endian swapping, so pick image
	 * with matching endianness.
	 */
	u.i = 0x12345678;
	if (u.c == 0x12) {
		snprintf(imgpath, sizeof(imgpath),
		    "%s/%s", argv[1], "sysvbfs_be.img");
	} else {
		snprintf(imgpath, sizeof(imgpath),
		    "%s/%s", argv[1], "sysvbfs_le.img");
	}
		

        rump_init();

#define MYFSDEV "/de-vice"
	rump_pub_etfs_register(MYFSDEV, imgpath, RUMP_ETFS_BLK);
	args.fspec =  (void *)(uintptr_t)MYFSDEV;

	if (rump_sys_mkdir("/mnt", 0755) == -1)
		die("mkdir /mnt");
	if (rump_sys_mount(RUMP_MOUNT_SYSVBFS, "/mnt", RUMP_MNT_RDONLY,
	    &args, sizeof(args)) == -1)
		die("mount");
	if ((fd = rump_sys_open("/mnt/README", 0)) == -1)
		die("open file");
	memset(buf, 0, sizeof(buf));
	if (rump_sys_read(fd, buf, sizeof(buf)) <= 0)
		die("read version");
	if (strcmp(buf, EXPECTED) != 0)
		die("got unexpected result");
	rump_sys_close(fd);
	if (rump_sys_unmount("/mnt", 0) == -1)
		die("unmount failed");

	return 0;
}
Exemplo n.º 7
0
static void
mountnull(const char *what, const char *mp, int flags)
{
	struct null_args nargs;

	if (rump_sys_mkdir(what, 0777) == -1) {
		if (errno != EEXIST)
			atf_tc_fail_errno("null create %s", what);
	}
	if (rump_sys_mkdir(mp, 0777) == -1) {
		if (errno != EEXIST)
			atf_tc_fail_errno("null create %s", mp);
	}
	memset(&nargs, 0, sizeof(nargs));
	nargs.nulla_target = __UNCONST(what);
	if (rump_sys_mount(MOUNT_NULL, mp, flags, &nargs, sizeof(nargs)) == -1)
		atf_tc_fail_errno("could not mount nullfs");
}
Exemplo n.º 8
0
int
main()
{
	char buf[8192];
	int fd;

        rump_init();
	if (rump_sys_mkdir("/kern", 0755) == -1)
		die("mkdir /kern");
	if (rump_sys_mount("kernfs", "/kern", 0, NULL, 0) == -1)
		die("mount kernfs");
	if ((fd = rump_sys_open("/kern/version", 0)) == -1)
		die("open /kern/version");
	printf("\nReading version info from /kern:\n");
	if (rump_sys_read(fd, buf, sizeof(buf)) <= 0)
		die("read version");
	printf("\n%s", buf);
	rump_sys_reboot(0, NULL);

	return 0;
}
Exemplo n.º 9
0
void
rumpkern_demo(void)
{
	char buf[256];
	ssize_t nn;
	int fd, rv;

	printk(KERN_INFO "reading rump kernel version from kernfs/version:\n");
	rv = rump_sys_mkdir("/mnt", 0777);
	BUG_ON(rv == -1);

	rv = rump_sys_mount("kernfs", "/mnt", 0, NULL, 0);
	BUG_ON(rv == -1);

	fd = rump_sys_open("/mnt/version", RUMP_O_RDONLY, 0);
	BUG_ON(rv == -1);

	nn = rump_sys_read(fd, buf, sizeof(buf));
	BUG_ON(nn < 1);
	buf[nn] = '\0';

	printk(KERN_INFO "%s", buf);
}
Exemplo n.º 10
0
static int
mount_struct(_Bool verbose, struct mount_data_s *mntdp)
{
	fsu_fs_t *fs;
	int rv;

	fs = mntdp->mntd_fs;

	/*
	 * Switch the default process to the native syscalls.
	 * The bad thing about this is that it will fail in unobvious
	 * way if programs using this go multithreaded, but worry about
	 * that if it happens.
	 */
	rump_i_know_what_i_am_doing_with_sysents = 1;
	rump_pub_lwproc_sysent_usenative();

	rv = fs->fs_parseargs(mntdp->mntd_argc, mntdp->mntd_argv, fs->fs_args,
	    &(mntdp->mntd_flags), mntdp->mntd_canon_dev, mntdp->mntd_canon_dir);
	if (rv != 0)
		return -1;

	if (rump_sys_mkdir(MOUNT_DIRECTORY, 0777) == -1 && errno != EEXIST)
		err(-1, "mkdir");
	strcpy(mntdp->mntd_canon_dir, MOUNT_DIRECTORY);

	rv = fsu_load_fs(fs->fs_name);

	if (rv == 0) {
		rv = rump_sys_mount(fs->fs_name, mntdp->mntd_canon_dir,
		    mntdp->mntd_flags, fs->fs_args, fs->fs_args_size);
#if 0
		/*
		 * This will result in a lot of spam for fs type autodetection,
		 * so need to come up with a better scheme here.
		 */
		if (rv == -1)
			warn("mount failed");
#endif
	}

	if (rv == 0) {
		/* fork a rump kernel process to chroot() to the mountpoint */
		if ((rv = rump_pub_lwproc_rfork(RUMP_RFCFDG)) != 0) {
			warnx("fork failed!");
			rump_sys_unmount(MOUNT_DIRECTORY, 0);
		} else {
			atexit(fsu_unmount);
			rump_sys_chroot(MOUNT_DIRECTORY);
		}
	}
#ifdef WITH_SMBFS
	if (strcmp(fs->fs_name, MOUNT_SMBFS) == 0) {
		extern struct smb_ctx sctx;

		smb_ctx_done(&sctx);
	}
#endif
	if (rv != 0 && verbose) {
		warn(NULL);
		fprintf(stderr, "%s is not a valid %s image\n",
		    mntdp->mntd_fsdevice, fs->fs_name);
	}

	return rv;
}