Share to: share facebook share twitter share wa share telegram print page
Available for Advertising

Inode

The inode (index node) is a data structure in a Unix-style file system that describes a file-system object such as a file or a directory. Each inode stores the attributes and disk block locations of the object's data.[1] File-system object attributes may include metadata (times of last change,[2] access, modification), as well as owner and permission data.[3]

A directory is a list of inodes with their assigned names. The list includes an entry for itself, its parent, and each of its children.

Etymology

There has been uncertainty on the Linux kernel mailing list about the reason for the "i" in "inode". In 2002, the question was brought to Unix pioneer Dennis Ritchie, who replied:[4]

In truth, I don't know either. It was just a term that we started to use. "Index" is my best guess, because of the slightly unusual file system structure that stored the access information of files as a flat array on the disk, with all the hierarchical directory information living aside from this. Thus the i-number is an index in this array, the i-node is the selected element of the array. (The "i-" notation was used in the 1st edition manual; its hyphen was gradually dropped.)

A 1978 paper by Ritchie and Ken Thompson bolsters the notion of "index" being the etymological origin of inodes. They wrote:[5]

[…] a directory entry contains only a name for the associated file and a pointer to the file itself. This pointer is an integer called the i-number (for index number) of the file. When the file is accessed, its i-number is used as an index into a system table (the i-list) stored in a known part of the device on which the directory resides. The entry found thereby (the file's i-node) contains the description of the file.

Additionally, Maurice J. Bach wrote that the word inode "is a contraction of the term index node and is commonly used in literature on the UNIX system".[6]

Details

File descriptors, file table and inode table in Unix[7]

A file system relies on data structures about the files, as opposed to the contents of that file. The former are called metadata—data that describes data. Each file is associated with an inode, which is identified by an integer, often referred to as an i-number or inode number.

Inodes store information about files and directories (folders), such as file ownership, access mode (read, write, execute permissions), and file type. The data may be called stat data, in reference to the stat system call that provides the data to programs.

The inode number indexes a table of inodes on the file system. From the inode number, the kernel's file system driver can access the inode contents, including the location of the file, thereby allowing access to the file. A file's inode number can be found using the ls -i command. The ls -i command prints the inode number in the first column of the report.

On many older file systems, inodes are stored in one or more fixed-size areas that are set up at file system creation time, so the maximum number of inodes is fixed at file system creation, limiting the maximum number of files the file system can hold. A typical allocation heuristic for inodes in a file system is one inode for every 2K bytes contained in the filesystem.[8]

Some Unix-style file systems such as JFS, XFS, ZFS, OpenZFS, ReiserFS, btrfs, and APFS omit a fixed-size inode table, but must store equivalent data in order to provide equivalent capabilities. Common alternatives to the fixed-size table include B-trees and the derived B+ trees.

File names and directory implications:

  • Inodes do not contain their hard link names, only other file metadata.
  • Unix directories are lists of association structures, each of which contains one filename and one inode number.
  • The file system driver must search a directory for a particular filename and then convert the filename to the correct corresponding inode number.

The operating system kernel's in-memory representation of this data is called struct inode in Linux. Systems derived from BSD use the term vnode (the "v" refers to the kernel's virtual file system layer).

POSIX inode description

The POSIX standard mandates file-system behavior that is strongly influenced by traditional UNIX file systems. An inode is denoted by the phrase "file serial number", defined as a per-file system unique identifier for a file.[9] That file serial number, together with the device ID of the device containing the file, uniquely identify the file within the whole system.[10]

Within a POSIX system, a file has the following attributes[10] which may be retrieved by the stat system call:

  • Device ID (this identifies the device containing the file; that is, the scope of uniqueness of the serial number).
  • File serial numbers.
  • The file mode which determines the file type and how the file's owner, its group, and others can access the file.
  • A link count telling how many hard links point to the inode.
  • The User ID of the file's owner.
  • The Group ID of the file.
  • The device ID of the file if it is a device file.
  • The size of the file in bytes.
  • Timestamps telling when the inode itself was last modified (ctime, inode change time), the file content last modified (mtime, modification time), and last accessed (atime, access time).
  • The preferred I/O block size.
  • The number of blocks allocated to this file.

Implications

Filesystems designed with inodes will have the following administrative characteristics:

Files can have multiple names. If multiple names hard link to the same inode then the names are equivalent; i.e., the first to be created has no special status. This is unlike symbolic links, which depend on the original name, not the inode (number).

inode persistence and unlinked files

