linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Hebb <tommyhebb@gmail.com>
To: Viacheslav Dubeyko <slava@dubeyko.com>,
	Sergei Antonov <saproj@gmail.com>
Cc: linux-fsdevel@vger.kernel.org, stable@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Hin-Tak Leung <htl10@users.sourceforge.net>,
	Anton Altaparmakov <anton@tuxera.com>,
	Fabian Frederick <fabf@skynet.be>,
	Christian Kujau <lists@nerdbynature.de>
Subject: Re: [PATCH] hfsplus: add missing osx prefix to FinderInfo attribute check
Date: Thu, 02 Apr 2015 19:57:38 -0400	[thread overview]
Message-ID: <551DD772.9020406@gmail.com> (raw)
In-Reply-To: <1427906337.2788.2.camel@slavad-ubuntu-14.04>

> 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

  reply	other threads:[~2015-04-02 23:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-01  3:41 [PATCH] hfsplus: add missing osx prefix to FinderInfo attribute check Thomas Hebb
2015-04-01 16:38 ` Viacheslav Dubeyko
2015-04-02 23:57   ` Thomas Hebb [this message]
2015-04-03  0:28     ` Viacheslav Dubeyko
2015-04-02 23:41 ` Sergei Antonov
2015-04-03  1:33   ` Viacheslav Dubeyko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=551DD772.9020406@gmail.com \
    --to=tommyhebb@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=anton@tuxera.com \
    --cc=fabf@skynet.be \
    --cc=htl10@users.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=lists@nerdbynature.de \
    --cc=saproj@gmail.com \
    --cc=slava@dubeyko.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).