Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Enumerations | Functions
runlist.h File Reference
#include "types.h"
#include "layout.h"
#include "volume.h"

Go to the source code of this file.

Data Structures

struct  runlist_element
 
struct  runlist
 

Enumerations

enum  LCN_SPECIAL_VALUES {
  LCN_HOLE = -1, LCN_RL_NOT_MAPPED = -2, LCN_ENOENT = -3, LCN_ENOMEM = -4,
  LCN_EIO = -5
}
 

Functions

runlist_elementntfs_runlists_merge (runlist_element *drl, runlist_element *srl)
 
runlist_elementntfs_mapping_pairs_decompress (const ntfs_volume *vol, const ATTR_RECORD *attr, runlist_element *old_rl)
 
LCN ntfs_rl_vcn_to_lcn (const runlist_element *rl, const VCN vcn)
 

Enumeration Type Documentation

Enumerator:
LCN_HOLE 
LCN_RL_NOT_MAPPED 
LCN_ENOENT 
LCN_ENOMEM 
LCN_EIO 

Definition at line 65 of file runlist.h.

Function Documentation

runlist_element* ntfs_mapping_pairs_decompress ( const ntfs_volume vol,
const ATTR_RECORD *  attr,
runlist_element old_rl 
)

ntfs_mapping_pairs_decompress - convert mapping pairs array to runlist : ntfs volume on which the attribute resides : attribute record whose mapping pairs array to decompress : optional runlist in which to insert 's runlist

It is up to the caller to serialize access to the runlist .

Decompress the attribute 's mapping pairs array into a runlist. On success, return the decompressed runlist.

If is not NULL, decompressed runlist is inserted into the appropriate place in and the resultant, combined runlist is returned. The original is deallocated.

On error, return -errno. is left unmodified in that case.

The following error codes are defined: -ENOMEM - Not enough memory to allocate runlist array. -EIO - Corrupt runlist. -EINVAL - Invalid parameters were passed in. -ERANGE - The two runlists overlap.

FIXME: For now we take the conceptionally simplest approach of creating the new runlist disregarding the already existing one and then splicing the two into one, if that is possible (we check for overlap and discard the new runlist if overlap present before returning ERR_PTR(-ERANGE)).

Definition at line 749 of file runlist.c.

LCN ntfs_rl_vcn_to_lcn ( const runlist_element rl,
const VCN  vcn 
)

ntfs_rl_vcn_to_lcn - convert a vcn into a lcn given a runlist : runlist to use for conversion : vcn to convert

Convert the virtual cluster number of an attribute into a logical cluster number (lcn) of a device using the runlist to map vcns to their corresponding lcns.

It is up to the caller to serialize access to the runlist .

Since lcns must be >= 0, we use negative return codes with special meaning:

Return code Meaning / Description

LCN_HOLE Hole / not allocated on disk. LCN_RL_NOT_MAPPED This is part of the runlist which has not been inserted into the runlist yet. LCN_ENOENT There is no such vcn in the attribute.

Locking: - The caller must have locked the runlist (for reading or writing).

  • This function does not touch the lock, nor does it modify the runlist.

Definition at line 1004 of file runlist.c.

runlist_element* ntfs_runlists_merge ( runlist_element drl,
runlist_element srl 
)

ntfs_runlists_merge - merge two runlists into one : original runlist to be worked on : new runlist to be merged into

First we sanity check the two runlists and to make sure that they are sensible and can be merged. The runlist must be either after the runlist or completely within a hole (or unmapped region) in .

It is up to the caller to serialize access to the runlists and .

Merging of runlists is necessary in two cases:

  1. When attribute lists are used and a further extent is being mapped.
  2. When new clusters are allocated to fill a hole or extend a file.

There are four possible ways can be merged. It can:

  • be inserted at the beginning of a hole,
  • split the hole in two and be inserted between the two fragments,
  • be appended at the end of a hole, or it can
  • replace the whole hole. It can also be appended to the end of the runlist, which is just a variant of the insert case.

On success, return a pointer to the new, combined, runlist. Note, both runlists and are deallocated before returning so you cannot use the pointers for anything any more. (Strictly speaking the returned runlist may be the same as but this is irrelevant.)

On error, return -errno. Both runlists are left unmodified. The following error codes are defined: -ENOMEM - Not enough memory to allocate runlist array. -EINVAL - Invalid parameters were passed in. -ERANGE - The runlists overlap and cannot be merged.

Definition at line 531 of file runlist.c.