当前位置: 首页>>代码示例>>C++>>正文


C++ run_command函数代码示例

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


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

示例1: do_diag


//.........这里部分代码省略.........
			return 0;
		}
		else if (strncmp(argv[1],"reset-type", 10) == 0)
		{
			uint8_t cause;

			mmc_get_hw_reset_reason(&cause);
			printf("reset-type: ");
			switch (cause) {
			case 0x1:
				printf("hard reset");
				break;
			case 0x2:
				printf("soft reset");
				break;
			case 0x4:
				printf("watchdog reset");
				break;
			default:
				printf("unknown 0x%02x",cause);
				break;
			}
			printf("\n");

			return 0;
		}
		else if (strncmp(argv[1],"i2c", 3) == 0)
		{
                        char cmd[255], *subcmd[]={"speed", "dev", "probe"};

                        for (i = 0; i < sizeof(subcmd)/sizeof(subcmd[0]); i++)
                        {
				sprintf(cmd, "i2c %s", subcmd[i]);
                                run_command(cmd, 0);
                        }

			return 0;
		}
		else if (strncmp(argv[1],"xaui", 4) == 0)
		{
#define XAUI_INTERFACES	2
#define TEST_IP		"192.168.4.1"
			int default_port[] = {2624, 3136};

			/* save original env vars */
			orig_ethact = getenv("ethact");
			sprintf(ca_ethact, orig_ethact); // save to safety place
			orig_ipaddr = getenv("ipaddr");
			sprintf(ca_ipaddr, orig_ipaddr);

			/* start to test */
			setenv("ipaddr", TEST_IP);
			NetPingIP = string_to_ip(TEST_IP); // ping our self
			for (i = 0; i < XAUI_INTERFACES; i++)
			{
				char *new_ethact = "octeth ";

				sprintf(new_ethact, "octeth%d", i);
				setenv("ethact", new_ethact);

				/* enabling internal loopback */
				if (cvmx_helper_configure_loopback(default_port[i], 1, 0))
				{
					printf("enable %s loopback failed!\n", new_ethact);
					continue;
				}
开发者ID:ryanSie,项目名称:Advantech,代码行数:67,代码来源:cmd_adv_diag.c

示例2: fetch_populated_submodules

int fetch_populated_submodules(const struct argv_array *options,
			       const char *prefix, int command_line_option,
			       int quiet)
{
	int i, result = 0;
	struct child_process cp;
	struct argv_array argv = ARGV_ARRAY_INIT;
	struct string_list_item *name_for_path;
	const char *work_tree = get_git_work_tree();
	if (!work_tree)
		goto out;

	if (read_cache() < 0)
		die("index file corrupt");

	argv_array_push(&argv, "fetch");
	for (i = 0; i < options->argc; i++)
		argv_array_push(&argv, options->argv[i]);
	argv_array_push(&argv, "--recurse-submodules-default");
	/* default value, "--submodule-prefix" and its value are added later */

	memset(&cp, 0, sizeof(cp));
	cp.env = local_repo_env;
	cp.git_cmd = 1;
	cp.no_stdin = 1;

	calculate_changed_submodule_paths();

	for (i = 0; i < active_nr; i++) {
		struct strbuf submodule_path = STRBUF_INIT;
		struct strbuf submodule_git_dir = STRBUF_INIT;
		struct strbuf submodule_prefix = STRBUF_INIT;
		const struct cache_entry *ce = active_cache[i];
		const char *git_dir, *name, *default_argv;

		if (!S_ISGITLINK(ce->ce_mode))
			continue;

		name = ce->name;
		name_for_path = unsorted_string_list_lookup(&config_name_for_path, ce->name);
		if (name_for_path)
			name = name_for_path->util;

		default_argv = "yes";
		if (command_line_option == RECURSE_SUBMODULES_DEFAULT) {
			struct string_list_item *fetch_recurse_submodules_option;
			fetch_recurse_submodules_option = unsorted_string_list_lookup(&config_fetch_recurse_submodules_for_name, name);
			if (fetch_recurse_submodules_option) {
				if ((intptr_t)fetch_recurse_submodules_option->util == RECURSE_SUBMODULES_OFF)
					continue;
				if ((intptr_t)fetch_recurse_submodules_option->util == RECURSE_SUBMODULES_ON_DEMAND) {
					if (!unsorted_string_list_lookup(&changed_submodule_paths, ce->name))
						continue;
					default_argv = "on-demand";
				}
			} else {
				if ((config_fetch_recurse_submodules == RECURSE_SUBMODULES_OFF) ||
				    gitmodules_is_unmerged)
					continue;
				if (config_fetch_recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND) {
					if (!unsorted_string_list_lookup(&changed_submodule_paths, ce->name))
						continue;
					default_argv = "on-demand";
				}
			}
		} else if (command_line_option == RECURSE_SUBMODULES_ON_DEMAND) {
			if (!unsorted_string_list_lookup(&changed_submodule_paths, ce->name))
				continue;
			default_argv = "on-demand";
		}

		strbuf_addf(&submodule_path, "%s/%s", work_tree, ce->name);
		strbuf_addf(&submodule_git_dir, "%s/.git", submodule_path.buf);
		strbuf_addf(&submodule_prefix, "%s%s/", prefix, ce->name);
		git_dir = read_gitfile(submodule_git_dir.buf);
		if (!git_dir)
			git_dir = submodule_git_dir.buf;
		if (is_directory(git_dir)) {
			if (!quiet)
				printf("Fetching submodule %s%s\n", prefix, ce->name);
			cp.dir = submodule_path.buf;
			argv_array_push(&argv, default_argv);
			argv_array_push(&argv, "--submodule-prefix");
			argv_array_push(&argv, submodule_prefix.buf);
			cp.argv = argv.argv;
			if (run_command(&cp))
				result = 1;
			argv_array_pop(&argv);
			argv_array_pop(&argv);
			argv_array_pop(&argv);
		}
		strbuf_release(&submodule_path);
		strbuf_release(&submodule_git_dir);
		strbuf_release(&submodule_prefix);
	}
	argv_array_clear(&argv);
out:
	string_list_clear(&changed_submodule_paths, 1);
	return result;
}
开发者ID:carleeto,项目名称:git,代码行数:100,代码来源:submodule.c

示例3: write_bcb

static void write_bcb(const struct bootloader_message * const bcb)
{
	sprintf(buf, "mmcinit 1; fatsave mmc 1:5 0x%08x BCB", bcb);
	run_command(buf, 0);
}
开发者ID:succulent,项目名称:acclaim_cyanoboot,代码行数:5,代码来源:mmc.c

示例4: parse_pack_header

static const char *unpack(int err_fd, struct shallow_info *si)
{
	struct pack_header hdr;
	struct argv_array av = ARGV_ARRAY_INIT;
	const char *hdr_err;
	int status;
	char hdr_arg[38];
	struct child_process child;
	int fsck_objects = (receive_fsck_objects >= 0
			    ? receive_fsck_objects
			    : transfer_fsck_objects >= 0
			    ? transfer_fsck_objects
			    : 0);

	hdr_err = parse_pack_header(&hdr);
	if (hdr_err) {
		if (err_fd > 0)
			close(err_fd);
		return hdr_err;
	}
	snprintf(hdr_arg, sizeof(hdr_arg),
			"--pack_header=%"PRIu32",%"PRIu32,
			ntohl(hdr.hdr_version), ntohl(hdr.hdr_entries));

	if (si->nr_ours || si->nr_theirs) {
		alt_shallow_file = setup_temporary_shallow(si->shallow);
		argv_array_pushl(&av, "--shallow-file", alt_shallow_file, NULL);
	}

	memset(&child, 0, sizeof(child));
	if (ntohl(hdr.hdr_entries) < unpack_limit) {
		argv_array_pushl(&av, "unpack-objects", hdr_arg, NULL);
		if (quiet)
			argv_array_push(&av, "-q");
		if (fsck_objects)
			argv_array_push(&av, "--strict");
		child.argv = av.argv;
		child.no_stdout = 1;
		child.err = err_fd;
		child.git_cmd = 1;
		status = run_command(&child);
		if (status)
			return "unpack-objects abnormal exit";
	} else {
		int s;
		char keep_arg[256];

		s = sprintf(keep_arg, "--keep=receive-pack %"PRIuMAX" on ", (uintmax_t) getpid());
		if (gethostname(keep_arg + s, sizeof(keep_arg) - s))
			strcpy(keep_arg + s, "localhost");

		argv_array_pushl(&av, "index-pack",
				 "--stdin", hdr_arg, keep_arg, NULL);
		if (fsck_objects)
			argv_array_push(&av, "--strict");
		if (fix_thin)
			argv_array_push(&av, "--fix-thin");
		child.argv = av.argv;
		child.out = -1;
		child.err = err_fd;
		child.git_cmd = 1;
		status = start_command(&child);
		if (status)
			return "index-pack fork failed";
		pack_lockfile = index_pack_lockfile(child.out);
		close(child.out);
		status = finish_command(&child);
		if (status)
			return "index-pack abnormal exit";
		reprepare_packed_git();
	}
	return NULL;
}
开发者ID:1974kpkpkp,项目名称:git,代码行数:73,代码来源:receive-pack.c

示例5: native_remove_cmd

jboolean native_remove_cmd(JNIEnv* env, jclass clazz, jstring name) {
    if (!name)
        return JNI_FALSE;
    const char *path = (*env)->GetStringUTFChars(env, name, NULL);
    return run_command("rm -r %s", path) >= 0;
}
开发者ID:xufeifandj,项目名称:My-Launcher,代码行数:6,代码来源:lewa_shell.c

示例6: rsync_transport_push

static int rsync_transport_push(struct transport *transport,
		int refspec_nr, const char **refspec, int flags)
{
	struct strbuf buf = STRBUF_INIT, temp_dir = STRBUF_INIT;
	int result = 0, i;
	struct child_process rsync;
	const char *args[10];

	if (flags & TRANSPORT_PUSH_MIRROR)
		return error("rsync transport does not support mirror mode");

	/* first push the objects */

	strbuf_addstr(&buf, rsync_url(transport->url));
	strbuf_addch(&buf, '/');

	memset(&rsync, 0, sizeof(rsync));
	rsync.argv = args;
	rsync.stdout_to_stderr = 1;
	i = 0;
	args[i++] = "rsync";
	args[i++] = "-a";
	if (flags & TRANSPORT_PUSH_DRY_RUN)
		args[i++] = "--dry-run";
	if (transport->verbose > 0)
		args[i++] = "-v";
	args[i++] = "--ignore-existing";
	args[i++] = "--exclude";
	args[i++] = "info";
	args[i++] = get_object_directory();
	args[i++] = buf.buf;
	args[i++] = NULL;

	if (run_command(&rsync))
		return error("Could not push objects to %s",
				rsync_url(transport->url));

	/* copy the refs to the temporary directory; they could be packed. */

	strbuf_addstr(&temp_dir, git_path("rsync-refs-XXXXXX"));
	if (!mkdtemp(temp_dir.buf))
		die ("Could not make temporary directory");
	strbuf_addch(&temp_dir, '/');

	if (flags & TRANSPORT_PUSH_ALL) {
		if (for_each_ref(write_one_ref, &temp_dir))
			return -1;
	} else if (write_refs_to_temp_dir(&temp_dir, refspec_nr, refspec))
		return -1;

	i = 2;
	if (flags & TRANSPORT_PUSH_DRY_RUN)
		args[i++] = "--dry-run";
	if (!(flags & TRANSPORT_PUSH_FORCE))
		args[i++] = "--ignore-existing";
	args[i++] = temp_dir.buf;
	args[i++] = rsync_url(transport->url);
	args[i++] = NULL;
	if (run_command(&rsync))
		result = error("Could not push to %s",
				rsync_url(transport->url));

	if (remove_dir_recursively(&temp_dir, 0))
		warning ("Could not remove temporary directory %s.",
				temp_dir.buf);

	strbuf_release(&buf);
	strbuf_release(&temp_dir);

	return result;
}
开发者ID:AndyA,项目名称:git-andya,代码行数:71,代码来源:transport.c

示例7: continue_logging_in

CS_RETCODE
continue_logging_in(CS_CONTEXT ** ctx, CS_CONNECTION ** conn, CS_COMMAND ** cmd, int verbose)
{
	CS_RETCODE ret;
	char query[30];
#ifdef TDS_STATIC_CAST
	TDSCONTEXT *tds_ctx;
#endif

	ret = cs_ctx_alloc(CS_VERSION_100, ctx);
	if (ret != CS_SUCCEED) {
		if (verbose) {
			fprintf(stderr, "Context Alloc failed!\n");
		}
		return ret;
	}

#ifdef TDS_STATIC_CAST
	/* Force default date format, some tests rely on it */
	tds_ctx = (TDSCONTEXT *) (*ctx)->tds_ctx;
	if (tds_ctx && tds_ctx->locale && tds_ctx->locale->date_fmt) {
		free(tds_ctx->locale->date_fmt);
		tds_ctx->locale->date_fmt = strdup("%b %d %Y %I:%M%p");
	}
#endif

	ret = ct_init(*ctx, CS_VERSION_100);
	if (ret != CS_SUCCEED) {
		if (verbose) {
			fprintf(stderr, "Library Init failed!\n");
		}
		return ret;
	}
	if ((ret = ct_callback(*ctx, NULL, CS_SET, CS_CLIENTMSG_CB, 
			       (CS_VOID*) clientmsg_cb)) != CS_SUCCEED) {
		fprintf(stderr, "ct_callback() failed\n");
		return ret;
	}
	if ((ret = ct_callback(*ctx, NULL, CS_SET, CS_SERVERMSG_CB, servermsg_cb)) != CS_SUCCEED) {
		fprintf(stderr, "ct_callback() failed\n");
		return ret;
	}
	ret = ct_con_alloc(*ctx, conn);
	if (ret != CS_SUCCEED) {
		if (verbose) {
			fprintf(stderr, "Connect Alloc failed!\n");
		}
		return ret;
	}
	ret = ct_con_props(*conn, CS_SET, CS_USERNAME, USER, CS_NULLTERM, NULL);
	if (ret != CS_SUCCEED) {
		if (verbose) {
			fprintf(stderr, "ct_con_props() SET USERNAME failed!\n");
		}
		return ret;
	}
	ret = ct_con_props(*conn, CS_SET, CS_PASSWORD, PASSWORD, CS_NULLTERM, NULL);
	if (ret != CS_SUCCEED) {
		if (verbose) {
			fprintf(stderr, "ct_con_props() SET PASSWORD failed!\n");
		}
		return ret;
	}
	
	printf("connecting as %s to %s.%s\n", USER, SERVER, DATABASE);
	
	ret = ct_connect(*conn, SERVER, CS_NULLTERM);
	if (ret != CS_SUCCEED) {
		if (verbose) {
			fprintf(stderr, "Connection failed!\n");
		}
		ct_con_drop(*conn);
		*conn = NULL;
		cs_ctx_drop(*ctx);
		*ctx = NULL;
		return ret;
	}
	ret = ct_cmd_alloc(*conn, cmd);
	if (ret != CS_SUCCEED) {
		if (verbose) {
			fprintf(stderr, "Command Alloc failed!\n");
		}
		ct_con_drop(*conn);
		*conn = NULL;
		cs_ctx_drop(*ctx);
		*ctx = NULL;
		return ret;
	}

	strcpy(query, "use ");
	strncat(query, DATABASE, 20);

	ret = run_command(*cmd, query);
	if (ret != CS_SUCCEED)
		return ret;

	return CS_SUCCEED;
}
开发者ID:mabrand,项目名称:freetds,代码行数:98,代码来源:common.c

示例8: ifup

int ifup(const char *name, unsigned flags)
{
	int ret;
	char *cmd, *cmd_discover;
	const char *ip;
	struct stat s;
	int i;
	struct device_d *dev;
	struct eth_device *edev = eth_get_byname(name);

	if (edev && edev->ipaddr && !(flags & IFUP_FLAG_FORCE))
		return 0;

	eth_set_current(edev);

	env_push_context();

	setenv("ip", "");

	for (i = 0; i < ARRAY_SIZE(vars); i++)
		setenv(vars[i], "");

	cmd = asprintf("source /env/network/%s", name);
	cmd_discover = asprintf("/env/network/%s-discover", name);

	ret = run_command(cmd);
	if (ret) {
		pr_err("Running '%s' failed with %d\n", cmd, ret);
		goto out;
	}

	ret = stat(cmd_discover, &s);
	if (!ret) {
		ret = run_command(cmd_discover);
		if (ret) {
			pr_err("Running '%s' failed with %d\n", cmd, ret);
			goto out;
		}
	}

	dev = get_device_by_name(name);
	if (!dev) {
		pr_err("Cannot find device %s\n", name);
		goto out;
	}

	ret = eth_set_param(dev, "ethaddr");
	if (ret)
		goto out;

	ip = getenv("ip");
	if (!strcmp(ip, "dhcp")) {
		ret = run_command("dhcp");
		if (ret)
			goto out;
		ret = eth_set_param(dev, "serverip");
		if (ret)
			goto out;
	} else if (!strcmp(ip, "static")) {
		for (i = 0; i < ARRAY_SIZE(vars); i++) {
			ret = eth_set_param(dev, vars[i]);
			if (ret)
				goto out;
		}
	} else {
		pr_err("unknown ip type: %s\n", ip);
		ret = -EINVAL;
		goto out;
	}

	ret = 0;
out:
	env_pop_context();
	free(cmd);
	free(cmd_discover);

	return ret;
}
开发者ID:AubrCool,项目名称:barebox,代码行数:78,代码来源:ifup.c

示例9: make_rpm


//.........这里部分代码省略.........
      case 'd' :
          snprintf(filename, sizeof(filename), "%s/buildroot%s", directory, file->dst);

	  if (Verbosity > 1)
	    printf("Directory %s...\n", filename);

          make_directory(filename, 0755, -1, -1);
          break;
      case 'l' :
          snprintf(filename, sizeof(filename), "%s/buildroot%s", directory, file->dst);

	  if (Verbosity > 1)
	    printf("%s -> %s...\n", file->src, filename);

          make_link(filename, file->src);
          break;
    }
  }

 /*
  * Build the distribution from the spec file...
  */

  if (Verbosity)
    puts("Building RPM binary distribution...");

  if (format == PACKAGE_LSB_SIGNED || format == PACKAGE_RPM_SIGNED)
    build_option = "-signed ";
  else
    build_option = "";

  if (!strcmp(platform->machine, "intel"))
  {
    if (run_command(NULL, EPM_RPMBUILD " -bb --buildroot \"%s/buildroot\" "
                          EPM_RPMARCH "i386 %s%s", absdir, build_option,
			  specname))
      return (1);
  }
  else if (!strcmp(platform->machine, "ppc"))
  {
    if (run_command(NULL, EPM_RPMBUILD " -bb --buildroot \"%s/buildroot\" "
                          EPM_RPMARCH "powerpc %s%s", absdir, build_option,
			  specname))
      return (1);
  }
  else if (run_command(NULL, EPM_RPMBUILD " -bb --buildroot \"%s/buildroot\" "
                       EPM_RPMARCH "%s %s%s", absdir, platform->machine,
		       build_option, specname))
    return (1);

 /*
  * Move the RPMs to the local directory and rename the RPMs using the
  * product name specified by the user...
  */

  move_rpms(prodname, directory, platname, dist, platform, rpmdir, NULL,
            release);

  for (i = 0; i < dist->num_subpackages; i ++)
    move_rpms(prodname, directory, platname, dist, platform, rpmdir,
              dist->subpackages[i], release);

 /*
  * Build a compressed tar file to hold all of the subpackages...
  */
