Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Directory (computing)

From Wikipedia, the free encyclopedia
(Redirected fromFolder (computing))
File system structure for locating files
Screenshot of aMicrosoft Windowscommand prompt window showing a directory listing.

Incomputing, adirectory is afile system cataloging structure that contains references to othercomputer files, and possibly other directories. On many computers, directories are known asfolders ordrawers,[1]analogous to aworkbench or the traditional officefiling cabinet. The name derives from books like atelephone directory that lists the phone numbers of all the people living in a certain area.

Files are organized by storing related files in the same directory. In ahierarchical file system (that is, one in which files and directories are organized in a manner that resembles atree), a directory contained inside another directory is called asubdirectory. The termsparent andchild are often used to describe the relationship between a subdirectory and the directory in which it is cataloged, the latter being the parent. The top-most directory in such a filesystem, which does not have a parent of its own, is called theroot directory.

Thefreedesktop.org media type for directories within manyUnix-like systems – including but not limited to systems usingGNOME,KDE Plasma 5, orROX Desktop as the desktop environment – is "inode/directory".[2] This is not anIANA registered media type.

Overview

[edit]
Diagram of a hierarchical directory tree. The root directory is here called "MFD", for Master File Directory. Usually a file can only be in one directory at a time, but here File 2 ishard linked so it appears in two directories.

Historically, and even on some modernembedded systems, the file systems either had no support for directories at all or had only a "flat"directory structure, meaning subdirectories were not supported; there was only a group of top-level directories, each containing files. In modern systems, a directory can contain a mix of files and subdirectories.

A reference to a location in a directory system is called apath.

In manyoperating systems, programs have an associatedworking directory in which they execute. Typically, file names accessed by the program are assumed to reside within this directory if the file names are not specified with an explicit directory name.

Some operating systems restrict auser's access only to theirhome directory or project directory, thus isolating their activities from all other users. In early versions of Unix, the root directory was the home directory of theroot user, but modern Unix usually uses another directory such as/root for this purpose.

In keeping withUnix philosophy, Unix systems treat directories as a type of file.[3] Caveats include not being able to write to a directory file except indirectly by creating, renaming, and removing file system objects in the directory and only being able to read from a directory file using directory-specific library routines andsystem calls that return records, not a byte-stream.[4]

Folder metaphor

[edit]
Sample folder icon (fromKDE).

The namefolder, presenting an analogy to thefile folder used in offices, and used in a hierarchical file system design for theElectronic Recording Machine, Accounting (ERMA) Mark 1 published in 1958[5] as well as byXerox Star,[6] is used in almost all modernoperating systems' desktop environments. Folders are often depicted withicons that visually resemble physical file folders.

There is a difference between adirectory, which is afile system concept, and thegraphical user interface metaphor that is used to represent it (afolder).[original research?] For example,Microsoft Windows uses the concept ofspecial folders to help present the contents of the computer to the user in a fairly consistent way that frees the user from having to deal with absolute directory paths, which can vary between versions of Windows, and between individual installations. Many operating systems also have the concept of "smart folders" orvirtual folders that reflect the results of a file system search or other operation. These folders do not represent a directory in the file hierarchy. Manyemail clients allow the creation of folders to organize email. These folders have no corresponding representation in the filesystem structure.

If one is referring to acontainer of documents, the termfolder is more appropriate.[citation needed] The termdirectory refers to the way a structured list of document files and folders are stored on the computer. The distinction can be due to the way a directory is accessed; on Unix systems,/usr/bin/ is usually referred to as a directory when viewed in acommand lineconsole, but if accessed through a graphicalfile manager, users may sometimes call it a folder.

Lookup cache

[edit]
icon
This sectionneeds additional citations forverification. Please helpimprove this article byadding citations to reliable sources in this section. Unsourced material may be challenged and removed.(October 2025) (Learn how and when to remove this message)

Operating systems that support hierarchical file systems implement a form ofcaching inRAM to speed up file path resolution. This mechanism reduces the overhead associated with repeatedly traversing file system hierarchies to resolvepathnames intoinode references.

InUnix-like systems, this may be called thedirectory name lookup cache (DNLC),directory entry cache, ordcache.[7][8]

Overview

[edit]

