Loading...
Searching...
No Matches
cat_inode.hpp
Go to the documentation of this file.
/*********************************************************************/
// dar - disk archive - a backup/restoration program
// Copyright (C) 2002-2026 Denis Corbin
//
// This program 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 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; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// to contact the author, see the AUTHOR file
/*********************************************************************/
#ifndef CAT_INODE_HPP
#define CAT_INODE_HPP
#include "../my_config.h"
extern "C"
{
} // end extern "C"
#include "infinint.hpp"
#include "ea.hpp"
#include "integers.hpp"
#include "mask.hpp"
#include "user_interaction.hpp"
#include "filesystem_specific_attribute.hpp"
#include "datetime.hpp"
#include "cat_nomme.hpp"
#include "archive_aux.hpp"
namespace libdar
{
class cat_inode : public cat_nomme
{
public:
cat_inode(const infinint & xuid,
const infinint & xgid,
U_16 xperm,
const datetime & last_access,
const datetime & last_modif,
const datetime & last_change,
const std::string & xname,
const infinint & device);
cat_inode(const std::shared_ptr<user_interaction> & dialog,
const smart_pointer<pile_descriptor> & pdesc,
const archive_version & reading_ver,
saved_status saved,
bool small);
cat_inode(const cat_inode & ref);
cat_inode(cat_inode && ref) noexcept: cat_nomme(std::move(ref)) { nullifyptr(); move_from(std::move(ref)); };
cat_inode & operator = (const cat_inode & ref);
cat_inode & operator = (cat_inode && ref) { cat_nomme::operator = (std::move(ref)); move_from(std::move(ref)); return *this; };
~cat_inode() noexcept(false);
const infinint & get_uid() const { return uid; };
const infinint & get_gid() const { return gid; };
U_16 get_perm() const { return perm; };
datetime get_last_access() const { return last_acc; };
datetime get_last_modif() const { return last_mod; };
void set_last_access(const datetime & x_time) { last_acc = x_time; };
void set_last_modif(const datetime & x_time) { last_mod = x_time; };
infinint get_device() const { if(fs_dev == nullptr) throw SRC_BUG; return *fs_dev; };
bool same_as(const cat_inode & ref) const;
bool is_more_recent_than(const cat_inode & ref, const infinint & hourshift) const;
// used for RESTORATION
virtual bool has_changed_since(const cat_inode & ref, const infinint & hourshift, comparison_fields what_to_check) const;
// signature() left as an abstract method
// clone is abstract too
// used for INCREMENTAL BACKUP
void compare(const cat_inode &other,
const mask & ea_mask,
comparison_fields what_to_check,
const infinint & hourshift,
bool symlink_date,
const fsa_scope & scope,
bool isolated_mode,
bool seq_read_mode
) const;
// throw Erange exception if a difference has been detected
// this is not a symetrical comparison, but all what is present
// in the current object is compared against the argument
// which may contain supplementary informations
// used for DIFFERENCE
// EXTENDED ATTRIBUTES Methods
//
// I : to know whether EA data is present or not for this object
void ea_set_saved_status(ea_saved_status status);
ea_saved_status ea_get_saved_status() const { return ea_saved; };
// II : to associate EA list to an cat_inode object (mainly for backup operation) #EA_FULL only#
void ea_attach(ea_attributs *ref);
const ea_attributs *get_ea() const; // #<-- EA_FULL *and* EA_REMOVED# for this call only
void ea_detach() const; //discards any future call to get_ea() !
infinint ea_get_size() const; //returns the size of EA (still valid if ea have been detached) mainly used to define CRC width
// III : to record where is dump the EA in the archive #EA_FULL only#
void ea_set_offset(const infinint & pos);
bool ea_get_offset(infinint & pos) const;
void ea_set_crc(const crc & val);
void ea_get_crc(const crc * & ptr) const;
bool ea_get_crc_size(infinint & val) const;
// IV : to know/record if EA and FSA have been modified # any EA status# and FSA status #
datetime get_last_change() const { return last_cha; };
void set_last_change(const datetime & x_time) { last_cha = x_time; };
bool has_last_change() const { return !last_cha.is_null(); };
// old format did provide last_change only when EA were present, since archive
// format 8, this field is always present even in absence of EA. Thus it is
// still necessary to check if the cat_inode has a last_change() before
// using get_last_change() (depends on the version of the archive read).
// FILESYSTEM SPECIFIC ATTRIBUTES Methods
//
// I : which FSA are present
void fsa_set_saved_status(fsa_saved_status status);
fsa_saved_status fsa_get_saved_status() const { return fsa_saved; };
fsa_scope fsa_get_families() const { if(fsa_families == nullptr) throw SRC_BUG; return infinint_to_fsa_scope(*fsa_families); };
// II : add or drop FSA list to the cat_inode
void fsa_attach(filesystem_specific_attribute_list *ref);
void fsa_partial_attach(const fsa_scope & val); // #<-- FSA_PARTIAL only
const filesystem_specific_attribute_list *get_fsa() const; // #<-- FSA_FULL only
void fsa_detach() const; // discard any future call to get_fsa() !
infinint fsa_get_size() const; // returns the size of FSA (still valid if fsal has been detached) / mainly used to define CRC size
// III : to record where FSA are dumped in the archive (only if fsa_status not empty !)
void fsa_set_offset(const infinint & pos);
bool fsa_get_offset(infinint & pos) const;
void fsa_set_crc(const crc & val);
void fsa_get_crc(const crc * & ptr) const;
bool fsa_get_crc_size(infinint & val) const;
protected:
virtual void sub_compare(const cat_inode & other,
bool isolated_mode,
bool seq_read_mode) const {};
bool get_small_read() const { return small_read; };
// inherited from cat_entree
virtual void inherited_dump(const pile_descriptor & pdesc, bool small) const override;
private :
infinint uid;
infinint gid;
U_16 perm;
datetime last_acc;
datetime last_mod;
datetime last_cha;
ea_saved_status ea_saved;
fsa_saved_status fsa_saved;
bool small_read;
// the following is used only if ea_saved == full
infinint *ea_offset;
ea_attributs *ea;
infinint *ea_size;
// the following is used if ea_saved == full or ea_saved == partial or
crc *ea_crc;
infinint *fsa_families;
infinint *fsa_offset;
filesystem_specific_attribute_list *fsal;
infinint *fsa_size;
crc *fsa_crc;
//
infinint *fs_dev;
archive_version edit;
void nullifyptr() noexcept;
void destroy() noexcept;
void copy_from(const cat_inode & ref);
void move_from(cat_inode && ref) noexcept;
static const ea_attributs empty_ea;
};
} // end of namespace
#endif
archive_aux.hpp
set of datastructures used to interact with a catalogue object
cat_nomme.hpp
base class of all objects contained in a catalogue and that can be named
libdar::archive_version
class archive_version manages the version of the archive format
Definition archive_version.hpp:47
libdar::cat_inode
the root class for all cat_inode
Definition cat_inode.hpp:53
libdar::cat_inode::ea_size
infinint * ea_size
storage size required by EA
Definition cat_inode.hpp:195
libdar::cat_inode::last_mod
datetime last_mod
last modification time (mtime)
Definition cat_inode.hpp:185
libdar::cat_inode::last_acc
datetime last_acc
last access time (atime)
Definition cat_inode.hpp:184
libdar::cat_inode::perm
U_16 perm
inode's permission
Definition cat_inode.hpp:183
libdar::cat_inode::ea_get_crc_size
bool ea_get_crc_size(infinint &val) const
returns true if crc is know and puts its width in argument
libdar::cat_inode::edit
archive_version edit
need to know EA and FSA format used in archive file
Definition cat_inode.hpp:206
libdar::cat_inode::inherited_dump
virtual void inherited_dump(const pile_descriptor &pdesc, bool small) const override
true if object has been created by sequential reading of an archive
libdar::cat_inode::ea
ea_attributs * ea
Extended Attributes read or to be written down.
Definition cat_inode.hpp:194
libdar::cat_inode::uid
infinint uid
inode owner's user ID
Definition cat_inode.hpp:181
libdar::cat_inode::fsa_size
infinint * fsa_size
storage size required for FSA
Definition cat_inode.hpp:202
libdar::cat_inode::cat_inode
cat_inode(const infinint &xuid, const infinint &xgid, U_16 xperm, const datetime &last_access, const datetime &last_modif, const datetime &last_change, const std::string &xname, const infinint &device)
flag used to only consider certain fields when comparing/restoring inodes
libdar::cat_inode::fsa_families
infinint * fsa_families
list of FSA families present for that inode (set to nullptr in fsa_none mode)
Definition cat_inode.hpp:199
libdar::cat_inode::fsa_crc
crc * fsa_crc
CRC computed on FSA.
Definition cat_inode.hpp:203
libdar::cat_inode::small_read
bool small_read
whether we the object has been built with sequential-reading
Definition cat_inode.hpp:190
libdar::cat_inode::get_ea
const ea_attributs * get_ea() const
the returned value is the address of an existing file of the cat_inode object and shall not be delete...
libdar::cat_inode::ea_get_crc
void ea_get_crc(const crc *&ptr) const
the argument is set to point to an allocated crc object owned by this "cat_inode" object,...
libdar::cat_inode::fs_dev
infinint * fs_dev
filesystem ID on which resides the inode (only used when read from filesystem)
Definition cat_inode.hpp:205
libdar::cat_inode::ea_crc
crc * ea_crc
CRC computed on EA.
Definition cat_inode.hpp:197
libdar::cat_inode::ea_offset
infinint * ea_offset
offset in archive where to find EA
Definition cat_inode.hpp:193
libdar::cat_inode::ea_saved
ea_saved_status ea_saved
inode Extended Attribute status
Definition cat_inode.hpp:187
libdar::cat_inode::last_cha
datetime last_cha
last inode meta data change (ctime)
Definition cat_inode.hpp:186
libdar::cat_inode::fsa_saved
fsa_saved_status fsa_saved
inode Filesystem Specific Attribute status
Definition cat_inode.hpp:188
libdar::cat_inode::fsa_offset
infinint * fsa_offset
offset in archive where to find FSA # always allocated (to be reviewed)
Definition cat_inode.hpp:200
libdar::cat_inode::fsal
filesystem_specific_attribute_list * fsal
Filesystem Specific Attributes read or to be written down # only allocated if fsa_saved if set to FUL...
Definition cat_inode.hpp:201
libdar::cat_inode::gid
infinint gid
inode owner's group ID
Definition cat_inode.hpp:182
libdar::cat_inode::compare
void compare(const cat_inode &other, const mask &ea_mask, comparison_fields what_to_check, const infinint &hourshift, bool symlink_date, const fsa_scope &scope, bool isolated_mode, bool seq_read_mode) const
libdar::cat_inode::fsa_get_families
fsa_scope fsa_get_families() const
gives the set of FSA family recorded for that inode
Definition cat_inode.hpp:152
libdar::crc
pure virtual class defining interface of a CRC object
Definition crc.hpp:47
libdar::datetime
stores time information
Definition datetime.hpp:59
libdar::datetime::is_null
bool is_null() const
return true if the datetime is exactly January 1st, 1970, 0 h 0 mn 0 s
Definition datetime.hpp:131
libdar::ea_attributs
the class ea_attributs manages the set of EA that can be associated to an inode
Definition ea.hpp:48
libdar::filesystem_specific_attribute_list
interface to fileystem for FSA
Definition filesystem_specific_attribute.hpp:138
libdar::infinint
the arbitrary large positive integer class
Definition real_infinint.hpp:62
libdar::mask
the generic class, parent of all masks
Definition mask.hpp:62
libdar::smart_pointer
smart pointer class to be used to automagically manage multiple time pointed to address
Definition smart_pointer.hpp:79
datetime.hpp
this file contains the definition of class datetime that stores unix times in a portable way
ea.hpp
contains a set of routines to manage EA values associated to a file
filesystem_specific_attribute.hpp
filesystem specific attributes
libdar::comparison_fields
comparison_fields
how to consider file change during comparison and incremental backup
Definition archive_aux.hpp:53
libdar::infinint_to_fsa_scope
fsa_scope infinint_to_fsa_scope(const infinint &ref)
convert an infinint to fsa_scape
libdar::fsa_scope
std::set< fsa_family > fsa_scope
set of fsa families
Definition fsa_family.hpp:70
libdar::fsa_saved_status
fsa_saved_status
FSA saved status for an entry.
Definition cat_status.hpp:73
libdar::saved_status
saved_status
data saved status for an entry
Definition cat_status.hpp:44
libdar::ea_saved_status
ea_saved_status
EA saved status for an entry.
Definition cat_status.hpp:55
libdar::saved_status::saved
@ saved
inode is saved in the archive
Definition cat_status.hpp:45
infinint.hpp
switch module to limitint (32 ou 64 bits integers) or infinint
integers.hpp
are defined here basic integer types that tend to be portable
mask.hpp
here lies a collection of mask classes
my_config.h
include macro defined by the configure script and some specific additional ones
libdar
libdar namespace encapsulate all libdar symbols
Definition archive.hpp:47
user_interaction.hpp
defines the interaction interface between libdar and users.