Пример #1
0
int cmd_vfs_exec(struct vmm_chardev *cdev, int argc, char **argv)
{
	u32 off, len;
	physical_addr_t pa;
	if (argc < 2) {
		cmd_vfs_usage(cdev);
		return VMM_EFAIL;
	}
	if (strcmp(argv[1], "help") == 0) {
		cmd_vfs_usage(cdev);
		return VMM_OK;
	} else if ((strcmp(argv[1], "fslist") == 0) && (argc == 2)) {
		return cmd_vfs_fslist(cdev);
	} else if ((strcmp(argv[1], "mplist") == 0) && (argc == 2)) {
		return cmd_vfs_mplist(cdev);
	} else if ((strcmp(argv[1], "mount") == 0) && (argc == 4)) {
		return cmd_vfs_mount(cdev, argv[2], argv[3]);
	} else if ((strcmp(argv[1], "umount") == 0) && (argc == 3)) {
		return cmd_vfs_umount(cdev, argv[2]);
	} else if ((strcmp(argv[1], "ls") == 0) && (argc == 3)) {
		return cmd_vfs_ls(cdev, argv[2]);
	} else if ((strcmp(argv[1], "cat") == 0) && (argc == 3)) {
		return cmd_vfs_cat(cdev, argv[2]);
	} else if ((strcmp(argv[1], "mv") == 0) && (argc == 4)) {
		return cmd_vfs_mv(cdev, argv[2], argv[3]);
	} else if ((strcmp(argv[1], "rm") == 0) && (argc == 3)) {
		return cmd_vfs_rm(cdev, argv[2]);
	} else if ((strcmp(argv[1], "mkdir") == 0) && (argc == 3)) {
		return cmd_vfs_mkdir(cdev, argv[2]);
	} else if ((strcmp(argv[1], "rmdir") == 0) && (argc == 3)) {
		return cmd_vfs_rmdir(cdev, argv[2]);
	} else if ((strcmp(argv[1], "load") == 0) && (argc > 3)) {
		pa = (physical_addr_t)strtoull(argv[2], NULL, 0);
		off = (argc > 4) ? strtoul(argv[4], NULL, 0) : 0;
		len = (argc > 5) ? strtoul(argv[5], NULL, 0) : 0xFFFFFFFF;
		return cmd_vfs_load(cdev, pa, argv[3], off, len);
	}
	cmd_vfs_usage(cdev);
	return VMM_EFAIL;
}
Пример #2
0
static int cmd_vfs_exec(struct vmm_chardev *cdev, int argc, char **argv)
{
	u32 off, len;
	physical_addr_t pa;
	struct vmm_guest *guest;
	if (argc < 2) {
		cmd_vfs_usage(cdev);
		return VMM_EFAIL;
	}
	if (strcmp(argv[1], "help") == 0) {
		cmd_vfs_usage(cdev);
		return VMM_OK;
	} else if ((strcmp(argv[1], "fslist") == 0) && (argc == 2)) {
		return cmd_vfs_fslist(cdev);
	} else if ((strcmp(argv[1], "mplist") == 0) && (argc == 2)) {
		return cmd_vfs_mplist(cdev);
	} else if ((strcmp(argv[1], "mount") == 0) && (argc == 4)) {
		return cmd_vfs_mount(cdev, argv[2], argv[3]);
	} else if ((strcmp(argv[1], "umount") == 0) && (argc == 3)) {
		return cmd_vfs_umount(cdev, argv[2]);
	} else if ((strcmp(argv[1], "ls") == 0) && (argc == 3)) {
		return cmd_vfs_ls(cdev, argv[2]);
	} else if ((strcmp(argv[1], "run") == 0) && (argc == 3)) {
		return cmd_vfs_run(cdev, argv[2]);
#if CONFIG_CRYPTO_HASH_MD5
	} else if ((strcmp(argv[1], "md5") == 0) && (argc == 3)) {
		return cmd_vfs_md5(cdev, argv[2]);
#endif
#if CONFIG_CRYPTO_HASH_SHA256
	} else if ((strcmp(argv[1], "sha256") == 0) && (argc == 3)) {
		return cmd_vfs_sha256(cdev, argv[2]);
#endif
	} else if ((strcmp(argv[1], "cat") == 0) && (argc == 3)) {
		return cmd_vfs_cat(cdev, argv[2]);
	} else if ((strcmp(argv[1], "mv") == 0) && (argc == 4)) {
		return cmd_vfs_mv(cdev, argv[2], argv[3]);
	} else if ((strcmp(argv[1], "rm") == 0) && (argc == 3)) {
		return cmd_vfs_rm(cdev, argv[2]);
	} else if ((strcmp(argv[1], "mkdir") == 0) && (argc == 3)) {
		return cmd_vfs_mkdir(cdev, argv[2]);
	} else if ((strcmp(argv[1], "rmdir") == 0) && (argc == 3)) {
		return cmd_vfs_rmdir(cdev, argv[2]);
	} else if ((strcmp(argv[1], "fdt_load") == 0) && (argc >= 5)) {
		return cmd_vfs_fdt_load(cdev, argv[2], argv[3], argv[4],
					argc-5, (argc-5) ? &argv[5] : NULL);
	} else if ((strcmp(argv[1], "host_load") == 0) && (argc > 3)) {
		pa = (physical_addr_t)strtoull(argv[2], NULL, 0);
		off = (argc > 4) ? strtoul(argv[4], NULL, 0) : 0;
		len = (argc > 5) ? strtoul(argv[5], NULL, 0) : 0xFFFFFFFF;
		return cmd_vfs_load(cdev, NULL, pa, argv[3], off, len);
	} else if ((strcmp(argv[1], "host_load_list") == 0) && (argc == 3)) {
		return cmd_vfs_load_list(cdev, NULL, argv[2]);
	} else if ((strcmp(argv[1], "guest_load") == 0) && (argc > 4)) {
		guest = vmm_manager_guest_find(argv[2]);
		if (!guest) {
			vmm_cprintf(cdev, "Failed to find guest %s\n",
				    argv[2]);
			return VMM_ENOTAVAIL;
		}
		pa = (physical_addr_t)strtoull(argv[3], NULL, 0);
		off = (argc > 5) ? strtoul(argv[5], NULL, 0) : 0;
		len = (argc > 6) ? strtoul(argv[6], NULL, 0) : 0xFFFFFFFF;
		return cmd_vfs_load(cdev, guest, pa, argv[4], off, len);
	} else if ((strcmp(argv[1], "guest_load_list") == 0) && (argc == 4)) {
		guest = vmm_manager_guest_find(argv[2]);
		if (!guest) {
			vmm_cprintf(cdev, "Failed to find guest %s\n",
				    argv[2]);
			return VMM_ENOTAVAIL;
		}
		return cmd_vfs_load_list(cdev, guest, argv[3]);
	}
	cmd_vfs_usage(cdev);
	return VMM_EFAIL;
}