Directory lookup caches store mappings between absolute or relative path components (such as `/usr/bin`) and their corresponding inode or directory entry objects. This allows the system to bypass full path traversal for frequently accessed files or directories, dramatically improving performance for workloads with heavy metadata operations.

The cache is typically implemented using fast lookup structures such as hash tables or radix trees, and may utilize aging algorithms such asLRU for cache eviction.

Historical background

[edit]

SunOS introduced a lookup cache as part of the implementation ofNFS;[7] however, it was not only used by NFS. It has since been adapted and extended in systems such as Linux, BSD, Solaris, and macOS.

Implementations

[edit]

Windows

[edit]

Windows uses internal path caching mechanisms as part of its NTFS and kernel object manager layers, though these are not always exposed directly.

BSD variants

[edit]

BSD variants, includingFreeBSD,NetBSD,[9]OpenBSD,[10] andDragonFly BSD implement directory lookup caches.

macOS

[edit]

macOS integrates lookup caching into its VFS layer.[11]

Linux

[edit]

The Linux kernel's Virtual File System (VFS) layer uses a structure called thedcache to cache directory entry objects (dcache entries). Each dentry links to an inode and can represent a file or subdirectory. These dentries are organized in a tree structure that mirrors the directory hierarchy and are stored in memory as long as there is no memory pressure.

In addition to speeding up file lookups, the dcache also plays a role in maintaining consistency across mounted file systems, including complex setups with overlays or bind mounts.

Cache coherence in distributed file systems

[edit]

Fordistributed file systems such asNFS orAFS, the cache must remain coherent across multiple clients. In such systems, a change made on one client must be reflected in other clients' lookup caches. To achieve this, network file systems use a variety of mechanisms:

  • Attribute timeouts
  • Lease-based locking (e.g.,NFSv4 delegations)
  • Callback invalidations (e.g., AFS)

Failure to ensure coherence may result in stale file metadata or incorrect path resolution, leading to application errors or data loss.

Performance impact

[edit]

Optimized directory lookup caches can significantly reduce system call latency for file operations such as `open()`, `stat()`, and `execve()`. In benchmark tests, systems with aggressive dentry caching have shown orders-of-magnitude improvements in access times for large codebases and system boot times.

See also

[edit]
Lookup cache related
File system structure
Operating system concepts
Common commands

References

[edit]
  1. ^"Chapter 1: Tutorial".Using The AMIGA Workbench. Commodore-Amiga. July 1991. p. 46.The path specifies the disk name, or location, and all of the drawers that lead to the specified file.
  2. ^Leonard, Thomas (2018-10-02)."Shared MIME-info Database".X Desktop Group. Non-regular files. Retrieved2023-03-13.
  3. ^"Everything is a File".Behavior Genetics Association. c. 2002. Archived fromthe original on March 10, 2012. RetrievedApril 30, 2021.
  4. ^"readdir(3) — Linux manual page". The Linux man-pages project. 2021-03-22. RetrievedNovember 27, 2022.
  5. ^Barnard III, G. A.; Fein, L. (1958)."Organization and Retrieval of Records Generated in a Large-Scale Engineering Project".International Workshop on Managing Requirements Knowledge. Philadelphia, PA, USA. pp. 59–63.doi:10.1109/AFIPS.1958.75.
  6. ^""Xerox Star User Interface (1982)"".YouTube. 28 August 2009.Archived from the original on 2021-12-21. Retrieved19 November 2014.
  7. ^abRussel Sandberg; David Goldberg; Steve Kleiman; Dan Walsh; Bob Lyon.Design and Implementation of the Sun Network Filesystem(PDF). Summer 1985 USENIX Conference and Exhibition. Portland, Oregon, USA.
  8. ^"Close-To-Open Cache Consistency in the Linux NFS Client". Center for Information Technology Integration, University of Michigan. Retrieved19 November 2014.
  9. ^namecache(9) – NetBSD Kernel Developer'sManual
  10. ^vfs_cache(9) – OpenBSD Kernel Developer'sManual
  11. ^"cache_lookup".Apple Developer.

External links

[edit]
Wikimedia Commons has media related toFile system directories.
Types
Properties
Organisation
Operations
Linking
Management
Retrieved from "https://en.wikipedia.org/w/index.php?title=Directory_(computing)&oldid=1318593364#Folder_metaphor"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp