[klibc] Re: [PATCH] gen_init_cpio uses external file list

Sam Ravnborg sam at ravnborg.org
Fri Sep 17 07:49:59 PDT 2004


On Thu, Sep 16, 2004 at 04:11:12PM -0600, Thayne Harbaugh wrote:
> 
> This patch makes gen_init_cpio generate the initramfs_data.cpio from a
> file which contains a list of entries: file, dir, nod.  I swapped the
> order of filename/location for the file arguments so that it would be
> more uniform with the dir and nod tyes.

Comments already given on klibc list by others, but repeated for lkml readers.

Helper programs like this shall be compatible with at least solaris & cygwin.
Therefore the linux only stuff needs to be avoided.

 +	char name[PATH_MAX + 1];
> +	unsigned int mode;
> +	uid_t uid;
> +	gid_t gid;
> +	int rc = -1;
> +
> +	if (4 != sscanf(line, "%" str(PATH_MAX) "s %o %d %d", name, &mode, &uid, &gid)) {
> +		fprintf(stderr, "Unrecognized dir format '%s'", line);
> +		goto fail;

Do we know that uid_t and gid_t equals an int here?
Use an int in the sscanf and do explicit type conversion later.


> +	while (-1 != getline(&line, &line_sz, cpio_list)) {
> +		int type_idx;

fgets() please.

	Sam



More information about the klibc mailing list