开发者ID:brandongooch,项目名称:epm,代码行数:66,代码来源:rpm.c

示例10: move_rpms

static int				/* O - 0 = success, 1 = fail */
move_rpms(const char     *prodname,	/* I - Product short name */
          const char     *directory,	/* I - Directory for distribution files */
          const char     *platname,	/* I - Platform name */
          dist_t         *dist,		/* I - Distribution information */
	  struct utsname *platform,	/* I - Platform information */
	  const char     *rpmdir,	/* I - RPM directory */
          const char     *subpackage,	/* I - Subpackage name */
	  const char     *release)	/* I - Release: value */
{
  char		rpmname[1024];		/* RPM name */
  char		prodfull[1024];		/* Full product name */
  struct stat	rpminfo;		/* RPM file info */


 /*
  * Move the RPMs to the local directory and rename the RPMs using the
  * product name specified by the user...
  */

  if (subpackage)
    snprintf(prodfull, sizeof(prodfull), "%s-%s", prodname, subpackage);
  else
    strlcpy(prodfull, prodname, sizeof(prodfull));

  if (dist->release[0])
    snprintf(rpmname, sizeof(rpmname), "%s/%s-%s-%s", directory, prodfull,
             dist->version, dist->release);
  else
    snprintf(rpmname, sizeof(rpmname), "%s/%s-%s", directory, prodfull,
             dist->version);

  if (platname[0])
  {
    strlcat(rpmname, "-", sizeof(rpmname));
    strlcat(rpmname, platname, sizeof(rpmname));
  }

  strlcat(rpmname, ".rpm", sizeof(rpmname));

  if (!strcmp(platform->machine, "intel"))
    run_command(NULL, "/bin/mv %s/RPMS/i386/%s-%s-%s.i386.rpm %s",
		rpmdir, prodfull, dist->version, release,
		rpmname);
  else if (!strcmp(platform->machine, "ppc"))
    run_command(NULL, "/bin/mv %s/RPMS/powerpc/%s-%s-%s.powerpc.rpm %s",
		rpmdir, prodfull, dist->version, release,
		rpmname);
  else
    run_command(NULL, "/bin/mv %s/RPMS/%s/%s-%s-%s.%s.rpm %s",
		rpmdir, platform->machine, prodfull, dist->version,
		release, platform->machine, rpmname);

  if (Verbosity)
  {
    stat(rpmname, &rpminfo);

    printf("    %7.0fk  %s\n", rpminfo.st_size / 1024.0, rpmname);
  }

  return (0);
}
开发者ID:brandongooch,项目名称:epm,代码行数:62,代码来源:rpm.c

