Loading...
Searching...
No Matches
filesystem_restore.hpp
Go to the documentation of this file.
/*********************************************************************/
// dar - disk archive - a backup/restoration program
// Copyright (C) 2002-2025 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 FILESYSTEM_RESTORE_HPP
#define FILESYSTEM_RESTORE_HPP
#include "../my_config.h"
extern "C"
{
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#if HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
} // end extern "C"
#include <deque>
#include "crit_action.hpp"
#include "fsa_family.hpp"
#include "cat_all_entrees.hpp"
#include "filesystem_hard_link_read.hpp"
#include "filesystem_hard_link_write.hpp"
#include <set>
namespace libdar
{
class filesystem_restore : public filesystem_hard_link_write, public filesystem_hard_link_read
{
public:
filesystem_restore(const std::shared_ptr<user_interaction> & dialog,
const path & root,
bool x_warn_overwrite,
bool x_info_details,
const mask & x_ea_mask,
comparison_fields what_to_check,
bool x_warn_remove_no_match,
bool empty,
const crit_action *x_overwrite,
bool x_only_overwrite,
const fsa_scope & scope);
filesystem_restore(const filesystem_restore & ref) = delete;
filesystem_restore(filesystem_restore && ref) = delete;
filesystem_restore & operator = (const filesystem_restore & ref) = delete;
filesystem_restore & operator = (filesystem_restore && ref) = delete;
~filesystem_restore() { restore_stack_dir_ownership(); detruire(); };
void reset_write();
using action_done_for_data = enum
{
done_data_restored, //< data has been restored to filesystem
done_no_change_no_data, //< no change in filesystem because no data present in archive
done_no_change_policy, //< no change in filesystem because of overwiting policy decision
done_data_removed //< data (= whole inode) removed from filesystem
};
void write(const cat_entree *x,
action_done_for_data & data_restored,
bool & ea_restored,
bool & data_created,
bool & hard_link,
bool & fsa_restored);
void ignore_overwrite_restrictions_for_next_write() { ignore_over_restricts = true; };
private:
class stack_dir_t : public cat_directory
{
public:
stack_dir_t(const cat_directory & ref, bool restore) : cat_directory(ref) { restore_date = restore; };
bool get_restore_date() const { return restore_date; };
void set_restore_date(bool val) { restore_date = val; };
private:
bool restore_date;
};
path *fs_root;
bool info_details;
mask *ea_mask;
bool warn_overwrite;
comparison_fields what_to_check;
bool warn_remove_no_match;
std::deque<stack_dir_t> stack_dir;
path *current_dir;
bool empty;
bool ignore_over_restricts;
const crit_action *overwrite;
bool only_overwrite;
void detruire();
void restore_stack_dir_ownership();
user_interaction & get_ui() const { return filesystem_hard_link_read::get_ui(); };
std::shared_ptr<user_interaction> get_pointer() const { return filesystem_hard_link_read::get_pointer(); };
// subroutines of write()
void action_over_remove(const cat_inode *in_place,
const cat_detruit *to_be_added,
const std::string & spot,
over_action_data action);
void action_over_data(const cat_inode *in_place,
const cat_nomme *to_be_added,
const std::string & spot,
over_action_data action,
action_done_for_data & data_done);
bool action_over_ea(const cat_inode *in_place,
const cat_nomme *to_be_added,
const std::string & spot,
over_action_ea action);
bool action_over_fsa(const cat_inode *in_place,
const cat_nomme *to_be_added,
const std::string & spot,
over_action_ea action);
};
} // end of namespace
#endif
cat_all_entrees.hpp
include file gathering all entree found in a catalogue
libdar::cat_detruit
the deleted file entry
Definition cat_detruit.hpp:49
libdar::cat_directory
the cat_directory inode class
Definition cat_directory.hpp:52
libdar::cat_entree
the root class from all other inherite for any entry in the catalogue
Definition cat_entree.hpp:60
libdar::cat_inode
the root class for all cat_inode
Definition cat_inode.hpp:53
libdar::cat_nomme
the base class for all entry that have a name
Definition cat_nomme.hpp:45
libdar::crit_action
the global action for overwriting
Definition crit_action.hpp:81
libdar::filesystem_hard_link_read
keep trace of hard links when reading the filesystem
Definition filesystem_hard_link_read.hpp:58
libdar::filesystem_hard_link_write
keep trace of already written inodes to restore hard links
Definition filesystem_hard_link_write.hpp:58
libdar::filesystem_restore
receive the flow of inode from the restoration filtering routing and promotes these to real filesyste...
Definition filesystem_restore.hpp:59
libdar::filesystem_restore::ignore_overwrite_restrictions_for_next_write
void ignore_overwrite_restrictions_for_next_write()
ask for no warning or user interaction for the next write operation
Definition filesystem_restore.hpp:123
libdar::filesystem_restore::reset_write
void reset_write()
reset the writing process for the current object
libdar::filesystem_restore::action_over_data
void action_over_data(const cat_inode *in_place, const cat_nomme *to_be_added, const std::string &spot, over_action_data action, action_done_for_data &data_done)
perform action for data due to the overwriting policy when the "to be added" entry is not a cat_detru...
libdar::filesystem_restore::action_over_ea
bool action_over_ea(const cat_inode *in_place, const cat_nomme *to_be_added, const std::string &spot, over_action_ea action)
perform action for EA due to overwriting policy
libdar::filesystem_restore::filesystem_restore
filesystem_restore(const std::shared_ptr< user_interaction > &dialog, const path &root, bool x_warn_overwrite, bool x_info_details, const mask &x_ea_mask, comparison_fields what_to_check, bool x_warn_remove_no_match, bool empty, const crit_action *x_overwrite, bool x_only_overwrite, const fsa_scope &scope)
constructor
libdar::filesystem_restore::action_over_remove
void action_over_remove(const cat_inode *in_place, const cat_detruit *to_be_added, const std::string &spot, over_action_data action)
perform action due to the overwriting policy when the "to be added" entry is a detruit object
libdar::filesystem_restore::filesystem_restore
filesystem_restore(filesystem_restore &&ref)=delete
move constructor is forbidden
libdar::filesystem_restore::operator=
filesystem_restore & operator=(const filesystem_restore &ref)=delete
assignment operator is forbidden
libdar::filesystem_restore::~filesystem_restore
~filesystem_restore()
destructor
Definition filesystem_restore.hpp:87
libdar::filesystem_restore::write
void write(const cat_entree *x, action_done_for_data &data_restored, bool &ea_restored, bool &data_created, bool &hard_link, bool &fsa_restored)
restore a libdar object to a filesystem entry both data and EA
libdar::filesystem_restore::action_over_fsa
bool action_over_fsa(const cat_inode *in_place, const cat_nomme *to_be_added, const std::string &spot, over_action_ea action)
perform action for FSA due to overwriting policy
libdar::filesystem_restore::filesystem_restore
filesystem_restore(const filesystem_restore &ref)=delete
copy constructor is forbidden
libdar::mask
the generic class, parent of all masks
Definition mask.hpp:62
libdar::mem_ui::get_pointer
std::shared_ptr< user_interaction > get_pointer() const
get access to the shared_ptr pointing to the user_interaction
Definition mem_ui.hpp:97
libdar::mem_ui::get_ui
user_interaction & get_ui() const
get access to the user_interaction object
Definition mem_ui.hpp:94
libdar::path
the class path is here to manipulate paths in the Unix notation: using'/'
Definition path.hpp:51
crit_action.hpp
contains classes that let the user define the policy for overwriting files
filesystem_hard_link_read.hpp
filesystem_hard_link_read classes manages hardlinked inode read from filesystem
filesystem_hard_link_write.hpp
class filesystem_hard_link_write keeps trace of already written inode to restore hard links
fsa_family.hpp
filesystem specific attributes available families and fsa_scope definition
libdar::comparison_fields
comparison_fields
how to consider file change during comparison and incremental backup
Definition archive_aux.hpp:53
libdar::over_action_ea
over_action_ea
the possible action for overwriting EA
Definition crit_action.hpp:62
libdar::fsa_scope
std::set< fsa_family > fsa_scope
set of fsa families
Definition fsa_family.hpp:70
libdar::over_action_data
over_action_data
the possible actions for overwriting data
Definition crit_action.hpp:47
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