On Mon, Nov 30, 2009 at 03:47:53PM +0000, Matthew Booth wrote:
On 30/11/09 14:47, Richard W.M. Jones wrote:
> +/* Returns:
> + * 0 if everything was OK,
> + * -1 for a general error (sets errno),
> + * -2 if an existing path element was not a directory.
> + */
> static int
> recursive_mkdir (const char *path)
> {
> @@ -130,10 +135,7 @@ recursive_mkdir (const char *path)
> if (errno == EEXIST) { /* Something exists here, might not be a dir. */
> r = lstat (path,&buf);
> if (r == -1) return -1;
> - if (!S_ISDIR (buf.st_mode)) {
> - errno = ENOTDIR;
> - return -1;
> - }
> + if (!S_ISDIR (buf.st_mode)) return -2;
> return 0; /* OK - directory exists here already. */
> }
>
If you made this return -ENOTDIR it would be slightly less magic when
used later.
Unfortunately -ENOTDIR might be -1 ...
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top