- rc = lcfg_ioctl(argv[0], OBD_DEV_ID, &lcfg);
- if (rc < 0) {
- fprintf(stderr, "error: %s: %s\n", jt_cmdname(argv[0]),
- strerror(rc = errno));
+ /* Write the contents of file to stdout */
+ fd = open(glob_info.gl_pathv[i], O_RDONLY);
+ if (fd < 0) {
+ fprintf(stderr,
+ "error: get_param: opening('%s') failed: %s\n",
+ glob_info.gl_pathv[i], strerror(errno));
+ continue;
+ }
+
+ do {
+ rc = read(fd, buf, CFS_PAGE_SIZE);
+ if (rc == 0)
+ break;
+ if (rc < 0) {
+ fprintf(stderr, "error: get_param: "
+ "read('%s') failed: %s\n",
+ glob_info.gl_pathv[i], strerror(errno));
+ break;
+ }
+ /* Print the output in the format path=value if the
+ * value contains no new line character or cab be
+ * occupied in a line, else print value on new line */
+ if (valuename && popt->show_path) {
+ int longbuf = strnchr(buf, rc - 1, '\n') != NULL
+ || rc > 60;
+ printf("%s=%s", valuename, longbuf ? "\n" : buf);
+ valuename = NULL;
+ if (!longbuf)
+ continue;
+ fflush(stdout);
+ }
+ rc = write(fileno(stdout), buf, rc);
+ if (rc < 0) {
+ fprintf(stderr, "error: get_param: "
+ "write to stdout failed: %s\n",
+ strerror(errno));
+ break;
+ }
+ } while (1);
+ close(fd);