示例11: main

int main(int argc, char *const argv[])
{
	char tmpdir[] = "/tmp/dirXXXXXX";
	char cmd[128];
	char filepnm[128] = "";
	char *dev;
	struct lr_server_data lsd;
	FILE *filep = NULL;
	int ret;
	int c;
	int opt_client = 0;
	int opt_reply = 0;

	progname = argv[0];
	while ((c = getopt_long(argc, argv, "chr", longopts, NULL)) != -1) {
		switch (c) {
		case 'c':
			opt_client = 1;
			break;
		case 'r':
			opt_reply = 1;
			break;
		case 'h':
		default:
			display_usage();
			return -1;
		}
	}
	dev = argv[optind];
	if (!dev) {
		display_usage();
		return -1;
	}

	/* Make a temporary directory to hold Lustre data files. */
	if (!mkdtemp(tmpdir)) {
		fprintf(stderr, "%s: Can't create temporary directory %s: %s\n",
			progname, tmpdir, strerror(errno));
		return errno;
	}

	memset(cmd, 0, sizeof(cmd));
	snprintf(cmd, sizeof(cmd),
		"%s -c -R 'dump /%s %s/%s' %s",
		DEBUGFS, LAST_RCVD, tmpdir, LAST_RCVD, dev);

	ret = run_command(cmd, sizeof(cmd));
	if (ret) {
		fprintf(stderr, "%s: Unable to dump %s file\n",
			progname, LAST_RCVD);
		goto out_rmdir;
	}

	snprintf(filepnm, 128, "%s/%s", tmpdir, LAST_RCVD);
	filep = fopen(filepnm, "r");
	if (!filep) {
		fprintf(stderr, "%s: Unable to read old data\n",
			progname);
		ret = -errno;
		goto out_rmdir;
	}
	unlink(filepnm);

	/* read lr_server_data structure */
	printf("%s:\n", LAST_RCVD);
	ret = fread(&lsd, 1, sizeof(lsd), filep);
	if (ret < sizeof(lsd)) {
		fprintf(stderr, "%s: Short read (%d of %d)\n",
			progname, ret, (int)sizeof(lsd));
		ret = -ferror(filep);
		if (ret)
			goto out_close;
	}

	/* swab structure fields of interest */
	lsd.lsd_feature_compat = __le32_to_cpu(lsd.lsd_feature_compat);
	lsd.lsd_feature_incompat = __le32_to_cpu(lsd.lsd_feature_incompat);
	lsd.lsd_feature_rocompat = __le32_to_cpu(lsd.lsd_feature_rocompat);
	lsd.lsd_last_transno = __le64_to_cpu(lsd.lsd_last_transno);
	lsd.lsd_osd_index = __le32_to_cpu(lsd.lsd_osd_index);
	lsd.lsd_mount_count = __le64_to_cpu(lsd.lsd_mount_count);

	/* display */
	printf("  uuid: %.40s\n", lsd.lsd_uuid);
	printf("  feature_compat: %#x\n", lsd.lsd_feature_compat);
	printf("  feature_incompat: %#x\n", lsd.lsd_feature_incompat);
	printf("  feature_rocompat: %#x\n", lsd.lsd_feature_rocompat);
	printf("  last_transaction: %llu\n", lsd.lsd_last_transno);
	printf("  target_index: %u\n", lsd.lsd_osd_index);
	printf("  mount_count: %llu\n", lsd.lsd_mount_count);

	/* read client information */
	if (opt_client) {
		lsd.lsd_client_start = __le32_to_cpu(lsd.lsd_client_start);
		lsd.lsd_client_size = __le16_to_cpu(lsd.lsd_client_size);
		printf("  client_area_start: %u\n", lsd.lsd_client_start);
		printf("  client_area_size: %hu\n", lsd.lsd_client_size);

		/* seek to per-client data area */
		ret = fseek(filep, lsd.lsd_client_start, SEEK_SET);
//.........这里部分代码省略.........
开发者ID:sdsc,项目名称:lustre-release,代码行数:101,代码来源:lr_reader.c

示例12: get_file_method

bool get_file_method(LSHandle* lshandle, LSMessage *message, void *ctx) {
  LSError lserror;
  LSErrorInit(&lserror);

  char run_command_buffer[MAXBUFLEN];
  char command[MAXLINLEN];

  json_t *object = json_parse_document(LSMessageGetPayload(message));
  json_t *id;

  // Extract the filename argument from the message
  id = json_find_first_label(object, "filename");
  if (!id || (id->child->type != JSON_STRING) ||
      (strlen(id->child->text) >= MAXNAMLEN) ||
      (strspn(id->child->text, ALLOWED_CHARS) != strlen(id->child->text))) {
    if (!LSMessageRespond(message,
			"{\"returnValue\": false, \"errorCode\": -1, "
			"\"errorText\": \"Invalid or missing filename parameter\", "
			"\"stage\": \"failed\"}",
			&lserror)) goto error;
    return true;
  }
  char filename[MAXNAMLEN];
  sprintf(filename, "/media/internal/.temp/%s", id->child->text);

  // Extract the url argument from the message
  id = json_find_first_label(object, "url");               
  if (!id || (id->child->type != JSON_STRING) ||
      (strlen(id->child->text) >= MAXLINLEN)) {
    if (!LSMessageRespond(message,
			"{\"returnValue\": false, \"errorCode\": -1, "
			"\"errorText\": \"Invalid or missing url parameter\", "
			"\"stage\": \"failed\"}",
			&lserror)) goto error;
    return true;
  }
  char url[MAXLINLEN];
  strcpy(url, id->child->text);

  if (!strncmp(url, "file://", 7)) {
    strcpy(filename, url+7);
  }
  else {

    /* Download the package */

    snprintf(command, MAXLINLEN,
	     "/usr/bin/curl --create-dirs --insecure --location --fail --show-error --output %s %s 2>&1", filename, url);

    strcpy(run_command_buffer, "{\"stdOut\": [");
    if (run_command(command, true, run_command_buffer)) {
      strcat(run_command_buffer, "], \"returnValue\": true, \"stage\": \"download\"}");
      if (!LSMessageRespond(message, run_command_buffer, &lserror)) goto error;
    }
    else {
      strcat(run_command_buffer, "]");
      if (!report_command_failure(message, command, run_command_buffer+11, "\"stage\": \"failed\"")) goto end;
      return true;
    }
  }

  return read_file(message, filename, true);

 error:
  LSErrorPrint(&lserror, stderr);
  LSErrorFree(&lserror);
 end:
  return false;
}
开发者ID:webos-commons,项目名称:apptuckerbox,代码行数:69,代码来源:apptuckerbox.c

示例13: do_update_mmc

/* update_mmc [dev no] <type> 'mem' 'addr' 'length' [load addr] */
int do_update_mmc(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
{
	block_dev_desc_t *desc;
	uint64_t dst_addr = 0, mem_len = 0;
	unsigned int mem_addr = 0;
	unsigned char *p;
	char cmd[32];
	lbaint_t blk, cnt;
	int ret, dev;

	if (6 > argc)
		goto usage;

	ret = get_device("mmc", argv[1], &desc);
	if (0 > ret) {
		printf ("** Not find device mmc.%s **\n", argv[1]);
		return 1;
	}

	dev = simple_strtoul (argv[1], NULL, 10);
	sprintf(cmd, "mmc dev %d", dev);
	if (0 > run_command(cmd, 0))	/* mmc device */
		return -1;

	if (0 != strcmp(argv[2], "2ndboot")  &&
		0 != strcmp(argv[2], "boot") &&
		0 != strcmp(argv[2], "raw")  &&
		0 != strcmp(argv[2], "part"))
		goto usage;

	mem_addr = simple_strtoul (argv[3], NULL, 16);
	dst_addr = simple_strtoull(argv[4], NULL, 16);
	mem_len  = simple_strtoull(argv[5], NULL, 16);

	p   = (unsigned char *)((ulong)mem_addr);
	blk = (dst_addr/MMC_BLOCK_SIZE);
	cnt = (mem_len/MMC_BLOCK_SIZE) + ((mem_len & (MMC_BLOCK_SIZE-1)) ? 1 : 0);

	flush_dcache_all();

	if (! strcmp(argv[2], "2ndboot")) {
		struct boot_dev_head *bh = (struct boot_dev_head *)((ulong)mem_addr);
		struct boot_dev_mmc  *bd = (struct boot_dev_mmc *)&bh->bdi;

		bd->port_no = dev; /* set u-boot device port num */
		printf("head boot dev  = %d\n", bd->port_no);

		goto do_write;
	}

	if (! strcmp(argv[2], "boot")) {
		struct boot_dev_head head;
		struct boot_dev_head *bh = &head;
		struct boot_dev_mmc *bd = (struct boot_dev_mmc *)&bh->bdi;
		int len = sizeof(head);
		unsigned int load = CONFIG_SYS_TEXT_BASE;

		if (argc == 7)
			load = simple_strtoul (argv[6], NULL, 16);

		memset((void*)&head, 0x00, len);

		bh->load_addr = (unsigned int)load;
		bh->jump_addr = bh->load_addr;
		bh->load_size = (unsigned int)mem_len;
		bh->signature = SIGNATURE_ID;
		bd->port_no	  = dev;

		printf("head boot dev  = %d\n", bd->port_no);
		printf("head load addr = 0x%08x\n", bh->load_addr);
		printf("head load size = 0x%08x\n", bh->load_size);
		printf("head gignature = 0x%08x\n", bh->signature);

		p -= len;
		memcpy(p, bh, len);

		mem_len += MMC_BLOCK_SIZE;
		cnt = (mem_len/MMC_BLOCK_SIZE) + ((mem_len & (MMC_BLOCK_SIZE-1)) ? 1 : 0);

		goto do_write;
	}

	if (strcmp(argv[2], "part") == 0) {
		uint64_t parts[4][2] = { {0,0}, };
		uint64_t part_len = 0;
		int partno = (int)dst_addr;
		int num = 0;

		if (0 > mmc_get_part_table(desc, parts, &num))
			return 1;

		if (partno > num || 1 > partno)  {
			printf ("** Invalid mmc.%d partition number %d (1 ~ %d) **\n",
				dev, partno, num);
			return 1;
		}

		dst_addr = parts[partno-1][0];	/* set write addr from part table */
		part_len = parts[partno-1][1];
//.........这里部分代码省略.........
开发者ID:iTOP4418,项目名称:u-boot-2014.07,代码行数:101,代码来源:cmd_mmc_update.c

示例14: menu_shell

void menu_shell(void)
{
    char c;
    char cmd_buf[256];
    static int mode=0;
    while (1)
    {
      /*
      check the download modes 
      0 for usb download
      1 for tftp download
      3 for serial download
      */
	main_menu_usage(mode);
	
        c = awaitkey(-1, NULL);
        printf("%c\n", c);
        switch (c)
        {
        case 'c':
        {
	    mode=!mode;
            break;
	}
        case 's':
        {
	    system_setting_shell();
            break;
	}
        case 'b':
        {
//            strcpy(cmd_buf, "usbslave 1 0x800000; nand erase boot; nand write 0x800000 boot $(filesize)");
            strcpy(cmd_buf, "bootd");
            run_command(cmd_buf, 0);
            break;
        }
        case 'f':
        {
#if 0
	    if (bBootFrmNORFlash == 1)
            strcpy(cmd_buf, "mtdpart default; nand erase;saveenv");
	    else
	    {
	    printf("\nBoot From NAND !\nNot erase bootloader.\n ");
            strcpy(cmd_buf, "mtdpart default; nand erase 0x00080000; saveenv");
	    }
            run_command(cmd_buf, 0);
#else
	  printf("\nNot Supported!\n ");
#endif
            break;
        }
	case 'm':
	  multiboot_shell();
	  break;
        case 'r':
        {
            run_command("reset", 0);
            break;
        }
        case 'v':
        {
#if 0
            strcpy(cmd_buf, "mtdparts");
            run_command(cmd_buf, 0);
	    printf("\nPress any key...\n");
	    awaitkey(-1, NULL);
#else
	  printf("\nNot Supported!\n ");
#endif
            break;
        }
	case 'e':
	{
	    printf("Reset u-boot-env...");
            run_command("env default -f;saveenv;reset",0);
            break;
	}
        case  27:
        case 'q':
        {
            return;
            break;
        }
        case '0':
        {
	  if(bBootFrmNORFlash)
	  {
	    printf("\nWarning!This operation will be brick your board!!!continue?(y/n)");
	    c = awaitkey(-1, NULL);
	    if (c=='n'||c=='N')
	    break;  
	  }
	    printf("\nDownload U-boot Bootloader ... \n");
	    if(download(mode)<0)
	    break;
	    if(chk_image())
	    {
	    strcpy(cmd_buf, "sf probe 0;sf erase 0x0 0x100000;sf write 0x800000 0x0 0x100000");
	    }
//.........这里部分代码省略.........
开发者ID:tsingui,项目名称:bootloader,代码行数:101,代码来源:cmd_menu.c

示例15: strbuf_addstr

static struct ref *get_refs_via_rsync(struct transport *transport, int for_push)
{
	struct strbuf buf = STRBUF_INIT, temp_dir = STRBUF_INIT;
	struct ref dummy, *tail = &dummy;
	struct child_process rsync;
	const char *args[5];
	int temp_dir_len;

	if (for_push)
		return NULL;

	/* copy the refs to the temporary directory */

	strbuf_addstr(&temp_dir, git_path("rsync-refs-XXXXXX"));
	if (!mkdtemp(temp_dir.buf))
		die ("Could not make temporary directory");
	temp_dir_len = temp_dir.len;

	strbuf_addstr(&buf, rsync_url(transport->url));
	strbuf_addstr(&buf, "/refs");

	memset(&rsync, 0, sizeof(rsync));
	rsync.argv = args;
	rsync.stdout_to_stderr = 1;
	args[0] = "rsync";
	args[1] = (transport->verbose > 0) ? "-rv" : "-r";
	args[2] = buf.buf;
	args[3] = temp_dir.buf;
	args[4] = NULL;

	if (run_command(&rsync))
		die ("Could not run rsync to get refs");

	strbuf_reset(&buf);
	strbuf_addstr(&buf, rsync_url(transport->url));
	strbuf_addstr(&buf, "/packed-refs");

	args[2] = buf.buf;

	if (run_command(&rsync))
		die ("Could not run rsync to get refs");

	/* read the copied refs */

	strbuf_addstr(&temp_dir, "/refs");
	read_loose_refs(&temp_dir, temp_dir_len + 1, &tail);
	strbuf_setlen(&temp_dir, temp_dir_len);

	tail = &dummy;
	strbuf_addstr(&temp_dir, "/packed-refs");
	insert_packed_refs(temp_dir.buf, &tail);
	strbuf_setlen(&temp_dir, temp_dir_len);

	if (remove_dir_recursively(&temp_dir, 0))
		warning ("Error removing temporary directory %s.",
				temp_dir.buf);

	strbuf_release(&buf);
	strbuf_release(&temp_dir);

	return dummy.next;
}
开发者ID:AndyA,项目名称:git-andya,代码行数:62,代码来源:transport.c


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