do {
nend = 0; if (sscanf(line + end, "%" str(PATH_MAX) "s %n",
name, &nend) < 1) break;
len = strlen(name) + 1;
memcpy(dname + dname_len, name, len);
dname_len += len;
nlinks++;
end += nend;
} while (isgraph(line[end]));
} else {
dname = name;
}
rc = cpio_mkfile(dname, cpio_replace_env(location),
mode, uid, gid, nlinks);
fail: if (dname_len) free(dname); return rc;
}
staticvoid usage(constchar *prog)
{
fprintf(stderr, "Usage:\n" "\t%s [-t ] [-c] \n" "\n" " is a file containing newline separated entries that\n" "describe the files to be included in the initramfs archive:\n" "\n" "# a comment\n" "file []\n" "dir \n" "nod \n" "slink \n" "pipe \n" "sock \n" "\n" " name of the file/dir/nod/etc in the archive\n" " location of the file in the current filesystem\n" " expands shell variables quoted with ${}\n" " link target\n" " mode/permissions of the file\n" " user id (0=root)\n" " group id (0=root)\n" " device type (b=block, c=character)\n" " major number of nod\n" " minor number of nod\n" " space separated list of other links to file\n" "\n" "example:\n" "# A simple initramfs\n" "dir /dev 0755 0 0\n" "nod /dev/console 0600 0 0 c 5 1\n" "dir /root 0700 0 0\n" "dir /sbin 0755 0 0\n" "file /sbin/kinit /usr/src/klibc/kinit/kinit 0755 0 0\n" "\n" " is time in seconds since Epoch that will be used\n" "as mtime for symlinks, directories, regular and special files.\n" "The default is to use the current time for all files, but\n" "preserve modification time for regular files.\n" "-c: calculate and store 32-bit checksums for file data.\n",
prog);
}
/* * Timestamps after 2106-02-07 06:28:15 UTC have an ascii hex time_t * representation that exceeds 8 chars and breaks the cpio header * specification. Negative timestamps similarly exceed 8 chars.
*/ if (default_mtime > 0xffffffff || default_mtime < 0) {
fprintf(stderr, "ERROR: Timestamp out of range for cpio format\n"); exit(1);
}
if (argc - optind != 1) {
usage(argv[0]); exit(1);
}
filename = argv[optind]; if (!strcmp(filename, "-"))
cpio_list = stdin; elseif (!(cpio_list = fopen(filename, "r"))) {
fprintf(stderr, "ERROR: unable to open '%s': %s\n\n",
filename, strerror(errno));
usage(argv[0]); exit(1);
}
while (fgets(line, LINE_SIZE, cpio_list)) { int type_idx;
size_t slen = strlen(line);
line_nr++;
if ('#' == *line) { /* comment - skip to next line */ continue;
}
if (! (type = strtok(line, " \t"))) {
fprintf(stderr, "ERROR: incorrect format, could not locate file type line %d: '%s'\n",
line_nr, line);
ec = -1; break;
}
if ('\n' == *type) { /* a blank line */ continue;
}
if (slen == strlen(type)) { /* must be an empty line */ continue;
}
if (! (args = strtok(NULL, "\n"))) {
fprintf(stderr, "ERROR: incorrect format, newline required line %d: '%s'\n",
line_nr, line);
ec = -1;
}
for (type_idx = 0; file_handler_table[type_idx].type; type_idx++) { int rc; if (! strcmp(line, file_handler_table[type_idx].type)) { if ((rc = file_handler_table[type_idx].handler(args))) {
ec = rc;
fprintf(stderr, " line %d\n", line_nr);
} break;
}
}
if (NULL == file_handler_table[type_idx].type) {
fprintf(stderr, "unknown file type line %d: '%s'\n",
line_nr, line);
}
} if (ec == 0)
cpio_trailer();
exit(ec);
}
¤ Dauer der Verarbeitung: 0.15 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.