{"id":23467,"date":"2023-04-19T08:31:25","date_gmt":"2023-04-19T08:31:25","guid":{"rendered":"https:\/\/www.booksofall.com\/tw\/?post_type=product&#038;p=23467"},"modified":"2023-04-19T08:31:25","modified_gmt":"2023-04-19T08:31:25","slug":"unix-lecture-notes-chapter-03","status":"publish","type":"product","link":"https:\/\/www.booksofall.com\/tw\/unix-lecture-notes-chapter-03\/","title":{"rendered":"UNIX Lecture Notes &#8211; Chapter 03"},"content":{"rendered":"<h2>3.1 Introduction<\/h2>\n<p>This chapter looks at <a href=\"https:\/\/en.wikipedia.org\/wiki\/Unix_filesystem\">UNIX \u001cfile systems<\/a> from the programmer&#8217;s perspective. The primary objective is to be able to write programs that use the part of the UNIX <a href=\"https:\/\/aws.amazon.com\/what-is\/api\/\">API<\/a> concerning the fi\u001cle system and its components. Of necessity, we will begin with an overview of what the \u001cle system is, and to a limited extent, how it is implemented. Although it is not necessary to understand how it is implemented to write programs that use it, a basic understanding of the typical implementation can help in understanding performance considerations and limitations.<\/p>\n<h2>3.2 File System Abstraction<\/h2>\n<p>A <a href=\"https:\/\/www.easeus.com\/diskmanager\/file-system.html\">\u001cfile system<\/a> is an abstraction that supports the creation, deletion, and modification of files, and organization of files into directories. It also supports control of access to \u001cfiles and directories and manages the disk space accorded to it. We tend to use the phrase fi\u0010\u001cle system\u0011 to refer to a hierarchical, tree-like structure whose internal nodes are directories and whose external nodes are non-directory-\u001cfiles (or perhaps empty directories), but a \u001cfile system is actually the \u001dat structure sitting on a linear storage device such as a disk partition. The layout of <a href=\"https:\/\/www.kernel.org\/\">Linux<\/a>, for example, is shown in Figure 3.1. This \u001dat structure is completely hidden from the user, but not entirely from the programmer. The user sees this as a hierarchically organized collection of \u001cfiles and directories, which is more properly called the directory hierarchy or file hierarchy.<\/p>\n<h2>3.3 File System Mounting<\/h2>\n<p>Multiple storage devices are usually attached to a modern computer. Some operating systems treat the \u001cfile systems on these devices as independent entities. In Microsoft&#8217;s DOS, and systems derived from it, for example, each separate disk partition has a drive letter, and the \u001cfile hierarchy on each separate drive or partition is separate from all others attached to the computer. In e\u001bffect, DOS has multiple trees whose roots are drive letters. For example, a typical <a href=\"https:\/\/en.wikipedia.org\/wiki\/Microsoft_Windows\">Windows<\/a> machine may have a directory E:\\users on the &#8220;E:&#8221; drive and a directory &#8220;C:\\Temp&#8221; on the &#8220;C:&#8221; <a href=\"https:\/\/en.wikipedia.org\/wiki\/Hard_disk_drive\">drive<\/a> but these directories are in two separate trees, not a single tree.<\/p>\n<p>In UNIX there is a single \u001cfile hierarchy. It is a tree if you think of the leaf nodes as \u001cfilenames, but it is not a tree if you think of the leaf nodes as actual \u001cfiles, since a single \u001cfile can have more than one name, existing as a directory entry in multiple directories, making the topology a directed acyclic graph1. We will take the liberty of referring to it as a tree, knowing that this is inaccurate.<\/p>\n<p>In UNIX, every accessible \u001cfile is in this single fi\u001cle hierarchy, no matter how many disks are attached. There is no such thing as the &#8220;C&#8221; drive&#8221; or &#8220;E&#8221; drive&#8221; in UNIX. This is because of the concept of mounting, which will be described in more detail later. In short, in UNIX, a fi\u001cle system may be mounted onto the single \u001cfile hierarchy by attaching that fi\u001cle system&#8217;s root to some directory in the hierarchy. It is like grafting a branch onto a tree. By mounting a fi\u001cle system onto the fi\u001cle hierarchy, the fi\u001cle system becomes a subtree of the hierarchy, making it possible to navigate into the \u001cfile system from the rest of the fi\u001cle hierarchy. The mount command without arguments displays a list showing all of the file systems currently mounted on the fi\u001cle hierarchy. As an example, the output of the mount command could be:<\/p>\n<p>\/dev\/mapper\/root.vg-root.lv on \/ type ext3 (rw)<br \/>\nproc on \/proc type proc (rw)<br \/>\nsysfs on \/sys type sysfs (rw)<br \/>\ndevpts on \/dev\/pts type devpts (rw,gid=5,mode=620)<br \/>\ntmpfs on \/dev\/shm type tmpfs (rw,rootcontext=&#8221;system_u:object_r:tmpfs_t:s0&#8243;)<br \/>\n\/dev\/sda1 on \/boot type ext3 (rw)<br \/>\nnone on \/proc\/sys\/fs\/binfmt_misc type binfmt_misc (rw)<\/p>\n<p>Each line is of the form,<\/p>\n<p><em>\u001cfile_system_name on place_where_it_is_mounted type \u001cfile_system_type other_options<\/em><\/p>\n<p>The sixth line states that there is a fi\u001cle system named \/dev\/sda1 of type ext3 that is mounted on the directory \/boot. You may wonder about the meaning of the line<\/p>\n<p>proc on \/proc type proc (rw)<\/p>\n<p>In a subsequent chapter we will explore the \/proc fi\u001cle system, which is not a fi\u001cle system that manages disk space, but an interface to the kernel&#8217;s memory. Further interpretation of this output will be delayed until after a discussion of \u001cfile systems and mounting in greater depth. At this point, the signi\u001cficance of mounting is that di\u001bfferent fi\u001cle systems can be, and usually are, part of a single conceptual \u001cfile hierarchy, making it possible to partition a disk into separate fi\u001cle systems that all become part of a single fi\u001cle hierarchy.<\/p>\n","protected":false},"excerpt":{"rendered":"<p><iframe style=\"width: 100%; height: 750px; border: none;\" src=\"https:\/\/online.visual-paradigm.com\/share\/book\/unix-lecture-notes-chapter-03-1bs0xfq4k7?p=1\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n","protected":false},"featured_media":23474,"template":"","meta":{"_yoast_wpseo_title":"","_yoast_wpseo_metadesc":"UNIX file systems are the foundation of organizing and managing data in UNIX-based operating systems. It is time to learn more about it in the notes here."},"product_brand":[],"product_cat":[376],"product_tag":[],"class_list":{"0":"post-23467","1":"product","2":"type-product","3":"status-publish","4":"has-post-thumbnail","6":"product_cat-unix-lecture-notes","8":"first","9":"instock","10":"shipping-taxable","11":"product-type-simple"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>UNIX Lecture Notes - Chapter 03 - BooksOfAll Traditional Chinese<\/title>\n<meta name=\"description\" content=\"UNIX file systems are the foundation of organizing and managing data in UNIX-based operating systems. It is time to learn more about it in the notes here.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.booksofall.com\/tw\/unix-lecture-notes-chapter-03\/\" \/>\n<meta property=\"og:locale\" content=\"zh_TW\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"UNIX Lecture Notes - Chapter 03 - BooksOfAll Traditional Chinese\" \/>\n<meta property=\"og:description\" content=\"UNIX file systems are the foundation of organizing and managing data in UNIX-based operating systems. It is time to learn more about it in the notes here.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.booksofall.com\/tw\/unix-lecture-notes-chapter-03\/\" \/>\n<meta property=\"og:site_name\" content=\"BooksOfAll Traditional Chinese\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.booksofall.com\/tw\/wp-content\/uploads\/sites\/3\/2023\/04\/UNIX-Lecture-Notes-cover-UNIX-Lecture-Notes-Chapter_03.jpg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/www.booksofall.com\/tw\/wp-content\/uploads\/sites\/3\/2023\/04\/UNIX-Lecture-Notes-cover-UNIX-Lecture-Notes-Chapter_03.jpg\" \/>\n<meta name=\"twitter:label1\" content=\"\u9810\u4f30\u95b1\u8b80\u6642\u9593\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 \u5206\u9418\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.booksofall.com\/tw\/unix-lecture-notes-chapter-03\/\",\"url\":\"https:\/\/www.booksofall.com\/tw\/unix-lecture-notes-chapter-03\/\",\"name\":\"UNIX Lecture Notes - Chapter 03 - BooksOfAll Traditional Chinese\",\"isPartOf\":{\"@id\":\"https:\/\/www.booksofall.com\/tw\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.booksofall.com\/tw\/unix-lecture-notes-chapter-03\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.booksofall.com\/tw\/unix-lecture-notes-chapter-03\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.booksofall.com\/tw\/wp-content\/uploads\/sites\/3\/2023\/04\/UNIX-Lecture-Notes-cover-UNIX-Lecture-Notes-Chapter_03.jpg\",\"datePublished\":\"2023-04-19T08:31:25+00:00\",\"description\":\"UNIX file systems are the foundation of organizing and managing data in UNIX-based operating systems. It is time to learn more about it in the notes here.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.booksofall.com\/tw\/unix-lecture-notes-chapter-03\/#breadcrumb\"},\"inLanguage\":\"zh-TW\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.booksofall.com\/tw\/unix-lecture-notes-chapter-03\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-TW\",\"@id\":\"https:\/\/www.booksofall.com\/tw\/unix-lecture-notes-chapter-03\/#primaryimage\",\"url\":\"https:\/\/www.booksofall.com\/tw\/wp-content\/uploads\/sites\/3\/2023\/04\/UNIX-Lecture-Notes-cover-UNIX-Lecture-Notes-Chapter_03.jpg\",\"contentUrl\":\"https:\/\/www.booksofall.com\/tw\/wp-content\/uploads\/sites\/3\/2023\/04\/UNIX-Lecture-Notes-cover-UNIX-Lecture-Notes-Chapter_03.jpg\",\"width\":\"827\",\"height\":\"1169\",\"caption\":\"UNIX Lecture Notes - Chapter 03\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.booksofall.com\/tw\/unix-lecture-notes-chapter-03\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.booksofall.com\/tw\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Categories\",\"item\":\"https:\/\/www.booksofall.com\/tw\/categories\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"UNIX Lecture Notes &#8211; Chapter 03\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.booksofall.com\/tw\/#website\",\"url\":\"https:\/\/www.booksofall.com\/tw\/\",\"name\":\"BooksOfAll Traditional Chinese\",\"description\":\"Biggest IT eBooks library and learning resources - Free eBooks for programming, computing, artificial intelligence and more.\",\"publisher\":{\"@id\":\"https:\/\/www.booksofall.com\/tw\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.booksofall.com\/tw\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-TW\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.booksofall.com\/tw\/#organization\",\"name\":\"BooksOfAll Traditional Chinese\",\"url\":\"https:\/\/www.booksofall.com\/tw\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-TW\",\"@id\":\"https:\/\/www.booksofall.com\/tw\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.booksofall.com\/tw\/wp-content\/uploads\/sites\/3\/2022\/06\/booksofall-logo-2.png\",\"contentUrl\":\"https:\/\/www.booksofall.com\/tw\/wp-content\/uploads\/sites\/3\/2022\/06\/booksofall-logo-2.png\",\"width\":166,\"height\":30,\"caption\":\"BooksOfAll Traditional Chinese\"},\"image\":{\"@id\":\"https:\/\/www.booksofall.com\/tw\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"UNIX Lecture Notes - Chapter 03 - BooksOfAll Traditional Chinese","description":"UNIX file systems are the foundation of organizing and managing data in UNIX-based operating systems. It is time to learn more about it in the notes here.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.booksofall.com\/tw\/unix-lecture-notes-chapter-03\/","og_locale":"zh_TW","og_type":"article","og_title":"UNIX Lecture Notes - Chapter 03 - BooksOfAll Traditional Chinese","og_description":"UNIX file systems are the foundation of organizing and managing data in UNIX-based operating systems. It is time to learn more about it in the notes here.","og_url":"https:\/\/www.booksofall.com\/tw\/unix-lecture-notes-chapter-03\/","og_site_name":"BooksOfAll Traditional Chinese","og_image":[{"url":"https:\/\/www.booksofall.com\/tw\/wp-content\/uploads\/sites\/3\/2023\/04\/UNIX-Lecture-Notes-cover-UNIX-Lecture-Notes-Chapter_03.jpg","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_image":"https:\/\/www.booksofall.com\/tw\/wp-content\/uploads\/sites\/3\/2023\/04\/UNIX-Lecture-Notes-cover-UNIX-Lecture-Notes-Chapter_03.jpg","twitter_misc":{"\u9810\u4f30\u95b1\u8b80\u6642\u9593":"4 \u5206\u9418"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.booksofall.com\/tw\/unix-lecture-notes-chapter-03\/","url":"https:\/\/www.booksofall.com\/tw\/unix-lecture-notes-chapter-03\/","name":"UNIX Lecture Notes - Chapter 03 - BooksOfAll Traditional Chinese","isPartOf":{"@id":"https:\/\/www.booksofall.com\/tw\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.booksofall.com\/tw\/unix-lecture-notes-chapter-03\/#primaryimage"},"image":{"@id":"https:\/\/www.booksofall.com\/tw\/unix-lecture-notes-chapter-03\/#primaryimage"},"thumbnailUrl":"https:\/\/www.booksofall.com\/tw\/wp-content\/uploads\/sites\/3\/2023\/04\/UNIX-Lecture-Notes-cover-UNIX-Lecture-Notes-Chapter_03.jpg","datePublished":"2023-04-19T08:31:25+00:00","description":"UNIX file systems are the foundation of organizing and managing data in UNIX-based operating systems. It is time to learn more about it in the notes here.","breadcrumb":{"@id":"https:\/\/www.booksofall.com\/tw\/unix-lecture-notes-chapter-03\/#breadcrumb"},"inLanguage":"zh-TW","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.booksofall.com\/tw\/unix-lecture-notes-chapter-03\/"]}]},{"@type":"ImageObject","inLanguage":"zh-TW","@id":"https:\/\/www.booksofall.com\/tw\/unix-lecture-notes-chapter-03\/#primaryimage","url":"https:\/\/www.booksofall.com\/tw\/wp-content\/uploads\/sites\/3\/2023\/04\/UNIX-Lecture-Notes-cover-UNIX-Lecture-Notes-Chapter_03.jpg","contentUrl":"https:\/\/www.booksofall.com\/tw\/wp-content\/uploads\/sites\/3\/2023\/04\/UNIX-Lecture-Notes-cover-UNIX-Lecture-Notes-Chapter_03.jpg","width":"827","height":"1169","caption":"UNIX Lecture Notes - Chapter 03"},{"@type":"BreadcrumbList","@id":"https:\/\/www.booksofall.com\/tw\/unix-lecture-notes-chapter-03\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.booksofall.com\/tw\/"},{"@type":"ListItem","position":2,"name":"Categories","item":"https:\/\/www.booksofall.com\/tw\/categories\/"},{"@type":"ListItem","position":3,"name":"UNIX Lecture Notes &#8211; Chapter 03"}]},{"@type":"WebSite","@id":"https:\/\/www.booksofall.com\/tw\/#website","url":"https:\/\/www.booksofall.com\/tw\/","name":"BooksOfAll Traditional Chinese","description":"Biggest IT eBooks library and learning resources - Free eBooks for programming, computing, artificial intelligence and more.","publisher":{"@id":"https:\/\/www.booksofall.com\/tw\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.booksofall.com\/tw\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-TW"},{"@type":"Organization","@id":"https:\/\/www.booksofall.com\/tw\/#organization","name":"BooksOfAll Traditional Chinese","url":"https:\/\/www.booksofall.com\/tw\/","logo":{"@type":"ImageObject","inLanguage":"zh-TW","@id":"https:\/\/www.booksofall.com\/tw\/#\/schema\/logo\/image\/","url":"https:\/\/www.booksofall.com\/tw\/wp-content\/uploads\/sites\/3\/2022\/06\/booksofall-logo-2.png","contentUrl":"https:\/\/www.booksofall.com\/tw\/wp-content\/uploads\/sites\/3\/2022\/06\/booksofall-logo-2.png","width":166,"height":30,"caption":"BooksOfAll Traditional Chinese"},"image":{"@id":"https:\/\/www.booksofall.com\/tw\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.booksofall.com\/tw\/wp-json\/wp\/v2\/product\/23467","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.booksofall.com\/tw\/wp-json\/wp\/v2\/product"}],"about":[{"href":"https:\/\/www.booksofall.com\/tw\/wp-json\/wp\/v2\/types\/product"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.booksofall.com\/tw\/wp-json\/wp\/v2\/media\/23474"}],"wp:attachment":[{"href":"https:\/\/www.booksofall.com\/tw\/wp-json\/wp\/v2\/media?parent=23467"}],"wp:term":[{"taxonomy":"product_brand","embeddable":true,"href":"https:\/\/www.booksofall.com\/tw\/wp-json\/wp\/v2\/product_brand?post=23467"},{"taxonomy":"product_cat","embeddable":true,"href":"https:\/\/www.booksofall.com\/tw\/wp-json\/wp\/v2\/product_cat?post=23467"},{"taxonomy":"product_tag","embeddable":true,"href":"https:\/\/www.booksofall.com\/tw\/wp-json\/wp\/v2\/product_tag?post=23467"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}