I&C SCI 32 Chapter Notes - Chapter 6: Wrinkle, Root Directory, Drive Letter Assignment

71 views4 pages
ICS 32 Fall 2015
Notes and Examples: Paths and File Systems
What is a file system?
If you've ever used a personal computer — a desktop machine or a laptop, for example — there's a good chance that you've
interacted with a file system before, even if you've never heard the term before. A file system is software that manages how
information is stored on a storage device such as a hard drive or a USB stick. There are a number of different kinds of file systems in
use — sometimes more than one kind on the same operating system! — but they mostly share the same basic characteristics, while
differing mainly in the fine-grained details. So if you know about those shared characteristics, you'll quickly find yourself at home
using just about any file system on just about any operating system.
The basic abstraction in a file system is that of a file. A file is a container in which a sequence of bytes is stored. Each byte is
effectively a sequence of eight "digits" that are either 1 or 0; each of these is called bit. The bytes in each file are interpreted
differently depending on what kind of file it is, and it should be noted that this is largely a matter of what the program reading the
file expects that it should contain (e.g., text, an image, a song); the file system itself is mostly unconcerned with what's in each file,
except for the metadata associated with the file, which keeps track of things like who owns the file, who has access to the file, and
when the file was last modified. The file system manages the containers in which the bytes are stored, but cares little about the
bytes inside of each file, other than to make sure that a file's contents don't change unless you ask for them to be changed.
Paths
You've no doubt seen before that each file on a file system has a name, which we quite often call its filename; the filename is one
piece of metadata associated with each file. But there's more to identifying a file than its name. Because there are so many files
stored on a typical file system — as I was writing this, I asked Windows to count how many files are stored on my laptop and found
that the answer was about 700,000 — there needs to be some way to keep them all organized, so we can find files not only by their
names, but by some other sort of categorization. While operating systems are gradually adding progressively better search
capabilities, there is still an underlying reality that hasn't changed much in the last few decades: File systems are quite often a
hierarchy of directories, with each directory containing both files and other directories. So, if we want to uniquely identify a file on
our storage devices, we have to specify not only the file's name, but also where the file is stored in that hierarchy; without knowing
more about the location of the file, the file system won't easily be able to find it. The location of a file is identified uniquely using a
path.
Different operating systems use different conventions for paths, the most common two of which are these:
Windows stores each file on a drive (e.g., a hard drive or a USB storage device) identified by an uppercase letter. Quite commonly, a
Windows machine's "main" drive (the one where the operating system is stored) will be known as C (for historical reasons that
aren't all that interesting anymore), and others will have the letters D, E, and so on. On each drive is a root directory, which can
contain files and other directories; those directories can contain files and other directories; and so on. A path on Windows specifies
the drive letter, the directory within the root directory that contains the file, the directory within that directory that contains the file,
and so on. The drive letter is followed by a colon and the directories are separated by backslashes, leading to a path like the example
below:
D:\Examples\32\data\myfile.txt
Unix-based operating systems, which include Mac OS X and various flavors of Linux, use what are sometimes called POSIX-style
paths, which eschew the notion of a drive letter, and instead map certain directories to individual devices behind the scenes. As on
Windows, directories contain files and other directories, which contain files and other directories, and so on. Unlike of Windows, a
forward slash is used (instead of a backslash) to separate one directory from another. This leads to paths that look like the example
below:
/home/thornton/Examples/32/data/myfile.txt
The complexities of these rules aside, the important thing to realize is that there are slightly different rules on different operating
systems, though the ideas are similar on all of them: that directories form a recursive hierarchy (directories containing other
directories, which contain other directories) is fairly standard — even mobile operating systems like Android and iOS have this
notion — and the differences are mainly minor details. Still, if we want to write Python programs that work with file systems
correctly regardless of operating system, as you're doing in Project #1, you're best off using the right kinds of tools for the job, so
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows page 1 of the document.
Unlock all 4 pages and 3 million more documents.

Already have an account? Log in

Document Summary

If you"ve ever used a personal computer a desktop machine or a laptop, for example there"s a good chance that you"ve interacted with a file system before, even if you"ve never heard the term before. A file system is software that manages how information is stored on a storage device such as a hard drive or a usb stick. There are a number of different kinds of file systems in use sometimes more than one kind on the same operating system! But they mostly share the same basic characteristics, while differing mainly in the fine-grained details. So if you know about those shared characteristics, you"ll quickly find yourself at home using just about any file system on just about any operating system. The basic abstraction in a file system is that of a file. A file is a container in which a sequence of bytes is stored.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents