Lines Matching +full:line +full:- +full:name

1 // SPDX-License-Identifier: GPL-2.0
35 int (*handler)(const char *line);
38 static void push_string(const char *name) in push_string() argument
40 unsigned int name_len = strlen(name) + 1; in push_string()
42 fputs(name, stdout); in push_string()
55 static void push_rest(const char *name) in push_rest() argument
57 unsigned int name_len = strlen(name) + 1; in push_rest()
60 fputs(name, stdout); in push_rest()
81 const char name[] = "TRAILER!!!"; in cpio_trailer() local
97 (unsigned)strlen(name)+1, /* namesize */ in cpio_trailer()
100 push_rest(name); in cpio_trailer()
108 static int cpio_mkslink(const char *name, const char *target, in cpio_mkslink() argument
113 if (name[0] == '/') in cpio_mkslink()
114 name++; in cpio_mkslink()
129 (unsigned)strlen(name) + 1,/* namesize */ in cpio_mkslink()
132 push_string(name); in cpio_mkslink()
139 static int cpio_mkslink_line(const char *line) in cpio_mkslink_line() argument
141 char name[PATH_MAX + 1]; in cpio_mkslink_line() local
146 int rc = -1; in cpio_mkslink_line()
148 …if (5 != sscanf(line, "%" str(PATH_MAX) "s %" str(PATH_MAX) "s %o %d %d", name, target, &mode, &ui… in cpio_mkslink_line()
149 fprintf(stderr, "Unrecognized dir format '%s'", line); in cpio_mkslink_line()
152 rc = cpio_mkslink(name, target, mode, uid, gid); in cpio_mkslink_line()
157 static int cpio_mkgeneric(const char *name, unsigned int mode, in cpio_mkgeneric() argument
162 if (name[0] == '/') in cpio_mkgeneric()
163 name++; in cpio_mkgeneric()
178 (unsigned)strlen(name) + 1,/* namesize */ in cpio_mkgeneric()
181 push_rest(name); in cpio_mkgeneric()
211 static int cpio_mkgeneric_line(const char *line, enum generic_types gt) in cpio_mkgeneric_line() argument
213 char name[PATH_MAX + 1]; in cpio_mkgeneric_line() local
217 int rc = -1; in cpio_mkgeneric_line()
219 if (4 != sscanf(line, "%" str(PATH_MAX) "s %o %d %d", name, &mode, &uid, &gid)) { in cpio_mkgeneric_line()
221 line, generic_type_table[gt].type); in cpio_mkgeneric_line()
225 rc = cpio_mkgeneric(name, mode, uid, gid); in cpio_mkgeneric_line()
230 static int cpio_mkdir_line(const char *line) in cpio_mkdir_line() argument
232 return cpio_mkgeneric_line(line, GT_DIR); in cpio_mkdir_line()
235 static int cpio_mkpipe_line(const char *line) in cpio_mkpipe_line() argument
237 return cpio_mkgeneric_line(line, GT_PIPE); in cpio_mkpipe_line()
240 static int cpio_mksock_line(const char *line) in cpio_mksock_line() argument
242 return cpio_mkgeneric_line(line, GT_SOCK); in cpio_mksock_line()
245 static int cpio_mknod(const char *name, unsigned int mode, in cpio_mknod() argument
256 if (name[0] == '/') in cpio_mknod()
257 name++; in cpio_mknod()
272 (unsigned)strlen(name) + 1,/* namesize */ in cpio_mknod()
275 push_rest(name); in cpio_mknod()
279 static int cpio_mknod_line(const char *line) in cpio_mknod_line() argument
281 char name[PATH_MAX + 1]; in cpio_mknod_line() local
288 int rc = -1; in cpio_mknod_line()
290 if (7 != sscanf(line, "%" str(PATH_MAX) "s %o %d %d %c %u %u", in cpio_mknod_line()
291 name, &mode, &uid, &gid, &dev_type, &maj, &min)) { in cpio_mknod_line()
292 fprintf(stderr, "Unrecognized nod format '%s'", line); in cpio_mknod_line()
295 rc = cpio_mknod(name, mode, uid, gid, dev_type, maj, min); in cpio_mknod_line()
309 return -1; in cpio_mkfile_csum()
314 size -= this_read; in cpio_mkfile_csum()
318 return -1; in cpio_mkfile_csum()
323 static int cpio_mkfile(const char *name, const char *location, in cpio_mkfile() argument
332 int rc = -1; in cpio_mkfile()
386 if (name[0] == '/') in cpio_mkfile()
387 name++; in cpio_mkfile()
388 namesize = strlen(name) + 1; in cpio_mkfile()
406 push_string(name); in cpio_mkfile()
425 size -= this_read; in cpio_mkfile()
429 name += namesize; in cpio_mkfile()
457 static int cpio_mkfile_line(const char *line) in cpio_mkfile_line() argument
459 char name[PATH_MAX + 1]; in cpio_mkfile_line() local
467 int rc = -1; in cpio_mkfile_line()
469 if (5 > sscanf(line, "%" str(PATH_MAX) "s %" str(PATH_MAX) in cpio_mkfile_line()
471 name, location, &mode, &uid, &gid, &end)) { in cpio_mkfile_line()
472 fprintf(stderr, "Unrecognized file format '%s'", line); in cpio_mkfile_line()
475 if (end && isgraph(line[end])) { in cpio_mkfile_line()
479 dname = malloc(strlen(line)); in cpio_mkfile_line()
485 dname_len = strlen(name) + 1; in cpio_mkfile_line()
486 memcpy(dname, name, dname_len); in cpio_mkfile_line()
490 if (sscanf(line + end, "%" str(PATH_MAX) "s %n", in cpio_mkfile_line()
491 name, &nend) < 1) in cpio_mkfile_line()
493 len = strlen(name) + 1; in cpio_mkfile_line()
494 memcpy(dname + dname_len, name, len); in cpio_mkfile_line()
498 } while (isgraph(line[end])); in cpio_mkfile_line()
500 dname = name; in cpio_mkfile_line()
512 "\t%s [-t <timestamp>] [-c] <cpio_list>\n" in usage()
518 "file <name> <location> <mode> <uid> <gid> [<hard links>]\n" in usage()
519 "dir <name> <mode> <uid> <gid>\n" in usage()
520 "nod <name> <mode> <uid> <gid> <dev_type> <maj> <min>\n" in usage()
521 "slink <name> <target> <mode> <uid> <gid>\n" in usage()
522 "pipe <name> <mode> <uid> <gid>\n" in usage()
523 "sock <name> <mode> <uid> <gid>\n" in usage()
525 "<name> name of the file/dir/nod/etc in the archive\n" in usage()
549 "-c: calculate and store 32-bit checksums for file data.\n", in usage()
583 char line[LINE_SIZE]; in main() local
594 if (opt == -1) in main()
618 * Timestamps after 2106-02-07 06:28:15 UTC have an ascii hex time_t in main()
627 if (argc - optind != 1) { in main()
632 if (!strcmp(filename, "-")) in main()
641 while (fgets(line, LINE_SIZE, cpio_list)) { in main()
643 size_t slen = strlen(line); in main()
647 if ('#' == *line) { in main()
648 /* comment - skip to next line */ in main()
652 if (! (type = strtok(line, " \t"))) { in main()
654 "ERROR: incorrect format, could not locate file type line %d: '%s'\n", in main()
655 line_nr, line); in main()
656 ec = -1; in main()
661 /* a blank line */ in main()
666 /* must be an empty line */ in main()
672 "ERROR: incorrect format, newline required line %d: '%s'\n", in main()
673 line_nr, line); in main()
674 ec = -1; in main()
679 if (! strcmp(line, file_handler_table[type_idx].type)) { in main()
682 fprintf(stderr, " line %d\n", line_nr); in main()
689 fprintf(stderr, "unknown file type line %d: '%s'\n", in main()
690 line_nr, line); in main()