Re: [PATCH] abspath.c: use PATH_MAX in real_path_internal()

2014-07-20 Thread Jeff King
On Sun, Jul 20, 2014 at 10:00:41AM +0200, René Scharfe wrote: > -- >8 -- > Subject: [PATCH] unix-socket: remove stale socket before calling chdir() > > unix_stream_listen() is given a path. It calls unix_sockaddr_init(), > which in turn can call chdir(). After that a relative path doesn't > mea

Re: [PATCH] abspath.c: use PATH_MAX in real_path_internal()

2014-07-20 Thread René Scharfe
Am 20.07.2014 01:55, schrieb Karsten Blees: Am 18.07.2014 13:32, schrieb René Scharfe: Am 18.07.2014 01:03, schrieb Karsten Blees: Am 17.07.2014 19:05, schrieb René Scharfe: Am 17.07.2014 14:45, schrieb Nguyễn Thái Ngọc Duy: [...] "These routines have traditionally been used by programs to s

Re: [PATCH] abspath.c: use PATH_MAX in real_path_internal()

2014-07-20 Thread René Scharfe
Am 20.07.2014 02:29, schrieb Karsten Blees: > unix-socket.c: This looks pretty broken. The cd / cd back logic is only > ever used if the socket path is too long. In this case, after cd'ing to > the parent directory of the socket, unix_stream_listen tries to unlink > the *original* socket path, inst

Re: [PATCH] abspath.c: use PATH_MAX in real_path_internal()

2014-07-19 Thread Karsten Blees
Am 18.07.2014 12:49, schrieb Duy Nguyen: > can be used, else we fall back to chdir. I think there are only four > places that follow this pattern, here, setup.c (.git discovery), git.c > (restore_env) and unix-socket.c. Enough call sites to make it worth > the effort? > real_path(): here we actua

Re: [PATCH] abspath.c: use PATH_MAX in real_path_internal()

2014-07-19 Thread Karsten Blees
Am 18.07.2014 13:32, schrieb René Scharfe: > Am 18.07.2014 01:03, schrieb Karsten Blees: >> Am 17.07.2014 19:05, schrieb René Scharfe: >>> Am 17.07.2014 14:45, schrieb Nguyễn Thái Ngọc Duy: >> [...] >>> "These routines have traditionally been used by programs to save the >>> name of a working direc

Re: [PATCH] abspath.c: use PATH_MAX in real_path_internal()

2014-07-19 Thread Duy Nguyen
On Fri, Jul 18, 2014 at 10:08 PM, René Scharfe wrote: >> We could wrap this "get cwd, cd back" pattern as well. So "save_cwd" >> returns an opaque pointer, "go_back" takes the pointer, (f)chdir back >> and free the pointer if needed. On platforms that support fchdir, it >> can be used, else we fal

Re: [PATCH] abspath.c: use PATH_MAX in real_path_internal()

2014-07-18 Thread Junio C Hamano
Karsten Blees writes: > Am 17.07.2014 14:45, schrieb Nguyễn Thái Ngọc Duy: >> e.g. "git init". Make it static too to reduce stack usage. > > But wouldn't this increase overall memory usage? Stack memory > will be reused by subsequent code, while static memory cannot > be reused (but still increas

Re: [PATCH] abspath.c: use PATH_MAX in real_path_internal()

2014-07-18 Thread René Scharfe
Am 18.07.2014 12:49, schrieb Duy Nguyen: > On Fri, Jul 18, 2014 at 6:03 AM, Karsten Blees > wrote: >> Am 17.07.2014 19:05, schrieb René Scharfe: >>> Am 17.07.2014 14:45, schrieb Nguyễn Thái Ngọc Duy: >> [...] >>> "These routines have traditionally been used by programs to save the >>> name of a w

Re: [PATCH] abspath.c: use PATH_MAX in real_path_internal()

2014-07-18 Thread René Scharfe
Am 18.07.2014 01:03, schrieb Karsten Blees: Am 17.07.2014 19:05, schrieb René Scharfe: Am 17.07.2014 14:45, schrieb Nguyễn Thái Ngọc Duy: [...] "These routines have traditionally been used by programs to save the name of a working directory for the purpose of returning to it. A much faster and

Re: [PATCH] abspath.c: use PATH_MAX in real_path_internal()

2014-07-18 Thread Duy Nguyen
On Fri, Jul 18, 2014 at 6:03 AM, Karsten Blees wrote: > Am 17.07.2014 19:05, schrieb René Scharfe: >> Am 17.07.2014 14:45, schrieb Nguyễn Thái Ngọc Duy: > [...] >> "These routines have traditionally been used by programs to save the >> name of a working directory for the purpose of returning to it

Re: [PATCH] abspath.c: use PATH_MAX in real_path_internal()

2014-07-17 Thread Karsten Blees
Am 17.07.2014 19:05, schrieb René Scharfe: > Am 17.07.2014 14:45, schrieb Nguyễn Thái Ngọc Duy: [...] > "These routines have traditionally been used by programs to save the > name of a working directory for the purpose of returning to it. A much > faster and less error-prone method of accomplishing

Re: [PATCH] abspath.c: use PATH_MAX in real_path_internal()

2014-07-17 Thread Karsten Blees
Am 17.07.2014 20:03, schrieb Junio C Hamano: > Nguyễn Thái Ngọc Duy writes: > >> This array 'cwd' is used to store the result from getcwd() and chdir() >> back. PATH_MAX is the right constant for the job. On systems with >> longer PATH_MAX (eg. 4096 on Linux), hard coding 1024 fails stuff, >> e.

Re: [PATCH] abspath.c: use PATH_MAX in real_path_internal()

2014-07-17 Thread Karsten Blees
Am 17.07.2014 14:45, schrieb Nguyễn Thái Ngọc Duy: > e.g. "git init". Make it static too to reduce stack usage. But wouldn't this increase overall memory usage? Stack memory will be reused by subsequent code, while static memory cannot be reused (but still increases the process working set). -- T

Re: [PATCH] abspath.c: use PATH_MAX in real_path_internal()

2014-07-17 Thread Junio C Hamano
René Scharfe writes: > "These routines have traditionally been used by programs to save the > name of a working directory for the purpose of returning to it. A much > faster and less error-prone method of accomplishing this is to open the > current directory (.) and use the fchdir(2) function to

Re: [PATCH] abspath.c: use PATH_MAX in real_path_internal()

2014-07-17 Thread Junio C Hamano
Nguyễn Thái Ngọc Duy writes: > This array 'cwd' is used to store the result from getcwd() and chdir() > back. PATH_MAX is the right constant for the job. On systems with > longer PATH_MAX (eg. 4096 on Linux), hard coding 1024 fails stuff, > e.g. "git init". Make it static too to reduce stack usa

Re: [PATCH] abspath.c: use PATH_MAX in real_path_internal()

2014-07-17 Thread René Scharfe
Am 17.07.2014 14:45, schrieb Nguyễn Thái Ngọc Duy: > This array 'cwd' is used to store the result from getcwd() and chdir() > back. PATH_MAX is the right constant for the job. PATH_MAX may be better than 1024, but there can't really be a correct constant. The actual limit depends on the file syst

[PATCH] abspath.c: use PATH_MAX in real_path_internal()

2014-07-17 Thread Nguyễn Thái Ngọc Duy
This array 'cwd' is used to store the result from getcwd() and chdir() back. PATH_MAX is the right constant for the job. On systems with longer PATH_MAX (eg. 4096 on Linux), hard coding 1024 fails stuff, e.g. "git init". Make it static too to reduce stack usage. Signed-off-by: Nguyễn Thái Ngọc Duy