An inode may have no links. An inode without links represents a file with no remaining directory entries or paths leading to it in the filesystem. A file that has been deleted or lacks directory entries pointing to it is termed an 'unlinked' file.

Such files are removed from the filesystem, freeing the occupied disk space for reuse. An inode without links remains in the filesystem until the resources (disk space and blocks) freed by the unlinked file are deallocated or the file system is modified.

Although an unlinked file becomes invisible in the filesystem, its deletion is deferred until all processes with access to the file have finished using it, including executable files which are implicitly held open by the processes executing them.

inode number conversion and file directory path retrieval

It is typically not possible to map from an open file to the filename that was used to open it. When a program opens a file, the operating system converts the filename to an inode number and then discards the filename. As a result, functions like getcwd() and getwd() which retrieve the current working directory of the process, cannot directly access the filename.

Beginning with the current directory, these functions search up to its parent directory, then to the parent's parent, and so on, until reaching the root directory. At each level, the function looks for a directory entry whose inode matches that of the directory it just moved up from. Because the child directory's inode still exists as an entry in its parent directory, it allows the function to reconstruct the absolute path of the current working directory.

Some operating systems maintain extra information to make this operation run faster. For example, in the Linux VFS,[11] directory entry cache,[12] also known as dentry or dcache, are cache entries used by the kernel to speed up filesystem operations by storing information about directory links in RAM.

Historical possibility of directory hard linking

Historically, it was possible to hard link directories. This made the directory structure an arbitrary directed graph contrary to a directed acyclic graph. It was even possible for a directory to be its own parent. Modern systems generally prohibit this confusing state, except that the parent of root is still defined as root. The most notable exception to this prohibition is found in Mac OS X (versions 10.5 and higher) which allows hard links of directories to be created by the superuser.[13]

inode number stability and non-Unix file systems

When a file is relocated to a different directory on the same file system, or when a disk defragmentation alters its physical location, the file's inode number remains unchanged.

This unique characteristic permits the file to be moved or renamed even during read or write operations, thereby ensuring continuous access without disruptions.

This feature—having a file's metadata and data block locations persist in a central data structure, irrespective of file renaming or moving—cannot be fully replicated in many non-Unix file systems like FAT and its derivatives, as they lack a mechanism to maintain this invariant property when both the file's directory entry and its data are simultaneously relocated. In these file systems, moving or renaming a file might lead to more significant changes in the data structure representing the file, and the system does not keep a separate, central record of the file's data block locations and metadata as inodes do in Unix-like systems.

Simplified library installation with inode file systems

inode file systems allow a running process to continue accessing a library file even as another process is replacing that same file.

This operation should be performed atomically, meaning it should appear as a single operation that is either entirely completed or not done at all, with no intermediate state visible to other processes.

During the replacement, a new inode is created for the new library file, establishing an entirely new mapping. Subsequently, future access requests for that library will retrieve the newly installed version.

When the operating system is replacing the file (and creating a new inode), it places a lock[14] on the inode[15] and possibly the containing directory.[16] This prevents other processes from reading or writing to the file (inode)[17] during the update operation, thereby avoiding data inconsistency or corruption.[18]

Once the update operation is complete, the lock is released. Any subsequent access to the file (via the inode) by any processes will now point to the new version of the library. Thus, making it possible to perform updates even when the library is in use by another process.

One significant advantage of this mechanism is that it eliminates the need for a system reboot to replace libraries currently in use. Consequently, systems can update or upgrade software libraries seamlessly without interrupting running processes or operations.

Potential for inode exhaustion and solutions

When a file system is created, some file systems allocate a fixed number of inodes.[19] This means that it is possible to run out of inodes on a file system, even if there is free space remaining in the file system. This situation often arises in use cases where there are many small files, such as on a server storing email messages, because each file, no matter how small, requires its own inode.

Other file systems avoid this limitation by using dynamic inode allocation.[20] Dynamic inode allocation allows a file system to create more inodes as needed instead of relying on a fixed number created at the time of file system creation.[21] This can "grow" the file system by increasing the number of inodes available for new files and directories, thus avoiding the problem of running out of inodes.[22]

Inlining

It can make sense to store very small files in the inode itself to save both space (no data block needed) and lookup time (no further disk access needed). This file system feature is called inlining. The strict separation of inode and file data thus can no longer be assumed when using modern file systems.

If the data of a file fits in the space allocated for pointers to the data, this space can conveniently be used. For example, ext2 and its successors store the data of symlinks (typically file names) in this way if the data is no more than 60 bytes ("fast symbolic links").[23]

Ext4 has a file system option called inline_data that allows ext4 to perform inlining if enabled during file system creation. Because an inode's size is limited, this only works for very small files.[24]

