[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



On 26/10/09 11:08, Richard W.M. Jones wrote:
+  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).

You only need openat() followed by fdopendir().

This API seems like an unfortunate pimple. Would it not be better to
*not* export this API, and instead call this automatically everywhere
the daemon opens a file on ntfs?

But how does it know what the underlying filesystem is up to?  I agree
it's a bug in NTFS 3g, but changing all the code to do very expensive
magic doesn't seem like the right way, and you can't detect which
filesystems are broken like this.

Problem is, if you don't put the magic in you're pushing the problem on to the library user. The code's going to look pretty much the same every time, so it might as well be in the library. You could take 2 approaches here:

1. Always use case-sensitive-path: slow, but should be safe.
2. Detect fs type and call case-sensitive-path as required: probably tricky to get absolutely right (think: ntfs mounted as an additional volume under /mnt/windows).

I'd go for 1. It should be safe, and it's not as if the slowness is likely to be noticeable here.

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


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