文件属性中的@符号
来源:互联网 发布:四轴单片机 编辑:程序博客网 时间:2024/06/13 02:20
from : http://psionides.eu/2008/06/30/ls-on-mac-and-extended-file-attributes/
Yesterday while I was working in the terminal I noticed something unusual about the results of “ls -al” command:
What are those symbols? I googled for “mac ls at sign”, but most of the results told me that “@” means “symbolic link”. Well, all those files can’t be symbolic links, I’m pretty sure of that. So what are they?
I found the answer in a mail on Apple mailing list. It seems that the @ symbol means that the file has something called “extended attributes”. The attributes are a kind of metadata about the file stored in a special place in the HFS filesystem, not visible during normal browsing. As I learned from a Wikipedia page, most of popular filesystems support such metadata – although I’ve never heard such thing existed in Windows or Linux… The mail also said that apart from “@”, files can have “+” symbol, which means that they have non-standard permissions set using some kind of ACLs.
The mail explained that you can print that metadata by adding a –@ option to ls. I did that, and learned that some of the files had an attribute “com.apple.TextEncoding”, and some others – “com.apple.quarantine”. It’s easy to guess what TextEncoding is for, but quarantine? WTF?
Again, a quick Google search solved the mystery – the quarantine tag is what causes those messages “xxx is an application which was downloaded from the Internet. Are you sure you want to open it?” that I get when I run an application for the first time. Every file (not only applications, it seems) that is downloaded from the Internet is marked with this quarantine metadata tag. When the user confirms that he wants to open the file, the tag is removed and the popup doesn’t appear again.
There is a command line utility for accessing and managing that metadata, named xattr. It can print file’s metadata attributes and their values, modify attributes and remove them, like this:
$ xattr macruby-interview.htmlcom.apple.quarantine$ xattr -l macruby-interview.htmlcom.apple.quarantine: 0000;485e5e65;Firefox;|org.mozilla.firefox$ xattr -w pl.psionides foo macruby-interview.html$ xattr macruby-interview.htmlcom.apple.quarantinepl.psionides$ xattr -l macruby-interview.htmlcom.apple.quarantine: 0000;485e5e65;Firefox;|org.mozilla.firefoxpl.psionides: foo$ xattr -d pl.psionides macruby-interview.html$ xattr -d com.apple.quarantine macruby-interview.html$ xattr macruby-interview.html$ ls -l macruby-interview.html-rw-r--r-- 1 psionides staff 40066 22 cze 16:15 macruby-interview.html
As you can see, the metadata store not only the information that a file was downloaded from the Internet, but also how it was downloaded (using Firefox), and I think also when it was downloaded (the hex value). The -d option can be useful if MacOSX for some reason forgets to remove the quarantine attribute, which – as I’ve read – can happen sometimes.
- 文件属性中的@符号
- Linux中的文件类型以及文件属性
- 文件属性
- 文件属性
- 文件属性
- 文件属性
- 文件属性
- 文件属性
- 文件属性
- 获取文件属性。链接文件(硬链接符号链接)
- 关于文件属性中的如果较新则复制
- Unix中的特殊文件及文件属性
- java实现得到文件属性中的修改时间
- php中的@符号与#符号
- (C#) C#中的@符号
- C#中的@符号
- C++中的#符号
- 英语中的符号说法
- 指针知识梳理10-指向数组的指针
- linq+映射数据库调用方法
- 考CPA的战友们,你们有这么强悍的另一半吗?
- 13hibernate hibernate关联关系的CRUD(增删改查)
- 不更新也能排名上首页的策略
- 文件属性中的@符号
- Treasure Hunt I - ZOJ 3626 树形dp
- 在给文件输出的时候设置默认了怎么修改
- 未来地图,开启万物互联-华中雄
- 深入理解JavaScript系列 ----(11):执行上下文(Execution Contexts)
- 【考据】“烫烫烫”与“锟斤拷”的原理
- 深入浅出Cocoa之类与对象
- 设计模式之单例模式
- 论文读书笔记-主题-word representations learning & Evaluation