In non-Unix systems

  • NTFS has a master file table (MFT) storing files in a B-tree. Each entry has a "fileID", analogous to the inode number, that uniquely refers to this entry.[25] The three timestamps, a device ID, attributes, reference count, and file sizes are found in the entry, but unlike in POSIX the permissions are expressed through a different API.[26] The on-disk layout is more complex.[27] The earlier FAT file systems did not have such a table and were incapable of making hard links.
    • NTFS also has a concept of inlining small files into the MFT entry.[28]
    • The derived ReFS has a homologous MFT. ReFS has a 128-bit file ID; this extension was also backported to NTFS, which originally had a 64-bit file ID.[26]
  • The same stat-like GetFileInformationByHandle API can be used on Cluster Shared Volumes and SMB 3.0, so these systems presumably have a similar concept of a file ID.[26]

See also

References

  1. ^ Tanenbaum, Andrew S. Modern Operating Systems (3rd ed.). p. 279.
  2. ^ JVSANTEN. "Difference between mtime, ctime and atime - Linux Howtos and FAQs". Linux Howtos and FAQs. Archived from the original on 2016-11-20.{{cite web}}: CS1 maint: unfit URL (link)
  3. ^ "Anatomy of the Linux virtual file system switch". ibm.com.
  4. ^ Landley, Rob (July 20, 2002). "Fwd: Re: What does the "i" in inode stand for? Dennis Ritchie doesn't know either". linux-kernel (Mailing list). Retrieved 2011-01-12.
  5. ^ Ritchie, Dennis M.; Thompson, Ken (1978). "The UNIX Time-Sharing System". The Bell System Technical Journal. 57 (6): 1913–1914. Retrieved 19 December 2015.
  6. ^ Maurice J. Bach (1986). The Design of the UNIX Operating System. Prentice Hall. ISBN 978-0132017992.
  7. ^ Bach, Maurice J. (1986). The Design of the UNIX Operating System. Prentice Hall. p. 94. Bibcode:1986duos.book.....B.
  8. ^ "linfo". The Linux Information Project. Retrieved 11 March 2020.
  9. ^ "Definitions - 3.176 File Serial Number". The Open Group. Retrieved 10 January 2018.
  10. ^ a b "<sys/stat.h>". The Open Group. Retrieved 15 January 2018.
  11. ^ Gooch, Richard. Enberg, Pekka (ed.). "Overview of the Linux Virtual File System". kernel.org. Retrieved 20 May 2023.
  12. ^ Richard Gooch. Enberg, Pekka (ed.). "Directory Entry Cache (dcache)". kernel.org. Retrieved 20 May 2023.
  13. ^ "What is the Unix command to create a hardlink to a directory in OS X?". Stack Overflow. 16 Jan 2011. Archived from the original on 5 January 2020. Retrieved 5 Jan 2020.
  14. ^ The kernel development community. "Locking". kernel.org. Retrieved 21 May 2023.
  15. ^ Gooch, Richard. Enberg, Pekka (ed.). "struct inode_operations". kernel.org. Retrieved 21 May 2023.
  16. ^ The kernel development community. "Directory Locking". kernel.org. Retrieved 21 May 2023.
  17. ^ The kernel development community. "Lock types and their rules". kernel.org. Retrieved 21 May 2023.
  18. ^ van de Ven, A., Molnar, I. "Runtime locking correctness validator". kernel.org. Retrieved 21 May 2023.{{cite web}}: CS1 maint: multiple names: authors list (link)
  19. ^ The kernel development community. "2. High Level Design". kernel.org. Retrieved 21 May 2023.
  20. ^ The kernel development community. "XFS Self Describing Metadata". kernel.org. Retrieved 21 May 2023.
  21. ^ The kernel development community. "2.7. Block and Inode Allocation Policy". kernel.org. Retrieved 21 May 2023.
  22. ^ Vadala, Derek (2002). "6. Filesystems". Managing RAID on Linux. O'Reilly Media, Inc. ISBN 9781565927308.
  23. ^ "The Linux kernel: Filesystems". tue.nl.
  24. ^ "Ext4 Disk Layout". kernel.org. Retrieved August 18, 2013.
  25. ^ "Does Windows have Inode Numbers like Linux?". Stack Overflow.
  26. ^ a b c "GetFileInformationByHandle function (fileapi.h) - Win32 apps". docs.microsoft.com.
  27. ^ "[MS-FSCC]: NTFS Attribute Types". docs.microsoft.com.
  28. ^ "Windows - Maximum size of file that can be stored entirely in NTFS Master File Table (MFT)".

