Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

File attribute

From Wikipedia, the free encyclopedia
Metadata associated with computer file that define file system behavior

File attributes are a type ofmetadata that describe and may modify howfiles and/ordirectories in afilesystem behave. Typical file attributes may, for example, indicate or specify whether a file is visible, modifiable, compressed, or encrypted. The availability of most file attributes depends on support by the underlying filesystem (such asFAT,NTFS,ext4) where attribute data must be stored along with other control structures. Each attribute can have one of two states: set and cleared. Attributes are considered distinct from other metadata, such as dates and times,filename extensions orfile system permissions. In addition to files,folders,volumes and other file system objects may have attributes.

DOS and Windows

[edit]

Traditionally, inDOS andMicrosoft Windows,files andfolders accepted four attributes:[1][2][3]

  • Archive (A): When set, it indicates that the hosting file has changed since the lastbackup operation. Windows' file system sets this attribute on any file that has changed. Backup software then has the duty of clearing it upon a successful full or incremental backup (not a differential one).
  • Hidden (H): When set, indicates that the hosting file is hidden. MS-DOS commands likedir and Windows apps likeFile Explorer do not show hidden files by default, unless asked to do so.[4]
  • System (S): When set, indicates that the hosting file is a critical system file that is necessary for the computer to operate properly. MS-DOS and Microsoft Windows use it to mark important system files. MS-DOS commands likedir and Windows apps like File Explorer do not show system files by default even when hidden files are shown, unless asked to do so.
  • Read-only (R): When set, indicates that a file should not be altered. Upon opening the file, file systemAPI usually does not grant write permission to the requesting application, unless the application explicitly requests it. Read-only attributes on folders are usually ignored, being used for another purpose.[5][6]

As new versions of Windows came out, Microsoft has added to the inventory of available attributes on theNTFS file system,[7] including but not limited to:[8]

Other attributes that are displayed in the "Attributes" column of Windows Explorer[7] include:

  • Directory (D): The entry is asubdirectory, containing file and directory entries of its own.
  • Reparse Point (L): The file or directory has an associated re-parse point, or is asymbolic link.
  • Offline (O): The file data is physically moved to offline storage (Remote Storage).
  • Sparse (P): The file is asparse file, i.e., its contents are partially empty and non-contiguous.
  • Temporary (T): The file is used for temporary storage.

In DOS,OS/2 and Windows, theattrib command incmd.exe andcommand.com can be used to change and display the four traditional file attributes.[3][9] File Explorer in Windows can show the seven mentioned attributes but cannot set or clear the System attribute.[5]Windows PowerShell, which has become a component ofWindows 7 and later, features two commands that can read and write attributes:Get-ItemProperty andSet-ItemProperty.[10] To change an attribute on a file onWindows NT, the user must have appropriatefile system permissions known asWrite Attributes andWrite Extended Attributes.[11]

Unix and POSIX

[edit]

InUnix and Unix-like systems, includingPOSIX-conforming systems, each file has a 'mode' containing 9 bit flags controlling read, write and execute permission for each of the file's owner, group and all other users (seeFile-system permissions §Traditional Unix permissions for more details) plus thesetuid andsetgid bit flags and a'sticky' bit flag.The mode also specifies thefile type (regular file, directory, or some other special kind).

4.4BSD and derivatives

[edit]

In4.4BSD and4.4BSD-Lite, files and directories (folders) accepted four attributes that could be set by the owner of the file or thesuperuser (the "User" attributes) and two attributes that could only be set by the superuser (the "System" attributes):[12]

  • (User) No-dump: When set, it indicates that the file or directory should not be saved during abackup operation.
  • (User and System) Immutable: When set, indicates that the file or directory should not be altered. Attempts to open the file for writing, create a file within the directory, remove a file from the directory, rename a file within the directory, rename the file or directory, or remove the file or directory will fail with a permissions error.
  • (User and System) Append-only: When set, indicates that the file should only be appended to.
  • (User) Opaque: When set on a directory, indicates that the directory is opaque when viewed through aunion stack.

FreeBSD added some additional attributes,[13] also supported byDragonFly BSD:[14]

  • (User and System) No-unlink: When set, indicates that the file or directory should not be renamed or removed. Attempts to rename or remove the file or directory will fail with a permissions error.

FreeBSD also supports:[13]

  • (System) No-archive: When set, indicates that the file or directory should not be archived.
  • (System) Snapshot: When set, indicates that the file or directory is a snapshot file. This attribute is maintained by the system, and cannot be set, even by the super-user.

whereas DragonFly BSD supports:[14]

  • (User and System) No-history: When set, indicates that history should not be retained for the file or directory.
  • (User) Swapcache: When set, indicates that clean filesystem data for the file, or for the directory and everything underneath the directory, should be cached in swap space on asolid-state drive.
  • (System) Swapcache: When set, indicates that clean filesystem data for the file, or for the directory and everything underneath the directory, shouldnot be cached in swap space on a solid-state drive.
  • (System) Archived: When set, indicates that the file or directory may be archived.

NetBSD added another attribute,[15] also supported byOpenBSD:[16]

  • (System) Archived: When set, indicates that the file or directory is archived.

macOS added three attributes:

  • (User) Hidden: When set, indicates that the file or directory should not, by default, be displayed in the GUI;ls will display it, however.[17]
  • (System) Restricted: When set, indicates that the file or directory will be protected bySystem Integrity Protection
  • (User and System) Compressed: Read-only attribute for files compressed usingHFS+ Compression

In these systems, thechflags andls commands can be used to change and display file attributes. To change a "user" attribute on a file in 4.4BSD-derived operating systems, the user must be the owner of the file or the superuser; to change a "system" attribute, the user must be the superuser.

