On 30/11/09 15:52, Richard W.M. Jones wrote:
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 ...
Bleargh. Ok.
Matt
--
Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team
M: +44 (0)7977 267231
GPG ID: D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490