Read other articles:

Кубок России по волейболу среди женщин 1995 Время проведения май—сентябрь Итоговая расстановка Чемпион «Заречье» Московская обл. Второе место «Динамо» Краснодар Третье место «Метар» Челябинск 19941996 3-й розыгрыш Кубка России по волейболу среди женских команд проходил с

Kereta Api Nasional Filipina Pambansang Daambakal ng Pilipinascode: fil is deprecated IndustriTransportasi relDidirikan24 November 1892; 130 tahun lalu (1892-11-24)KantorpusatManila, FilipinaWilayah operasiMetro ManilaCalabarzonBicol RegionTokohkunciRet. P/Dir. Gen. Roberto T. Lastimoso, PNP, ChairmanJunn B. Magno, General ManagerJasaSaat ini:Kereta komuterTidak beroperasi[a]:Kereta antar kota Kereta barangPemilikPemerintah Filipina dibawah DOTrSitus webhttp://www.pnr.gov.ph/ Kereta Api ...

Genus of lizards This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: Podarcis – news · newspapers · books · scholar · JSTOR (March 2016) (Learn how and when to remove this template message) PodarcisTemporal range: 2.58–0 Ma PreꞒ Ꞓ O S D C P T J K Pg N ↓ Pleistocene – Recent[1] Common w...

يفتقر محتوى هذه المقالة إلى الاستشهاد بمصادر. فضلاً، ساهم في تطوير هذه المقالة من خلال إضافة مصادر موثوق بها. أي معلومات غير موثقة يمكن التشكيك بها وإزالتها. (ديسمبر 2018) حارة زبيد  - حارة -  تقسيم إداري البلد  اليمن المحافظة محافظة صنعاء المديرية مديرية ضواحي الأم

دوري الدرجة الأولى الأرجنتيني 1986–87 تفاصيل الموسم دوري الدرجة الأولى الأرجنتيني  النسخة 57  البلد الأرجنتين  البطل روزاريو سنترال  عدد المشاركين 20   دوري الدرجة الأولى الأرجنتيني 1985–86  دوري الدرجة الأولى الأرجنتيني 1987–88  تعديل مصدري - تعديل   دوري الدر...

