Changes by: antona
Update of /cvsroot/linux-ntfs/linux-ntfs/include
In directory usw-pr-cvs1:/tmp/cvs-serv6768/include
Added Files:
layout.h types.h
Log Message:
Forgot to cvs add ...
--- NEW FILE ---
/*
* $Id: layout.h,v 1.1 2001/04/11 11:50:24 antona Exp $
*
* layout.h - Ntfs on-disk layout structures. Part of the Linux-NTFS project.
*
* Copyright (c) 2000,2001 Anton Altaparmakov.
*
* This program/include file is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program/include file is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program (in the main directory of the Linux-NTFS
[...1891 lines suppressed...]
/* Irrelevant as feature unused. */
} __attribute__ ((__packed__)) PROPERTY_SET;
/*
* Attribute: Logged utility stream (0x100).
*
* Operations on this attribute are logged to the journal ($LogFile) like
* normal metadata changes.
*
* Used by the Encrypting File System (EFS). All encrypted files have this
* attribute with the name $EFS.
*/
typedef struct {
/* Can be anything the creator chooses. */
/* EFS uses it as follows: */
// FIXME: Type this info, verifying it along the way. (AIA)
} __attribute__ ((__packed__)) LOGGED_UTILITY_STREAM, EFS_ATTR;
#endif /* defined LAYOUT_H */
--- NEW FILE ---
/*
* $Id: types.h,v 1.1 2001/04/11 11:50:24 antona Exp $
*
* types.h - Misc type definitions not related to on-disk structuer. Part of
* the Linux-NTFS project.
*
* Copyright (c) 2000,2001 Anton Altaparmakov.
*
* This program/include file is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program/include file is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program (in the main directory of the Linux-NTFS
* distribution in the file COPYING); if not, write to the Free Software
* Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef NTFS_TYPES_H
#define NTFS_TYPES_H
#include <linux/bitops.h>
#include "list.h"
#include "layout.h"
#include "unistr.h"
typedef struct { /* In memory vcn to lcn mapping structure element. */
VCN vcn; /* vcn = starting virtual cluster number */
LCN lcn; /* lcn = starting logical cluster number */
__u64 length; /* run length in clusters */
} run_list_element;
typedef run_list_element *run_list;/*In memory vcn to lcn mapping array.*/
/* run_list notes:
* - The last vcn (in fact the last vcn + 1) is reached when length == 0.
* - When lcn == 0 this means that the count vcns starting at vcn are not
* physically allocated (i.e. this is a hole / data is sparse). */
/* FIXME: Should this be a linked list so it is easier/quicker to edit? (AIA) */
/*
* FIXME: Do we really want to return a pointer to the actual volume structure
* to the user to play with? It would be better to completely abstract the
* structure and provide functions for accessing the public members instead.
* In that case we would return a volume descriptor to the caller.
*
* DECISION: Return the actual structure. In the second release, once
* everything is working, we still have the option of abstracting the volume
* strcture data type.
*/
/*
* FIXME: For RAID stuff will need the fd and dev_name variables to be arrays
* or lists or something... Also will need to know the number of sectors (and
* sector size if not 512) of each device making up the RAID array. Obviously,
* will need RAID information as well like which RAID is used together with
* state information, etc. But that is the far future.
*/
/* The ntfs volume structure describing an open volume. */
typedef struct {
int fd; /* File descriptor associated with volume. */
char *dev_name; /* Name of the device/file the volume is in. */
char *vol_name; /* Name of the volume from the volume name
attribute. */
/* Version nos. and flags are from the volume information attribute. */
__u8 major_ver; /* Ntfs major version of volume. */
__u8 minor_ver; /* Ntfs minor version of volume. */
__u16 flags; /* Bit array of VOLUME_* flags. */
__s64 number_of_clusters;/* Volume size in clusters, hence also the
number of bits in lcn_bitmap. */
__u32 cluster_size; /* Byte size of a cluster. */
__u32 mft_record_size; /* Byte size of a mft record. */
__s64 mft_lcn; /* Logical cluster number of the data attribute
for FILE_$Mft. */
__s64 mftmirr_lcn; /* Logical cluster number of the data attribute
for FILE_$MftMirr. */
__u8 cluster_size_bits; /* Log(2) of the byte size of a cluster. */
__u8 mft_record_size_bits;/* Log(2) of the byte size of a mft record. */
__u8 *lcn_bitmap; /* Value of data attribute of FILE_$Bitmap. Each
bit represents a cluster on the volume, bit 0
representing lcn 0 and so on. A set bit means
that the cluster is in use and a zero bit
means the cluster is free. */
__u8 *mft_bitmap; /* Value of bitmap attribute of FILE_$Mft. Has
same interpretation as the lcn_bitmap above
but except that it keeps track of the usage
of the mft records rather than the lcns. */
run_list mft_runlist; /* Decompressed run list of the data attribute
of FILE_$Mft. */
__s64 number_of_mft_records; /* Number of records in the mft, equals
the number of bits in mft_bitmap. */
wchar_t *upcase; /* Upper case equivalents of all 65536
2-byte Unicode characters. Obtained
from FILE_$UpCase. */
__u32 upcase_len; /* Length in Unicode characters of the
upcase table. */
__u8 mft_records_per_cluster; /* The number of mft records that fit
into one cluster or 0 if clusters
are smaller than mft records. */
__u8 clusters_per_mft_record; /* The size of a mft record in clusters
or 0 if a mft record is smaller than
a cluster. */
struct list_head open_files; /* Linked list of ntfs_file struct
pointers, keeping track of all files
which have been loaded into memory
and are open. */
int nr_open_files; /* Number of open files. */
struct list_head closed_files; /* Linked list of ntfs_file struct
pointers, keeping track of all cached
files which are not open any more. */ int nr_closed_files; /* Number of closed files. */
int max_files; /* Maximum number of nr_open_files + nr_ closed_files. */
struct list_head mft_entries; /* Linked list of all loaded mft records
(disk inodes) in order of ascending
mft record number (disk inode number,
disregarding the sequence number).
Note, the list members are mft_entry
struct pointers. */
int nr_mft_entries; /* Number of mft_entries. */
struct list_head dirty_mft_entries; /* Linked list of all loaded mft
records which are dirty. */
int nr_dirty_mft_entries; /* Number of dirty mft_entries. */
struct list_head v_list; /* Anchor for list of all mounted
volumes. */
} ntfs_volume;
/*
* Implementation of files (aka mft records, aka inodes) in memory.
* ================================================================
*
* NOTE: I have completely ignored the existence of things like directories
* and directory references for the moment! These will just be added later on.
* The directories themselves are of course covered by being base mft records
* and hence follow the same semantics like every other mft record.
*
* Volume struct (typedef is in volume.h).
* ---------------------------------------
*
* open_files: Linked list of ntfs_file struct pointers, keeping track
* of all files which have been loaded into memory and are
* open.
*
* nr_open_files: Number of open files.
*
* closed_files: Linked list of ntfs_file struct pointers, keeping track
* of all cached files which are not open any more.
*
* nr_closed_files: Number of closed files.
*
* max_files: Maximum number of nr_open_files + nr_closed_files.
*
* As files are opened/closed, records move from one list to the other. When a
* file is opened it moves to the front of files_open as we expect to do I/O on
* it very soon so want quick access to it. When a file is closed, it moves to
* the end of files_closed as we don't expect it to be opened any time soon.
*
* Note: We probably want to replace these with hash tables once the library
* matures and users start complaining about the speed of it... but this will
* do for now.
*
* mft_entries: Linked list of all loaded mft records (disk inodes) in
* order of ascending mft record number (disk inode number,
* i.e. disregarding the sequence number). Note, the list
* members are not the actual MFT_RECORDS, but in memory
* mft_entry structs.
*
* nr_mft_entries: Number of mft_entries.
*
* dirty_mft_entries: Linked list of all loaded mft records which are dirty.
* Used by the disk writer thread. When a mft_entry is
* marked dirty, the entry is added to the end of this
* list. When it is flushed to disk, it is marked clean
* and removed from this list.
*
* nr_dirty_mft_entries: Number of dirty mft_entries.
*
*
* The mft_entry struct.
* ---------------------
*
* Each loaded mft record is represented by the mft_entry structure which
* contains these members:
*
* m_rec: Pointer to the actual MFT_RECORD. (Only valid if mapped flag is
* set.)
*
* m_flags: Atomic flags describing the mft entry / record:
*
* mapped: Is the MFT_RECORD actually in memory? (Is mrec valid?)
*
* dirty: Does the record need to be written to disk? (If not, it is safe
* to discard m_rec, but only if m_count is zero and we are
* holding m_rec_lock for writing.)
*
* error: When reading the entry from disk it was detected that it is
* corrupt. For example, it could be that a multi sector transfer
* error was detected.
*
* m_ref: Mft reference of the mft record described by this entry. (This
* includes the sequence number for consistency checking purposes.)
*
* m_count: Usage count. When zero this record is not referenced by
* any files and can be thrown away safely (writing it to disk
* first if dirty flag is set).
*
* m_list: Anchor for the mft_entries linked list.
*
* m_dirty_list: Anchor for the dirty_mft_enties linked list. (Only valid if
* the dirty flag is set.)
*
* m_vol: Volume this entry and its mft record belong to.
*
* m_file: Ntfs file this mft entry belongs to.
*
* Future:
*
* - Reference all loaded non-resident attributes somehow. Need this for the
* search context work and we do need to keep them so we can have two
* readers at the same time. So we need to somehow specify which attribute
* we are talking about, possibly which mft record it is in (+ position
* in attribute list?) and a pointer to the attribute value itself.
*
* The ntfs_file struct (file = base mft record).
* ----------------------------------------------
*
* Each loaded file is described by an ntfs_file struct, which contains these
* members:
*
* m_refs: The mft references of the file (i.e. the on disk inode number).
* This is an array of MFT_REFs. The first reference is the
* base mft record and if any others exist they are the associated
* loaded extension mft records. Used for attribute list purposes.
*
* m_entries: The loaded mft records for the file. This is an array of
* pointers to mft_entries, corresponding to the m_refs. This
* is not strictly necessary but results in a big speed up as we
* don't need to search the vol->mft_entries list every time...
*
* When an entry is referenced in the above lists the usage count for the
* corresponding entry is increased by one.
*
* nr_mft_refs: Number of records in the m_* arrays. If > 1, we
* know there must be an attribute list attribute (but if 1, we
* cannot assume there isn't one). This is of course the same as
* a possible nr_m_entries, but refs is shorter to write. (-;
*
* f_count: Usage count. When zero this file is not open by anyone
* and can be thrown away safely. No need to concern oneself with
* dirty state as this is done on a mft_entry level, i.e. one level
* below the idea of files.
*
* f_list: Anchor into vol->open/closed_files list. If f_count is > 0,
* into open_files list, otherwise into closed_files list.
*
* Notes:
*
* - No field to know whether we have the file open for writing as this is
* provided on a mft_entry level, i.e. below the files/directories level.
* This might turn out to be a mistake and is subject to change in the
* future if the current approach turns out not to work...
*/
struct _ntfs_file;
typedef struct {
MFT_RECORD *m_rec;
unsigned int m_flags;
MFT_REF m_ref;
unsigned int m_count;
struct _ntfs_file *m_file;
struct list_head m_list;
struct list_head m_dirty_list;
struct _ntfs_volume *m_vol;
} mft_entry;
struct {
MFT_REF *m_refs;
mft_entry *m_entries;
int nr_m_refs;
int f_count;
struct list_head f_list;
struct _ntfs_volume *f_vol;
} _ntfs_file;
typedef struct _ntfs_file ntfs_file;
#endif /* defined NTFS_TYPES_H */
|