Re: [PATCH v4 4/4] populate: add ability to populate a filesystem from a directory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ah, this is the new code.

Please reorder it to before wiring it up in mkfs, or even better just
merge the two patches as that makes reviewing easier.

> +++ b/mkfs/populate.c
> @@ -0,0 +1,287 @@
> 

Please add the SPDX license identifier and your or your employers
copyright (whoever has the right to it) here.

> +static void fail(char *msg, int i)
> +{
> +	fprintf(stderr, "%s: %s [%d - %s]\n", progname, msg, i, strerror(i));

This needs the _() treatment for localization.

> +static void writetimestamps(struct xfs_inode *ip, struct stat statbuf)
> +{
> +	struct timespec64 ts;
> +
> +	/* Copy timestamps from source file to destination inode.
> +	*  In order to not be influenced by our own access timestamp,

The usual kernel and xfprogs style for multi-line comments is:

	/*
	 * Copy timestamps from source file to destination inode.
	 * ..
	 */`

> +static void create_file(xfs_mount_t *mp, struct xfs_inode *pip,

We're (way too slowly) phasing out the use of typedefs for structs,
so the xfs_mount_t above should be struct xfs_mount.

> +	xfs_inode_t *ip;
> +	xfs_trans_t *tp;
> +	tp = getres(mp, 0);
> +	ppargs = newpptr(mp);

Similar for the xfs_inode_t and xfs_trans_t above and a few more later
in the patch.

Also please keep an empty line between delarations and the actual code
for clarity.


> +	// copy over timestamps

Please use /* */ style comments.

> +	if ((dir = opendir(cur_path)) == NULL) {
> +		fail(_("cannot open input dir"), 1);
> +	}

No need to use braces for single line statements.

> +	while ((entry = readdir(dir)) != NULL) {
> +		char link_target[PATH_MAX];
> +		char path[PATH_MAX];
> +		int error;
> +		int fd = -1;
> +		int flags;
> +		int majdev;
> +		int mindev;
> +		int mode;
> +		off_t len;

Can you factor this quite huge loop body into a helper function?

> index 0000000..e1b8587
> --- /dev/null
> +++ b/mkfs/populate.h
> @@ -0,0 +1,4 @@
> +#ifndef MKFS_POPULATE_H_
> +#define MKFS_POPULATE_H_

This also needs SPDX tag.

As you might have noticed this is really just nitpicking.  The actual
logic looks good to me.





[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux