From patchwork Thu Apr 2 23:57:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Hebb X-Patchwork-Id: 6152031 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D9B64BF4A6 for ; Thu, 2 Apr 2015 23:57:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DCD0220396 for ; Thu, 2 Apr 2015 23:57:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E38F52038D for ; Thu, 2 Apr 2015 23:57:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751702AbbDBX5l (ORCPT ); Thu, 2 Apr 2015 19:57:41 -0400 Received: from mail-qc0-f180.google.com ([209.85.216.180]:36575 "EHLO mail-qc0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751271AbbDBX5k (ORCPT ); Thu, 2 Apr 2015 19:57:40 -0400 Received: by qcgx3 with SMTP id x3so79999150qcg.3; Thu, 02 Apr 2015 16:57:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=Lw8IGrfPDurslpkuey0c88D/KFxH0cJXIlV23wXgFho=; b=r99wDuDp74/93jwhlcqzakCesPrKHPvtJsFSyvWT2KPbwV6Rzmo6I1VJuWNHIG2LGt L+hpx5iv+C6A5QMjEZX747FICZ9mg4fMrzcqh6ic45GWRYOguN/kXTzRra0JEQQNSL+G GHYxTm1uCzh/EyVPY6/LgOMPooZLDl6o02aahMNu4tc3CxkgLLGW4j1MwvKhauHZLzLu EvpIrwCK7F0zDix9iUZHS3hoHlLtqs51lHHB8U4NitoEmj9oGeBk8ZNTmSY3kg73gD4c CbEwOKHXuNaEGQqR/DpLGp6sr1uF8jSP0fQJWHp0zZ51g9aT+8KJb+lhHJlPVjeY9XWo aXMA== X-Received: by 10.55.26.29 with SMTP id a29mr22131079qka.0.1428019059738; Thu, 02 Apr 2015 16:57:39 -0700 (PDT) Received: from [130.64.128.230] (resnet-130-64-128-230.medford.tufts.edu. [130.64.128.230]) by mx.google.com with ESMTPSA id 187sm4567679qhv.8.2015.04.02.16.57.38 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Apr 2015 16:57:39 -0700 (PDT) Message-ID: <551DD772.9020406@gmail.com> Date: Thu, 02 Apr 2015 19:57:38 -0400 From: Thomas Hebb User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Viacheslav Dubeyko , Sergei Antonov CC: linux-fsdevel@vger.kernel.org, stable@vger.kernel.org, Andrew Morton , Hin-Tak Leung , Anton Altaparmakov , Fabian Frederick , Christian Kujau Subject: Re: [PATCH] hfsplus: add missing osx prefix to FinderInfo attribute check References: <551B6904.50405@gmail.com> <1427906337.2788.2.camel@slavad-ubuntu-14.04> In-Reply-To: <1427906337.2788.2.camel@slavad-ubuntu-14.04> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP > 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 $ 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 linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- 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