هذه صفحة توثيق قالب:صندوق معلومات شخصية خيالية الفرعية، لشرح القالب وتصنيفه، وهي لا تدخل في استخدامه. هذا القالب يستعمل لوا: وحدة:Check for unknown parametersوحدة:Unsubstوحدة:Wikidata2 هذا القالب يستخدم خاصية أو أكثر من ويكي بيانات. طالع > ويكي بيانات للتفاصيل. هذا القالب يستخدم قالب {{صندوق ...

American actress Not to be confused with Christine McCarthy. Christine EliseElise in 2009OccupationActressYears active1988–presentPartnerJason Priestley (1992-1997) Christine Elise McCarthy, professionally known as Christine Elise, is an American film and television actress. She is best known for her roles as Emily Valentine in Beverly Hills, 90210 and BH90210 and Kyle in the Child's Play franchise, first appearing in Child's Play 2 (1990) and reprising the role in Cult of Chucky (2017...

この記事の主題はウィキペディアにおける人物の特筆性の基準を満たしていないおそれがあります。基準に適合することを証明するために、記事の主題についての信頼できる二次資料を求めています。なお、適合することが証明できない場合には、記事は統合されるか、リダイレクトに置き換えられるか、さもなくば削除される可能性があります。出典検索?: 近藤重...

Ghede Chokra'sAlbum studio karya Shark MoveDirilis1973GenreRockDurasi34:34LabelShark Move RecordsProduserBhagu RamchandKronologi Shark Move Ghede Chokra's(1973) My Life(1976)My Life1976 Ghede Chokra's adalah album perdana dari grup musik Shark Move yang dirilis pada tahun 1973 secara independen[1] oleh Shark Move Records. Album Ghede Chokra's ditempatkan pada peringkat ke-94 dalam daftar 150 Album Indonesia Terbaik versi majalah Rolling Stone Indonesia yang diterbitkan pada edisi ...

هذه المقالة يتيمة إذ تصل إليها مقالات أخرى قليلة جدًا. فضلًا، ساعد بإضافة وصلة إليها في مقالات متعلقة بها. (نوفمبر 2022) بيوتر جلينسكي (بالبولندية: Piotr Glinski)‏    مناصب عضو سيم   تولى المنصب2015  نائب رئيس وزراء جمهورية بولندا[2]   في المنصب16 نوفمبر 2015  – 21 يونيو 202...

يفتقر محتوى هذه المقالة إلى الاستشهاد بمصادر. فضلاً، ساهم في تطوير هذه المقالة من خلال إضافة مصادر موثوق بها. أي معلومات غير موثقة يمكن التشكيك بها وإزالتها. (ديسمبر 2018) كان نظام الحكم ملكي في أيرلندا منذ العصور القديمة وحتى أصبح ماهي عليه الآن جمهورية أيرلندا في منتصف القر...

Torture method simulating drowning Not to be confused with Wakeboarding. The examples and perspective in this article deal primarily with the United States and do not represent a worldwide view of the subject. You may improve this article, discuss the issue on the talk page, or create a new article, as appropriate. (April 2016) (Learn how and when to remove this template message) Two United States soldiers and one South Vietnamese soldier waterboard a captured North Vietnamese prisoner of war...

Award Award The 2021 Nobel Prize in Physiology or MedicineJulius (left) and Patapoutian (right) for the discovery of receptors for temperature and touch.Date4 October 2021 (2021-10-04)LocationStockholmCountrySwedenPresented byNobel Assembly at Karolinska InstitutetHosted byThomas PerlmannReward(s)9 million SEK (2017)[1]First awarded19012021 laureatesDavid Julius and Ardem PatapoutianWebsite2021 Nobel Prize in Physiology or Medicine ← 2020 · Nobel Prize ...

Chemical group (–C(=O)C₆H₅) Not to be confused with Benzyl group. The benzoyl functional group. In organic chemistry, benzoyl (/ˈbɛnzoʊɪl/, BENZ-oh-il)[1] is the functional group with the formula −COC6H5 and structure −C(=O)−C6H5.[2][3] It can be viewed as benzaldehyde missing one hydrogen. The benzoyl group has a mass of 105 amu. The term benzoyl should not be confused with benzyl, which has the formula −CH2−C6H5. The benzoyl group is given the sym...

George Byng, 6e burggraaf Torrington Geboren 1768 Overleden 1831 Land/zijde Verenigd Koninkrijk Onderdeel Royal Navy Rang Vice Admiral Bevel HMS Cumberland (1807) George Byng (1768–1831), de 6e burggraaf Torrington was een Vice-Admiraal in de Britse Koninklijke marine. Koning Willem I der Nederlanden benoemde Lord Viscount Torrington in een Koninklijk Besluit van 7 februari 1816 tot Officier in de Militaire Willems-Orde omdat hij gecommandeerd hebbende het schip de Warrior aan welks boord W...

Місто Голі-Бриджангл. Gauley Bridge Координати 38°10′04″ пн. ш. 81°11′48″ зх. д. / 38.16780000002777484° пн. ш. 81.19690000002778163° зх. д. / 38.16780000002777484; -81.19690000002778163Координати: 38°10′04″ пн. ш. 81°11′48″ зх. д. / 38.16780000002777484° пн. ш. 81.19690000002778163° зх. д....

High school in Middlesex County, New Jersey, United States Middlesex High SchoolAddress300 John F. Kennedy DriveMiddlesex, Middlesex County, New Jersey 08846United StatesCoordinates40°35′00″N 74°29′42″W / 40.5832°N 74.4951°W / 40.5832; -74.4951InformationTypePublic high schoolMottoHome of the Blue JaysEstablished1959NCES School ID341005003404[1]PrincipalRyan ReganFaculty54.1 FTEs[1]Grades9-12[1]Enrollment622 (as of 2021–22)[1&#...

For the title character, see Lisa Simpson. 17th episode of the 9th season of The Simpsons Lisa the SimpsonThe Simpsons episodeFearing she has inherited the “Simpson gene”, Lisa envisions herself as an obese woman who needs a boat oar to get out of a hammock. This scene has become popular online in recent years.Episode no.Season 9Episode 17Directed bySusie DietterWritten byNed GoldreyerProduction code4F24Original air dateMarch 8, 1998 (1998-03-08)Guest appearancePhil Ha...

Island in Greece This article is about the Greek island of Rhodes. For other uses, see Rhodes (disambiguation). Rodi redirects here. For other uses, see Rodi (disambiguation). This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these template messages) This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenge...

This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: The Last Belle – news · newspapers · books · scholar · JSTOR (March 2019) (Learn how and when to remove this template message) 2011 British filmThe Last BelleFilm posterDirected byNeil BoyleWritten byNeil Boyle and Jim MaguireProduced byNeil Boyle and Rebecca N...

Kembali kehalaman sebelumnya