Re: [PATCH] hfsplus: add missing osx prefix to FinderInfo attribute check

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

 



> Could you describe in more details how do you use userspace utilities
> for extracting xattr?

Of course. I first create a new file on an HFS+ filesystem (case-
sensitive, journaling disabled). I then call listxattr() on that
file and receive a list of one attribute:
  osx.com.apple.FinderInfo
I call getxattr() with this name as the second argument.

Without the patch, getxattr() returns -1 and sets errno to either
ENOATTR (ENODATA) if the volume has an attribute tree or EOPNOTSUPP if
it doesn't. This behavior is clearly wrong, since listxattr() told me
that the attribute existed.

In the case where ENOATTR is returned (when an attribute b-tree exists,
as it does when any file on the filesystem has a real attribute), the
error causes GNU patch 2.7.5 to fail with the error message
  getting attribute osx.com.apple.FinderInfo of osx.com.apple.FinderInfo: No data available
(As shown in the attached typescript.) That's how I originally discovered
the problem.

I have written a test program to demonstrate the issue. It builds on
both Linux and OS X, so that the behaviors can be compared. You can
find it at https://github.com/tchebb/xattr-test.

After more investigation, however, I must withdraw the initial patch I
sent. It is not a correct solution to the entire problem; it's simply a
band-aid that fixes this one particular symptom. As you can see from
the included typescript, *any* osx-namespaced attribute is given an
additional copy of the prefix. I believe I've found a commit from 2014
that introduced this incorrect behavior, and I'll send another patch
soon that should resolve the issue entirely.

Thanks,
-Thomas Hebb

typescript
---
$ cat >a				# Make some test files
line 1
line 2
$ cat >b
line 1
line 2
line 3
$ diff -u a b | tee patch		# Create a diff between them
--- a	2015-04-02 17:03:18.000000000 -0400
+++ b	2015-04-02 17:03:30.000000000 -0400
@@ -1,2 +1,3 @@
 line 1
 line 2
+line 3
$ patch -i patch a			# Patch the file. Works fine, for now...
patching file a
$ ./xattr-test a			# But getxattr() still returns EOPNOTSUPP
Listing attributes of "a"
listxattr() returned 25
  List contents:
    osx.com.apple.FinderInfo

Getting attribute "osx.com.apple.FinderInfo"
getxattr() returned -1
getxattr() failed: Operation not supported

$ cat >a				# Let's try again
line 1
line 2
$ setfattr -n 'user.test' -v 'abc' a	# This time, give the volume an attr tree
$ patch -i patch a			# And patch fails!
patching file a
patch: getting attribute osx.com.apple.FinderInfo of osx.com.apple.FinderInfo: No data available
$ ./xattr-test a			# Because getxattr() returns ENODATA
Listing attributes of "a"
listxattr() returned 35
  List contents:
    osx.com.apple.FinderInfo
    user.test

Getting attribute "osx.com.apple.FinderInfo"
getxattr() returned -1
getxattr() failed: No data available

Getting attribute "user.test"
getxattr() returned 3
  Attribute value:
    0x61 0x62 0x63

$ setfattr -n 'osx.test' -v 'def' a	# Now, what if we create an attr in the osx namespace?
$ ./xattr-test a			# Aha, here's the real problem: "osx." is prefixed an extra time!
Listing attributes of "a"
listxattr() returned 48
  List contents:
    osx.com.apple.FinderInfo
    osx.osx.test
    user.test

Getting attribute "osx.com.apple.FinderInfo"
getxattr() returned -1
getxattr() failed: No data available

Getting attribute "osx.osx.test"
getxattr() returned -1
getxattr() failed: No data available

Getting attribute "user.test"
getxattr() returned 3
  Attribute value:
    0x61 0x62 0x63

$ exit
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]