- [Scott] When we talk about file metadata,
we'll usually think first of things like EXIF data
and authorship data,
things we're accustomed to seeing in various software tools,
like photo editors and word processing software.
And as we've seen,
this kind of metadata is important to understand.
There's another kind of metadata we should be aware of
when working with files, though.
That's the metadata that's stored in the file system,
outside of an actual files data.
Before we explore this,
let's take a moment to refresh ourselves
about how files are stored on computers.
A file is made up of information encoded into binary bits.
These bits represent whatever the content of the file is,
whether it's text, an image, a video, or whatever.
The bits are organized into bytes,
and the bytes are stored on disk
in little areas called blocks on Unix and Linux type systems
and clusters on Windows.
Every file system, regardless of operating system,
uses these fundamental little buckets of data
to store files or groups of them called extends,
and they can be of different sizes
on different file systems,
but these blocks, or clusters, or extends
each have their own address.
When we save a file on disk,
its data takes up one or more little unit,
and the addresses of those storage units
are recorded in a data structure
that associates them with other information about the file.
Most importantly, this is where we associate a name,
permissions, and creation and modification times
with the data of a file.
Depending on the file system,
other metadata may be associated with files here,
including ACLs or access control lists
and extended attributes.
On Linux and Unix type file systems,
these records that contain file metadata
and point to disk blocks are called inodes.
On a Windows NTFS drive,
these records are kept as entries in a structure
called the MFT or master file table.
We'll explore both of these approaches
to storing filesystem metadata later in the course.
Other file systems may use other structures,
like a FAT or file allocation table
to record basic information
like the name and location of a file,
but often they don't support richer metadata
that modern file systems handle.
Support for certain characters and file names
and case sensitivity also vary across file systems.
While all file systems support basic metadata,
like name, size, and modification date
and while modern file systems have rich metadata support,
they don't all work in the same way.
This means that copying or moving a file
isn't quite as simple of an operation
as it might appear to be.
When a file is copied or moved,
the copy operation includes the metadata
from the file system or metadata store,
along with the actual bytes of the file.
The name, the modification dates, and so on
are translated into whatever values can be stored
in the destination file system.
Though platform-specific data
sometimes doesn't have a place to go
and it temporarily get separated from its file
or even lost entirely.
As we'll see throughout the course,
the loss of this metadata is often not a big problem
because the bytes of the data itself are preserved
when the file is moved or copied.
However, metadata loss or cross-platform handling
can have some odd effects unless you know what's going on.
And in some situations,
metadata is quite important,
and so we need to consider carefully any action
that might strip or otherwise separate it from its file.
Because filesystem metadata
is stored outside of the files it describes,
we can change many of these metadata aspects of files
without modifying the actual file data.
That's what we do whenever we change permission modes
or set ACLs.
Those changes are made in the file system,
not to the individual files themselves,
and as a consequence,
if we move or copy these files to a file system
that doesn't support permissions, or flags, or whatever,
that particular metadata can be lost.
This can have security implications, as we'll discuss later.
Okay, so it turns out the files
are a little bit more complicated
than they might seem at first,
but the important part to think about here
is that the files themselves, the bytes on the disk,
don't include all this other metadata information
that we, as humans, think about when we think about files.
They're separate even though they're presented as one thing.
The data structures, strategies,
and features of different file systems
are really interesting to learn about,
but that's not the focus of this course.
It's important to recognize
that there are differences, though,
as we'll see in the next videos.