All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan-Benedict Glaw <jbglaw@lug-owl.de>
To: Thomas Glanzmann <sithglan@stud.uni-erlangen.de>
Cc: git@vger.kernel.org, gitster@pobox.com
Subject: Re: [PATCH] Do _not_ call unlink on a directory
Date: Mon, 16 Jul 2007 19:41:38 +0200	[thread overview]
Message-ID: <20070716174138.GC22998@lug-owl.de> (raw)
In-Reply-To: <11846075213759-git-send-email-sithglan@stud.uni-erlangen.de>

[-- Attachment #1: Type: text/plain, Size: 1665 bytes --]

On Mon, 2007-07-16 19:38:41 +0200, Thomas Glanzmann <sithglan@stud.uni-erlangen.de> wrote:
> Calling unlink on a directory on a Solaris UFS filesystem as root makes it
> inconsistent. Thanks to Johannes Sixt for the obvious fix.
> 
> Signed-off-by: Thomas Glanzmann <sithglan@stud.uni-erlangen.de>
> ---
>  entry.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/entry.c b/entry.c
> index 82bf725..907293f 100644
> --- a/entry.c
> +++ b/entry.c
> @@ -6,18 +6,18 @@ static void create_directories(const char *path, const struct checkout *state)
>  	int len = strlen(path);
>  	char *buf = xmalloc(len + 1);
>  	const char *slash = path;
> +        struct stat st;

Whitespace damage.

>  	while ((slash = strchr(slash+1, '/')) != NULL) {
>  		len = slash - path;
>  		memcpy(buf, path, len);
>  		buf[len] = 0;
> +                if (!stat(buf, &st) && S_ISDIR(st.st_mode))
> +                        continue; /* ok */

Dito.

>  		if (mkdir(buf, 0777)) {
>  			if (errno == EEXIST) {
> -				struct stat st;
>  				if (len > state->base_dir_len && state->force && !unlink(buf) && !mkdir(buf, 0777))
>  					continue;
> -				if (!stat(buf, &st) && S_ISDIR(st.st_mode))
> -					continue; /* ok */
>  			}
>  			die("cannot create directory at %s", buf);
>  		}

MfG, JBG

-- 
      Jan-Benedict Glaw      jbglaw@lug-owl.de              +49-172-7608481
Signature of:         "really soon now":      an unspecified period of time, likly to
the second  :                                 be greater than any reasonable definition
                                              of "soon".

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

  reply	other threads:[~2007-07-16 17:41 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-16 17:12 [PATCH] Do _not_ call unlink on a directory Thomas Glanzmann
2007-07-16 17:18 ` Matthieu Moy
2007-07-16 19:05   ` Scott Lamb
2007-07-16 19:56     ` Thomas Glanzmann
2007-07-16 20:00     ` Thomas Glanzmann
2007-07-16 20:21       ` Linus Torvalds
2007-07-16 20:25         ` Thomas Glanzmann
2007-07-16 20:34           ` Linus Torvalds
2007-07-16 20:39             ` Thomas Glanzmann
2007-07-16 21:23             ` Scott Lamb
2007-07-16 21:44               ` Linus Torvalds
2007-07-16 21:58                 ` Scott Lamb
2007-07-16 22:03                   ` Linus Torvalds
2007-07-16 20:29         ` Linus Torvalds
2007-07-16 17:38 ` Thomas Glanzmann
2007-07-16 17:41   ` Jan-Benedict Glaw [this message]
2007-07-16 17:42   ` Brian Downing
2007-07-16 17:55     ` Thomas Glanzmann
2007-07-16 19:58 ` Linus Torvalds
2007-07-16 21:06   ` Brian Downing
2007-07-16 21:19     ` Linus Torvalds
2007-07-17  8:58   ` David Kastrup
2007-07-17  7:30 ` Junio C Hamano
2007-07-17  8:28 ` Junio C Hamano
2007-07-17 10:15   ` Thomas Glanzmann
2007-07-17 18:34     ` Junio C Hamano
2007-07-17 20:27       ` Thomas Glanzmann
2007-07-18  7:24         ` Johannes Sixt
2007-07-18  8:50           ` Thomas Glanzmann
2007-07-17 19:07   ` Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070716174138.GC22998@lug-owl.de \
    --to=jbglaw@lug-owl.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=sithglan@stud.uni-erlangen.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.