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

Re: [Libguestfs] [PATCH 1/3] New API: case-sensitive-path to return case sensitive path on NTFS 3g fs



Richard W.M. Jones wrote:

> On Mon, Oct 26, 2009 at 11:41:22AM +0100, Jim Meyering wrote:
>> Richard W.M. Jones wrote:
>> > +char *
>> > +do_case_sensitive_path (const char *path)
>> > +{
>> > +  char ret[PATH_MAX+1] = "/";
>> > +  size_t next = 1;
>> > +
>> > +  /* MUST chdir ("/") before leaving this function. */
>> > +  if (chdir (sysroot) == -1) {
>>
>> If this function might ever be used from a multi-threaded
>> application, then you'll want to change it not to use chdir,
>> since chdir changes the process-wide current directory.
>> That can cause rare but particularly hard to debug problems.
>
> This code would be much harder to write if we don't use chdir.  Any
> suggestions on that?  If there was a "readdirat" variant then that
> might be promising.

To traverse without chdir, you can use the combination
of openat and fdopendir, and then readdir as usual.

With those gnulib modules, you use both openat and fdopendir portably.


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