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

Jim Meyering jim at meyering.net
Mon Oct 26 13:40:02 UTC 2009


Richard W.M. Jones wrote:

> On Mon, Oct 26, 2009 at 11:03:04AM +0000, Matthew Booth wrote:
>> On 26/10/09 09:20, Richard W.M. Jones wrote:
>>> +char *
>>> +do_case_sensitive_path (const char *path)
>>> +{
>>> +  char ret[PATH_MAX+1] = "/";
>>
>> Is PATH_MAX on Windows <= POSIX PATH_MAX? Does ntfs_3g honour this?
>> Seems like a grey area. It would be safer to realloc this buffer as
>> necessary. You also wouldn't need the strdup() at the end.
>
> PATH_MAX is a Linux thing.  NTFS 3g couldn't export something through
> the Linux VFS unless it honoured this.
>
>>> +  size_t next = 1;
>>> +
>>> +  /* MUST chdir ("/") before leaving this function. */
>>> +  if (chdir (sysroot) == -1) {
>>> +    reply_with_perror ("%s", sysroot);
>>> +    return NULL;
>>> +  }
>>
>> I'm not convinced chdir is necessary in this function if you use
>> openat() throughout.
>
> I'm pretty sure I need opendirat to make this work, and that function
> doesn't seem to exist (checked on Fedora 11).

It's in lib/fts.c:

/* file-descriptor-relative opendir.  */
/* FIXME: if others need this function, move it into lib/openat.c */
static inline DIR *
internal_function
opendirat (int fd, char const *dir)
{
  int new_fd = openat (fd, dir,
                       O_RDONLY | O_DIRECTORY | O_NOCTTY | O_NONBLOCK);
  DIR *dirp;

  if (new_fd < 0)
    return NULL;
  set_cloexec_flag (new_fd, true);
  dirp = fdopendir (new_fd);
  if (dirp == NULL)
    {
      int saved_errno = errno;
      close (new_fd);
      errno = saved_errno;
    }
  return dirp;
}




More information about the Libguestfs mailing list