Linux

[edit]

TheLinux operating system can support awide range of file attributes that can be listed by thelsattr command and modified, where possible, by thechattr command.Programs can examine and alter attributes usingioctl operations.[18]

Many Linux file systems support only a limited set of attributes, and none of them support every attribute thatchattr can change. File systems that support at least some attributes includeext4,XFS andbtrfs.

Common file attributes supported by many common Linux file systems
Attributelsattr flagchattr optionSemantics and rationale
Noatime updatesA+A,-Aatime record is not modified when file is read/accessed.
Append-onlya+a,-a

Writing to file only allowed in append mode.

Immutablei+i,-i

Prevents any change to file's contents or metadata: file/directory cannot be written to, deleted, renamed, or hard-linked.

No dumpd+d,-dFile is skipped by thedump program
Secure deletions+s,-sRequests that, when deleted, all file data blocks arefilled with zeroes.
Synchronous updatesS+S,-SChanges are written synchronously to the underlying filesystem storage medium; equivalent to 'sync' mount option for affected files.

OpenSolaris and derivatives

[edit]

Support for "system attributes" (in which the operating system defines the meaning, unlike generalextended file attributes) was added to OpenSolaris in 2007 in support of the CIFS server.[19] It has been carried forward from there into both theOracle Solaris 11 releases and the open sourceillumos project.

In this implementation, awide range of attributes can be set via thechmod command[20][21] and listed by thels command.[22][23]Programs can examine and alter attributes using thegetattrat andsetattrat functions.[24][25]

Currently theZFS file system supports all defined attributes, and starting in Oracle Solaris 11.2, thetmpfs file system supports a subset of attributes.[26]

Common file attributes supported by Oracle Solaris and illumos systems
AttributeCompact flag forls &chmodSemantics and rationale
appendonlya

Writing to file only allowed in append mode.

immutablei

Prevents any change to file's contents or metadata (except access time): file/directory cannot be written to, deleted, or renamed.

nodumpdFile should be skipped by backup programs
nounlinkuPrevents removing the file, but allows other changes.

See also

[edit]

References

[edit]
  1. ^"Definition of: file attribute".PC Magazine.Ziff Davis. Retrieved14 October 2020.
  2. ^"File attributes".Computer Hope. Retrieved2 December 2012.
  3. ^ab"In Windows, what are file attributes, and how can I change them?".Knowledge Base.Indiana University. 11 October 2011. Retrieved2 December 2012.
  4. ^"What is a hidden file?".Windows 7 Help. Microsoft. Retrieved2 December 2012.
  5. ^ab"You cannot view or change the Read-only or the System attributes of folders in Windows Server 2003, in Windows XP, in Windows Vista or in Windows 7".Microsoft Support. Microsoft. 31 May 2012. Retrieved2 December 2012.
  6. ^"Why is the readonly property on folders so strange?".
  7. ^ab"File Attribute Constants".MSDN.Microsoft. Retrieved17 July 2018.
  8. ^"HOW TO: Use the File Attribute Management Script (Fileattributes.pl) in Windows 2000".Microsoft support. Microsoft. Retrieved2 December 2012.
  9. ^"Definition of: DOS Attrib".PC Magazine.Ziff Davis. Archived fromthe original on 2 March 2012. Retrieved2 December 2012.
  10. ^"Use a PowerShell Cmdlet to Work with File Attributes".Hey, Scripting Guy! Blog. Microsoft. 26 January 2011. Retrieved3 December 2012.
  11. ^"How to set, view, change, or remove special permissions for files and folders in Windows XP".Microsoft Support. Microsoft. 7 May 2007. Retrieved2 December 2012.
  12. ^chflags(2) – BSD System CallsManual
  13. ^abchflags(2) – FreeBSD System CallsManual
  14. ^abchflags(2) – DragonFly BSD System Calls and Error NumbersManual
  15. ^chflags(2) – NetBSD System CallsManual
  16. ^chflags(2) – OpenBSD System CallsManual
  17. ^chflags(2) – Darwin andmacOS System CallsManual
  18. ^ioctl_iflags(2) – Linux Programmer'sManual – System Calls from Manned.org
  19. ^Shellenbaum, Mark."Extensible Attribute Interfaces [PSARC/2007/315]".OpenSolaris ARC Material Archive. illumos.org. Retrieved10 March 2023.
  20. ^"chmod(1)".Oracle Solaris 11.4 Reference Library: man pages section 1: User Commands. Oracle. Retrieved10 March 2023.
  21. ^"chmod(1)".illumos man pages. illumos.org. Retrieved10 March 2023.
  22. ^"ls(1)".Oracle Solaris 11.4 Reference Library: man pages section 1: User Commands. Oracle. Retrieved10 March 2023.
  23. ^"ls(1)".illumos man pages. illumos.org. Retrieved10 March 2023.
  24. ^"getattrat(3c)/setattrat(3c)".Oracle Solaris 11.4 Reference Library: man pages section 3: Basic Library Functions. Oracle. Retrieved10 March 2023.
  25. ^"getattrat(3c)/setattrat(3c)".illumos man pages. illumos.org. Retrieved10 March 2023.
  26. ^"sysattr(7)".Oracle Solaris 11.4 Reference Library: man pages section 7. Oracle. Retrieved10 March 2023.

External links

[edit]
Types
Properties
Organisation
Operations
Linking
Management
Disk and
non-rotating
Optical disc
Flash memory andSSD
host-sidewear leveling
Distributed parallel
NAS
Specialized
Pseudo
Encrypted
Types
Features
Access control
Interfaces
Lists
Layouts
Retrieved from "https://en.wikipedia.org/w/index.php?title=File_attribute&oldid=1245517100"
Category:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp