Skip to content

The Eclectic Light Company

Macs, painting, and more
Main navigation
  • Downloads
  • M1 & M2 Macs
  • Mac Problems
  • Mac articles
  • Art
  • Macs
  • Painting
hoakley July 26, 2019 Macs, Technology

How do the Finder, Terminal and Spotlight handle extended attribute flags?

My two previous articles described how xattr flags can control whether individual extended attribute (xattr) types are copied in the Finder, and to and from iCloud Drive, and how apps can use them to preserve custom xattrs on documents. What remains is to establish how different types of copying interpret these flags, and how they affect other parts of macOS such as the Finder and, most importantly, Spotlight search.

Jonathan Levin – who of course does know all about these, and has now added a short section about them to volume I of his reference books on Apple’s operating systems – points out that xattr flags only affect copy behaviour under the copyfile(3) API. That means that copies made using the Finder will respect them, and will strip xattrs where so instructed, but cp in Terminal doesn’t, and preserves all xattrs regardless of their flags. That can of course be a mixed blessing.

When you’re using custom xattrs, you’re probably not concerned whether other parts of macOS will handle them properly, except perhaps for Spotlight search. Ordinarily, metadata indexing doesn’t include custom xattr content, but it is (I think) possible to write a custom metadata importer to handle them. I don’t know whether such indexing would work with xattr flags, though.

Looking then at Spotlight, I was prepared for problems, but to my amazement metadata indexing of standard xattrs works as normal when they’re flagged.

To test this, I added standard com.apple.metadata:kMDItem xattrs which are normally indexed by Spotlight, including:

  • com.apple.metadata:kMDItemCopyright
  • com.apple.metadata:kMDItemCreator
  • com.apple.metadata:kMDItemDescription
  • com.apple.metadata:kMDItemHeadline
  • com.apple.metadata:kMDItemKeyword

These are normally treated as if they have PS flags by macOS, to ensure that they’re preserved during copying and syncing, but not during export. In my original work on xattr preservation, I found that they are preserved during transit through iCloud Drive, so there seems little point in attaching an overriding S flag in practice.

xattrflags11

When I then attached the S flag to each of those xattrs, Spotlight was still able to find the content of those flagged xattrs. This demonstrates that metadata indexing is aware of the xattr flag system, and provided that a xattr type is normally indexed for Spotlight, that indexing isn’t disrupted by the presence of the flag.

xattrflags12

However, the Finder is an exception to this. Some of the com.apple.metadata:kMDItem xattrs are now displayed in the Finder’s Get Info dialog. Adding an S flag to those xattrs renders them inaccessible to the Finder, which clearly isn’t aware of the xattr flag system, and sees them as having different names rather than flags.

xattrflags13

So to summarise:

  • Using xattr flags, apps can readily preserve private file metadata which transits through iCloud Drive. The biggest problem here is that xattr type names aren’t handled transparently by functions such as getxattr(), and it’s up to each app to handle them appropriately.
  • Xattr flags will affect copying files using the Finder and other methods reliant on the copyfile(3) API, but Terminal’s cp normally copies all xattrs regardless of flags.
  • Standard com.apple.metadata:kMDItem xattrs are treated by default as if they already have PS flags, and are preserved during transit through iCloud Drive.
  • Spotlight metadata indexing does appear to take the use of xattr flags into account, and still indexes xattrs with flags correctly.
  • The Finder’s Get Info dialog doesn’t handle xattr flags correctly; setting flags on a xattr type normally displayed by the Finder will render it inaccessible.

I hope those help you decide whether and how to use xattr flags.

Share this:

  • Twitter
  • Facebook
  • Reddit
  • Pinterest
  • Email
  • Print

Like this:

Like Loading...

Related

Posted in Macs, Technology and tagged Apple, cp, extended attributes, Finder, iCloud, iCloud Drive, macOS, macOS 10.14, metadata, Mojave, Spotlight, terminal, xattr. Bookmark the permalink.

1Comment

Add yours
  1. 1
    Michael Tsai - Blog - xattr Flags and iCloud Drive on July 26, 2019 at 8:35 pm

    […] Update (2019-07-26): Howard Oakley: […]

    LikeLike

·Comments are closed.

Quick Links

  • Downloads
  • Mac Troubleshooting Summary
  • M1 & M2 Macs
  • Mac problem-solving
  • Painting topics
  • Painting
  • Long Reads

Search

Monthly archives

  • February 2023 (9)
  • January 2023 (74)
  • December 2022 (74)
  • November 2022 (72)
  • October 2022 (76)
  • September 2022 (72)
  • August 2022 (75)
  • July 2022 (76)
  • June 2022 (73)
  • May 2022 (76)
  • April 2022 (71)
  • March 2022 (77)
  • February 2022 (68)
  • January 2022 (77)
  • December 2021 (75)
  • November 2021 (72)
  • October 2021 (75)
  • September 2021 (76)
  • August 2021 (75)
  • July 2021 (75)
  • June 2021 (71)
  • May 2021 (80)
  • April 2021 (79)
  • March 2021 (77)
  • February 2021 (75)
  • January 2021 (75)
  • December 2020 (77)
  • November 2020 (84)
  • October 2020 (81)
  • September 2020 (79)
  • August 2020 (103)
  • July 2020 (81)
  • June 2020 (78)
  • May 2020 (78)
  • April 2020 (81)
  • March 2020 (86)
  • February 2020 (77)
  • January 2020 (86)
  • December 2019 (82)
  • November 2019 (74)
  • October 2019 (89)
  • September 2019 (80)
  • August 2019 (91)
  • July 2019 (95)
  • June 2019 (88)
  • May 2019 (91)
  • April 2019 (79)
  • March 2019 (78)
  • February 2019 (71)
  • January 2019 (69)
  • December 2018 (79)
  • November 2018 (71)
  • October 2018 (78)
  • September 2018 (76)
  • August 2018 (78)
  • July 2018 (76)
  • June 2018 (77)
  • May 2018 (71)
  • April 2018 (67)
  • March 2018 (73)
  • February 2018 (67)
  • January 2018 (83)
  • December 2017 (94)
  • November 2017 (73)
  • October 2017 (86)
  • September 2017 (92)
  • August 2017 (69)
  • July 2017 (81)
  • June 2017 (76)
  • May 2017 (90)
  • April 2017 (76)
  • March 2017 (79)
  • February 2017 (65)
  • January 2017 (76)
  • December 2016 (75)
  • November 2016 (68)
  • October 2016 (76)
  • September 2016 (78)
  • August 2016 (70)
  • July 2016 (74)
  • June 2016 (66)
  • May 2016 (71)
  • April 2016 (67)
  • March 2016 (71)
  • February 2016 (68)
  • January 2016 (90)
  • December 2015 (96)
  • November 2015 (103)
  • October 2015 (119)
  • September 2015 (115)
  • August 2015 (117)
  • July 2015 (117)
  • June 2015 (105)
  • May 2015 (111)
  • April 2015 (119)
  • March 2015 (69)
  • February 2015 (54)
  • January 2015 (39)

Tags

APFS Apple AppleScript Apple silicon backup Big Sur Blake bug Catalina Consolation Console diagnosis Disk Utility Doré El Capitan extended attributes Finder firmware Gatekeeper Gérôme HFS+ High Sierra history of painting iCloud Impressionism iOS landscape LockRattler log logs M1 Mac Mac history macOS macOS 10.12 macOS 10.13 macOS 10.14 macOS 10.15 macOS 11 macOS 12 macOS 13 malware Mojave Monet Monterey Moreau MRT myth narrative OS X Ovid painting Pissarro Poussin privacy realism Renoir riddle Rubens Sargent scripting security Sierra SilentKnight SSD Swift symbolism Time Machine Turner update upgrade Ventura xattr Xcode XProtect

Statistics

  • 13,788,204 hits
Blog at WordPress.com.
Footer navigation
  • About & Contact
  • Macs
  • Painting
  • Language
  • Tech
  • Life
  • General
  • Downloads
  • Mac problem-solving
  • Extended attributes (xattrs)
  • Painting topics
  • Hieronymus Bosch
  • English language
  • LockRattler: 10.12 Sierra
  • LockRattler: 10.13 High Sierra
  • LockRattler: 10.11 El Capitan
  • Updates: El Capitan
  • Updates: Sierra, High Sierra, Mojave, Catalina, Big Sur
  • LockRattler: 10.14 Mojave
  • SilentKnight, silnite, LockRattler, SystHist & Scrub
  • DelightEd & Podofyllin
  • xattred, Metamer, Sandstrip & xattr tools
  • 32-bitCheck & ArchiChect
  • T2M2, Ulbow, Consolation and log utilities
  • Cirrus & Bailiff
  • Taccy, Signet, Precize, Alifix, UTIutility, Sparsity, alisma
  • Revisionist & DeepTools
  • Text Utilities: Nalaprop, Dystextia and others
  • PDF
  • Keychains & Permissions
  • LockRattler: 10.15 Catalina
  • Updates
  • Spundle, Cormorant, Stibium, Dintch, Fintch and cintch
  • Long Reads
  • Mac Troubleshooting Summary
  • LockRattler: 11.0 Big Sur
  • M1 & M2 Macs
  • Mints: a multifunction utility
  • LockRattler: 12.x Monterey
  • VisualLookUpTest
  • Virtualisation on Apple silicon
  • LockRattler: 13.x Ventura
Secondary navigation
  • Search

Post navigation

Updating Mojave to 10.14.6 is probably safe, as are Sierra and High Sierra Security Updates
The first Italian Master in oil: Antonello da Messina 1

Begin typing your search above and press return to search. Press Esc to cancel.

  • Follow Following
    • The Eclectic Light Company
    • Join 3,133 other followers
    • Already have a WordPress.com account? Log in now.
    • The Eclectic Light Company
    • Customize
    • Follow Following
    • Sign up
    • Log in
    • Copy shortlink
    • Report this content
    • View post in Reader
    • Manage subscriptions
    • Collapse this bar
 

Loading Comments...
 

    %d bloggers like this: