星期日, 11月 23, 2008

user_xattr in SuSE Linux

在使用SuSE Linux Enterprise Server 的時候都會在管理Partition的時候
看到預設的mount option 為 acl,user_xattr

acl 為Access Control List, 但是 user_xattr 的mount option 就比較少看到

參考小州老師的文章
引用於:
http://www.lccnet.com.tw/commercial/e-paper/0507/lecture_02.html

Extended Attribute (EA),可以讓使用者對於檔案目錄提供額外的標籤紀錄來表示內容描述


所以就來實做lab 一下
首先先觀察是否有啟用 user_xattr的 mount option
linux-mk16:~ # cat /etc/fstab | grep home
/dev/sda3 /home ext3 acl,user_xattr,usrquota,grpquota 1 2

所以目前是有加上 user_xattr 選項
ok, 來實際lab

linux-mk16:/home/max # touch /home/max/xattr_test
linux-mk16:/home/max # ls /home/max/
big2 maxfile maxfile2 maxfile3 xattr_test

建立一個檔案 xattr_test 於/home/max

linux-mk16:/home/max # getfattr /home/max/xattr_test
觀察相關的資訊

使用setfattr 設定 相關的資訊
linux-mk16:/home/max # setfattr -n user.max -v "max info" /home/max/xattr_test
linux-mk16:/home/max # setfattr -n user.ines -v "ines label" /home/max/xattr_test

再次觀察相關的資訊,會看到名稱的資訊
linux-mk16:/home/max # getfattr /home/max/xattr_test
getfattr: Removing leading '/' from absolute path names
# file: home/max/xattr_test
user.ines
user.max

根據名稱來觀察裡面的value
linux-mk16:/home/max # getfattr -n user.max /home/max/xattr_test
getfattr: Removing leading '/' from absolute path names
# file: home/max/xattr_test
user.max="max info"

linux-mk16:/home/max # getfattr -n user.ines /home/max/xattr_test
getfattr: Removing leading '/' from absolute path names
# file: home/max/xattr_test
user.ines="ines label"


^__^
Lab 完成, 提醒一下自己