if (stat(path.c_str(), &buf) < 0)
{
y2err("stat failed errno: " << errno << " (" << stringerror(errno) << ")");
- throw AclException();
+ SN_THROW(AclException());
}
}
else
{
y2err("fstat failed errno: " << errno << " (" << stringerror(errno) << ")");
::close(fd);
- throw AclException();
+ SN_THROW(AclException());
}
acl_access = acl_get_fd(fd);
{
y2err("acl_get_fd failed errno: " << errno << " (" << stringerror(errno) << ")");
::close(fd);
- throw AclException();
+ SN_THROW(AclException());
}
::close(fd);
if (!acl_access)
{
y2err("acl_get_file failed errno: " << errno << " (" << stringerror(errno) << ")");
- throw AclException();
+ SN_THROW(AclException());
}
}
y2err("acl_free failed errno: " << errno << " (" << stringerror(errno) << ")");
}
- throw AclException();
+ SN_THROW(AclException());
}
}
}
if (acl_set_file(path.c_str(), ACL_TYPE_ACCESS, acl_access))
{
y2err("acl_set_file failed errno: " << errno << " (" << stringerror(errno) << ")");
- throw AclException();
+ SN_THROW(AclException());
}
if (get_acl_types() & ACL_TYPE_DEFAULT)
if (acl_set_file(path.c_str(), ACL_TYPE_DEFAULT, acl_default))
{
y2err("acl_set_file failed errno: " << errno << " (" << stringerror(errno) << ")");
- throw AclException();
+ SN_THROW(AclException());
}
}
}
if (file == NULL)
{
y2war("file is NULL");
- throw FileNotFoundException();
+ SN_THROW(FileNotFoundException());
}
}
if (file == NULL)
{
y2war("file is NULL");
- throw FileNotFoundException();
+ SN_THROW(FileNotFoundException());
}
}
if (file == NULL)
{
y2war("open for '" << filename << "' failed");
- throw FileNotFoundException();
+ SN_THROW(FileNotFoundException());
}
}
Regex rx("^" "([0-9A-Z_]+)" "$");
if (!rx.match(key))
- throw InvalidKeyException();
+ SN_THROW(InvalidKeyException());
}
catch (const runtime_error& e)
{
y2err("failed to parse qgroup '" << qgroup_str << "'");
- throw InvalidConfigException();
+ SN_THROW(InvalidConfigException());
}
}
switch (e.error_number)
{
case EEXIST:
- throw CreateConfigFailedException("creating btrfs subvolume .snapshots failed "
- "since it already exists");
+ SN_THROW(CreateConfigFailedException("creating btrfs subvolume .snapshots failed "
+ "since it already exists"));
default:
- throw CreateConfigFailedException("creating btrfs subvolume .snapshots failed");
+ SN_THROW(CreateConfigFailedException("creating btrfs subvolume .snapshots failed"));
}
}
catch (const runtime_error& e)
{
y2err("delete subvolume failed, " << e.what());
- throw DeleteConfigFailedException("deleting btrfs snapshot failed");
+ SN_THROW(DeleteConfigFailedException("deleting btrfs snapshot failed"));
}
}
struct stat stat;
if (subvolume_dir.stat(&stat) != 0)
{
- throw IOErrorException("stat on subvolume directory failed");
+ SN_THROW(IOErrorException("stat on subvolume directory failed"));
}
if (!is_subvolume(stat))
{
- throw IOErrorException("subvolume is not a btrfs subvolume");
+ SN_THROW(IOErrorException("subvolume is not a btrfs subvolume"));
}
return subvolume_dir;
struct stat stat;
if (infos_dir.stat(&stat) != 0)
{
- throw IOErrorException("stat on info directory failed");
+ SN_THROW(IOErrorException("stat on info directory failed"));
}
if (!is_subvolume(stat))
if (stat.st_uid != 0)
{
y2err(".snapshots must have owner root");
- throw IOErrorException(".snapshots must have owner root");
+ SN_THROW(IOErrorException(".snapshots must have owner root"));
}
if (stat.st_gid != 0 && stat.st_mode & S_IWGRP)
{
y2err(".snapshots must have group root or must not be group-writable");
- throw IOErrorException(".snapshots must have group root or must not be group-writable");
+ SN_THROW(IOErrorException(".snapshots must have group root or must not be group-writable"));
}
if (stat.st_mode & S_IWOTH)
{
y2err(".snapshots must not be world-writable");
- throw IOErrorException(".snapshots must not be world-writable");
+ SN_THROW(IOErrorException(".snapshots must not be world-writable"));
}
return infos_dir;
catch (const runtime_error& e)
{
y2err("create snapshot failed, " << e.what());
- throw CreateSnapshotFailedException();
+ SN_THROW(CreateSnapshotFailedException());
}
}
else
catch (const runtime_error& e)
{
y2err("create snapshot failed, " << e.what());
- throw CreateSnapshotFailedException();
+ SN_THROW(CreateSnapshotFailedException());
}
}
}
if (!getMtabData(subvolume, found, mtab_data))
{
y2err("failed to find device");
- throw CreateSnapshotFailedException();
+ SN_THROW(CreateSnapshotFailedException());
}
SDir infos_dir = openInfosDir();
catch (const runtime_error& e)
{
y2err("create snapshot failed, " << e.what());
- throw CreateSnapshotFailedException();
+ SN_THROW(CreateSnapshotFailedException());
}
}
catch (const runtime_error& e)
{
y2err("delete snapshot failed, " << e.what());
- throw DeleteSnapshotFailedException();
+ SN_THROW(DeleteSnapshotFailedException());
}
}
if (r < 0)
{
y2err("failed to initialize subvol search (" << stringerror(r) << ")");
- throw BtrfsSendReceiveException();
+ SN_THROW(BtrfsSendReceiveException());
}
}
if (r1 < 0)
{
y2err("pipe failed errno:" << errno << " (" << stringerror(errno) << ")");
- throw BtrfsSendReceiveException();
+ SN_THROW(BtrfsSendReceiveException());
}
struct btrfs_ioctl_send_args io_send;
if (r2 < 0 || !uf.get())
{
- throw BtrfsSendReceiveException();
+ SN_THROW(BtrfsSendReceiveException());
}
#else
if (r2 < 0 || !dumper_ret)
{
- throw BtrfsSendReceiveException();
+ SN_THROW(BtrfsSendReceiveException());
}
#endif
u64 flags;
if (ioctl(dir.fd(), BTRFS_IOC_SUBVOL_GETFLAGS, &flags) < 0)
{
- throw IOErrorException("ioctl BTRFS_IOC_SUBVOL_GETFLAGS failed");
+ SN_THROW(IOErrorException("ioctl BTRFS_IOC_SUBVOL_GETFLAGS failed"));
}
return flags & BTRFS_SUBVOL_RDONLY;
if (!is_subvolume_ro(dir1) || !is_subvolume_ro(dir2))
{
y2err("not read-only snapshots");
- throw BtrfsSendReceiveException();
+ SN_THROW(BtrfsSendReceiveException());
}
u64 parent_root_id = 0;
if (!get_root_id(name1, &parent_root_id))
{
y2err("could not resolve root_id for " << name1);
- throw BtrfsSendReceiveException();
+ SN_THROW(BtrfsSendReceiveException());
}
vector<u64> clone_sources;
}
catch (const runtime_error& e)
{
- throw IOErrorException(string("set default failed, ") + e.what());
+ SN_THROW(IOErrorException(string("set default failed, ") + e.what()));
}
}
const struct stat& stat2)
{
if ((stat1.st_mode & S_IFMT) != (stat2.st_mode & S_IFMT))
- throw LogicErrorException();
+ SN_THROW(LogicErrorException());
switch (stat1.st_mode & S_IFMT)
{
return DELETED;
if (r1 != 0)
- throw IOErrorException("stat failed path:" + file1.fullname());
+ SN_THROW(IOErrorException("stat failed path:" + file1.fullname()));
if (r2 != 0)
- throw IOErrorException("lstat failed path:" + file2.fullname());
+ SN_THROW(IOErrorException("lstat failed path:" + file2.fullname()));
return cmpFiles(file1, stat1, file2, stat2);
}
else
{
if (*first1 != *first2)
- throw LogicErrorException();
+ SN_THROW(LogicErrorException());
struct stat stat1;
dir1.stat(*first1, &stat1, AT_SYMLINK_NOFOLLOW); // TODO error check
struct stat stat1;
int r1 = dir1.stat(&stat1);
if (r1 != 0)
- throw IOErrorException(sformat("stat failed path:%s errno:%d", dir1.fullname().c_str(), errno));
+ SN_THROW(IOErrorException(sformat("stat failed path:%s errno:%d",
+ dir1.fullname().c_str(), errno)));
struct stat stat2;
int r2 = dir2.stat(&stat2);
if (r2 != 0)
- throw IOErrorException(sformat("stat failed path:%s errno:%d", dir2.fullname().c_str(), errno));
+ SN_THROW(IOErrorException(sformat("stat failed path:%s errno:%d",
+ dir2.fullname().c_str(), errno)));
CmpData cmp_data;
cmp_data.cb = cb;
if (snapshot1 == snapper->getSnapshots().end() ||
snapshot2 == snapper->getSnapshots().end() ||
snapshot1 == snapshot2)
- throw IllegalSnapshotException();
+ SN_THROW(IllegalSnapshotException());
y2mil("num1:" << snapshot1->getNum() << " num2:" << snapshot2->getNum());
y2mil("num1:" << getSnapshot1()->getNum() << " num2:" << getSnapshot2()->getNum());
if (getSnapshot1()->isCurrent() || getSnapshot2()->isCurrent())
- throw IllegalSnapshotException();
+ SN_THROW(IllegalSnapshotException());
unsigned int num1 = getSnapshot1()->getNum();
unsigned int num2 = getSnapshot2()->getNum();
y2mil("num1:" << getSnapshot1()->getNum() << " num2:" << getSnapshot2()->getNum());
if (getSnapshot1()->isCurrent() || getSnapshot2()->isCurrent())
- throw IllegalSnapshotException();
+ SN_THROW(IllegalSnapshotException());
unsigned int num1 = getSnapshot1()->getNum();
unsigned int num2 = getSnapshot2()->getNum();
FILE* file = fdopen(info_dir.mktemp(tmp_name), "w");
if (!file)
- throw IOErrorException(sformat("mkstemp failed errno:%d (%s)", errno,
- stringerror(errno).c_str()));
+ SN_THROW(IOErrorException(sformat("mkstemp failed errno:%d (%s)", errno,
+ stringerror(errno).c_str())));
for (Files::const_iterator it = files.begin(); it != files.end(); ++it)
{
Comparison::getUndoStatistic() const
{
if (getSnapshot1()->isCurrent())
- throw IllegalSnapshotException();
+ SN_THROW(IllegalSnapshotException());
return files.getUndoStatistic();
}
Comparison::getXAUndoStatistic() const
{
if (getSnapshot1()->isCurrent())
- throw IllegalSnapshotException();
+ SN_THROW(IllegalSnapshotException());
return files.getXAUndoStatistic();
}
Comparison::getUndoSteps() const
{
if (getSnapshot1()->isCurrent())
- throw IllegalSnapshotException();
+ SN_THROW(IllegalSnapshotException());
return files.getUndoSteps();
}
Comparison::doUndoStep(const UndoStep& undo_step)
{
if (getSnapshot1()->isCurrent())
- throw IllegalSnapshotException();
+ SN_THROW(IllegalSnapshotException());
return files.doUndoStep(undo_step);
}
{
dirfd = ::open(base_path.c_str(), O_RDONLY | O_NOATIME | O_CLOEXEC);
if (dirfd < 0)
- throw IOErrorException(sformat("open failed path:%s errno:%d (%s)", base_path.c_str(),
- errno, stringerror(errno).c_str()));
+ SN_THROW(IOErrorException(sformat("open failed path:%s errno:%d (%s)", base_path.c_str(),
+ errno, stringerror(errno).c_str())));
struct stat buf;
if (fstat(dirfd, &buf) != 0)
- throw IOErrorException(sformat("fstat failed path:%s errno:%d (%s)", base_path.c_str(),
- errno, stringerror(errno).c_str()));
+ SN_THROW(IOErrorException(sformat("fstat failed path:%s errno:%d (%s)", base_path.c_str(),
+ errno, stringerror(errno).c_str())));
if (!S_ISDIR(buf.st_mode))
- throw IOErrorException("not a directory path:" + base_path);
+ SN_THROW(IOErrorException("not a directory path:" + base_path));
setXaStatus();
}
dirfd = ::openat(dir.dirfd, name.c_str(), O_RDONLY | O_NOFOLLOW | O_NOATIME | O_CLOEXEC);
if (dirfd < 0)
- throw IOErrorException(sformat("open failed path:%s errno:%d (%s)", dir.fullname().c_str(),
- errno, stringerror(errno).c_str()));
+ SN_THROW(IOErrorException(sformat("open failed path:%s errno:%d (%s)", dir.fullname().c_str(),
+ errno, stringerror(errno).c_str())));
struct stat buf;
if (fstat(dirfd, &buf) != 0)
- throw IOErrorException(sformat("fstat failed path:%s errno:%d (%s)", base_path.c_str(),
- errno, stringerror(errno).c_str()));
+ SN_THROW(IOErrorException(sformat("fstat failed path:%s errno:%d (%s)", base_path.c_str(),
+ errno, stringerror(errno).c_str())));
if (!S_ISDIR(buf.st_mode))
{
close(dirfd);
- throw IOErrorException("not a directory path:" + dir.fullname(name));
+ SN_THROW(IOErrorException("not a directory path:" + dir.fullname(name)));
}
xastatus = dir.xastatus;
{
dirfd = fcntl(dir.dirfd, F_DUPFD_CLOEXEC, 0);
if (dirfd == -1)
- throw IOErrorException(sformat("fcntl(F_DUPFD_CLOEXEC) failed error:%d (%s)", errno,
- stringerror(errno).c_str()));
+ SN_THROW(IOErrorException(sformat("fcntl(F_DUPFD_CLOEXEC) failed error:%d (%s)", errno,
+ stringerror(errno).c_str())));
xastatus = dir.xastatus;
}
::close(dirfd);
dirfd = fcntl(dir.dirfd, F_DUPFD_CLOEXEC, 0);
if (dirfd == -1)
- throw IOErrorException(sformat("fcntl(F_DUPFD_CLOEXEC) failed error:%d (%s)", errno,
- stringerror(errno).c_str()));
+ SN_THROW(IOErrorException(sformat("fcntl(F_DUPFD_CLOEXEC) failed error:%d (%s)", errno,
+ stringerror(errno).c_str())));
xastatus = dir.xastatus;
}
{
int fd = fcntl(dirfd, F_DUPFD_CLOEXEC, 0);
if (fd == -1)
- throw IOErrorException(sformat("fcntl(F_DUPFD_CLOEXEC) failed error:%d (%s)", errno,
- stringerror(errno).c_str()));
+ SN_THROW(IOErrorException(sformat("fcntl(F_DUPFD_CLOEXEC) failed error:%d (%s)", errno,
+ stringerror(errno).c_str())));
DIR* dp = fdopendir(fd);
if (dp == NULL)
{
::close(fd);
- throw IOErrorException(sformat("fdopendir failed path:%s error:%d (%s)",
- fullname().c_str(), errno, stringerror(errno).c_str()));
+ SN_THROW(IOErrorException(sformat("fdopendir failed path:%s error:%d (%s)",
+ fullname().c_str(), errno, stringerror(errno).c_str())));
}
vector<string> ret;
}
else
{
- throw IOErrorException(sformat("Couldn't get extended attributes status for %s/%s, "
- "errno:%d (%s)", base_path.c_str(), path.c_str(),
- errno, stringerror(errno).c_str()));
+ SN_THROW(IOErrorException(sformat("Couldn't get extended attributes status for %s/%s, "
+ "errno:%d (%s)", base_path.c_str(), path.c_str(),
+ errno, stringerror(errno).c_str())));
}
}
else
}
y2err("do not know about fstype '" << fstype << "'");
- throw InvalidConfigException();
+ SN_THROW(InvalidConfigException());
+ __builtin_unreachable();
}
config_name(config_name), subvolume("/")
{
if (!getValue(KEY_SUBVOLUME, subvolume))
- throw InvalidConfigException();
+ SN_THROW(InvalidConfigException());
}
ConfigInfo::checkKey(const string& key) const
{
if (key == KEY_SUBVOLUME || key == KEY_FSTYPE)
- throw InvalidConfigdataException();
+ SN_THROW(InvalidConfigdataException());
try
{
}
catch (const InvalidKeyException& e)
{
- throw InvalidConfigdataException();
+ SN_THROW(InvalidConfigdataException());
}
}
}
catch (const FileNotFoundException& e)
{
- throw ConfigNotFoundException();
+ SN_THROW(ConfigNotFoundException());
}
filesystem = Filesystem::create(*config_info, root_prefix);
Snapper::createSingleSnapshot(Snapshots::const_iterator parent, const SCD& scd)
{
if (parent == snapshots.end())
- throw IllegalSnapshotException();
+ SN_THROW(IllegalSnapshotException());
return snapshots.createSingleSnapshot(parent, scd);
}
}
catch (const FileNotFoundException& e)
{
- throw ListConfigsFailedException("sysconfig-file not found");
+ SN_THROW(ListConfigsFailedException("sysconfig-file not found"));
}
return config_infos;
if (config_name.empty() || config_name.find_first_of(", \t") != string::npos)
{
- throw CreateConfigFailedException("illegal config name");
+ SN_THROW(CreateConfigFailedException("illegal config name"));
}
if (!boost::starts_with(subvolume, "/") || !checkDir(subvolume))
{
- throw CreateConfigFailedException("illegal subvolume");
+ SN_THROW(CreateConfigFailedException("illegal subvolume"));
}
list<ConfigInfo> configs = getConfigs(root_prefix);
{
if (it->getSubvolume() == subvolume)
{
- throw CreateConfigFailedException("subvolume already covered");
+ SN_THROW(CreateConfigFailedException("subvolume already covered"));
}
}
if (access(string(CONFIGTEMPLATEDIR "/" + template_name).c_str(), R_OK) != 0)
{
- throw CreateConfigFailedException("cannot access template config");
+ SN_THROW(CreateConfigFailedException("cannot access template config"));
}
unique_ptr<Filesystem> filesystem;
}
catch (const InvalidConfigException& e)
{
- throw CreateConfigFailedException("invalid filesystem type");
+ SN_THROW(CreateConfigFailedException("invalid filesystem type"));
}
catch (const ProgramNotInstalledException& e)
{
- throw CreateConfigFailedException(e.what());
+ SN_THROW(CreateConfigFailedException(e.what()));
}
try
sysconfig.getValue("SNAPPER_CONFIGS", config_names);
if (find(config_names.begin(), config_names.end(), config_name) != config_names.end())
{
- throw CreateConfigFailedException("config already exists");
+ SN_THROW(CreateConfigFailedException("config already exists"));
}
config_names.push_back(config_name);
}
catch (const FileNotFoundException& e)
{
- throw CreateConfigFailedException("sysconfig-file not found");
+ SN_THROW(CreateConfigFailedException("sysconfig-file not found"));
}
try
}
catch (const FileNotFoundException& e)
{
- throw CreateConfigFailedException("modifying config failed");
+ SN_THROW(CreateConfigFailedException("modifying config failed"));
}
try
{
filesystem->createConfig();
}
- catch (...)
+ catch (const Exception& e)
{
+ SN_CAUGHT(e);
+
SysconfigFile sysconfig(SYSCONFIGFILE);
vector<string> config_names;
sysconfig.getValue("SNAPPER_CONFIGS", config_names);
SystemCmd cmd(RMBIN " " + quote(CONFIGSDIR "/" + config_name));
- throw;
+ SN_RETHROW(e);
}
Hooks::create_config(subvolume, filesystem.get());
}
catch (const DeleteConfigFailedException& e)
{
- throw DeleteConfigFailedException("deleting snapshot failed");
+ SN_THROW(DeleteConfigFailedException("deleting snapshot failed"));
}
SystemCmd cmd1(RMBIN " " + quote(CONFIGSDIR "/" + config_name));
if (cmd1.retcode() != 0)
{
- throw DeleteConfigFailedException("deleting config-file failed");
+ SN_THROW(DeleteConfigFailedException("deleting config-file failed"));
}
try
}
catch (const FileNotFoundException& e)
{
- throw DeleteConfigFailedException("sysconfig-file not found");
+ SN_THROW(DeleteConfigFailedException("sysconfig-file not found"));
}
}
{
uid_t uid;
if (!get_user_uid(it->c_str(), uid))
- throw InvalidUserException();
+ SN_THROW(InvalidUserException());
uids.push_back(uid);
}
}
{
gid_t gid;
if (!get_group_gid(it->c_str(), gid))
- throw InvalidGroupException();
+ SN_THROW(InvalidGroupException());
gids.push_back(gid);
}
}
{
acl_permset_t permset;
if (acl_get_permset(entry, &permset) != 0)
- throw AclException();
+ SN_THROW(AclException());
if (acl_add_perm(permset, ACL_READ) != 0 || acl_delete_perm(permset, ACL_WRITE) != 0 ||
acl_add_perm(permset, ACL_EXECUTE) != 0)
- throw AclException();
+ SN_THROW(AclException());
};
{
acl_entry_t entry;
if (acl_create_entry(acl, &entry) != 0)
- throw AclException();
+ SN_THROW(AclException());
if (acl_set_tag_type(entry, tag) != 0)
- throw AclException();
+ SN_THROW(AclException());
if (acl_set_qualifier(entry, qualifier) != 0)
- throw AclException();
+ SN_THROW(AclException());
set_acl_permissions(entry);
};
acl_t orig_acl = acl_get_fd(infos_dir.fd());
if (!orig_acl)
- throw AclException();
+ SN_THROW(AclException());
acl_t acl = acl_dup(orig_acl);
if (!acl)
- throw AclException();
+ SN_THROW(AclException());
set<uid_t> remaining_uids = set<uid_t>(uids.begin(), uids.end());
set<gid_t> remaining_gids = set<gid_t>(gids.begin(), gids.end());
acl_tag_t tag;
if (acl_get_tag_type(entry, &tag) != 0)
- throw AclException();
+ SN_THROW(AclException());
switch (tag)
{
uid_t* uid = (uid_t*) acl_get_qualifier(entry);
if (!uid)
- throw AclException();
+ SN_THROW(AclException());
if (contains(remaining_uids, *uid))
{
else
{
if (acl_delete_entry(acl, entry) != 0)
- throw AclException();
+ SN_THROW(AclException());
}
} break;
gid_t* gid = (gid_t*) acl_get_qualifier(entry);
if (!gid)
- throw AclException();
+ SN_THROW(AclException());
if (contains(remaining_gids, *gid))
{
else
{
if (acl_delete_entry(acl, entry) != 0)
- throw AclException();
+ SN_THROW(AclException());
}
} break;
}
if (acl_calc_mask(&acl) != 0)
- throw AclException();
+ SN_THROW(AclException());
if (acl_cmp(orig_acl, acl) == 1)
if (acl_set_fd(infos_dir.fd(), acl) != 0)
- throw AclException();
+ SN_THROW(AclException());
if (acl_free(acl) != 0)
- throw AclException();
+ SN_THROW(AclException());
}
Snapshot::openInfoDir() const
{
if (isCurrent())
- throw IllegalSnapshotException();
+ SN_THROW(IllegalSnapshotException());
SDir infos_dir = snapper->openInfosDir();
return SDir(infos_dir, decString(num));
for (map<string, string>::const_iterator it = userdata.begin(); it != userdata.end(); ++it)
{
if (it->first.empty() || it->first.find_first_of(",=") != string::npos)
- throw InvalidUserdataException();
+ SN_THROW(InvalidUserdataException());
if (it->second.find_first_of(",=") != string::npos)
- throw InvalidUserdataException();
+ SN_THROW(InvalidUserdataException());
}
}
Snapshots::findPost(const_iterator pre)
{
if (pre == entries.end() || pre->isCurrent() || pre->getType() != PRE)
- throw IllegalSnapshotException();
+ SN_THROW(IllegalSnapshotException());
for (iterator it = begin(); it != end(); ++it)
{
Snapshots::findPost(const_iterator pre) const
{
if (pre == entries.end() || pre->isCurrent() || pre->getType() != PRE)
- throw IllegalSnapshotException();
+ SN_THROW(IllegalSnapshotException());
for (const_iterator it = begin(); it != end(); ++it)
{
Snapshots::findPre(const_iterator post)
{
if (post == entries.end() || post->isCurrent() || post->getType() != POST)
- throw IllegalSnapshotException();
+ SN_THROW(IllegalSnapshotException());
return find(post->pre_num);
}
Snapshots::findPre(const_iterator post) const
{
if (post == entries.end() || post->isCurrent() || post->getType() != POST)
- throw IllegalSnapshotException();
+ SN_THROW(IllegalSnapshotException());
return find(post->pre_num);
}
if (errno == EEXIST)
continue;
- throw IOErrorException(sformat("mkdir failed errno:%d (%s)", errno,
- stringerror(errno).c_str()));
+ SN_THROW(IOErrorException(sformat("mkdir failed errno:%d (%s)", errno,
+ stringerror(errno).c_str())));
}
infos_dir.chmod(decString(num), 0755, 0);
xml.save(info_dir.mktemp(tmp_name));
if (info_dir.rename(tmp_name, file_name) != 0)
- throw IOErrorException(sformat("rename info.xml failed infoDir:%s errno:%d (%s)",
- info_dir.fullname().c_str(), errno,
- stringerror(errno).c_str()));
+ SN_THROW(IOErrorException(sformat("rename info.xml failed infoDir:%s errno:%d (%s)",
+ info_dir.fullname().c_str(), errno,
+ stringerror(errno).c_str())));
}
Snapshot::mountFilesystemSnapshot(bool user_request) const
{
if (isCurrent())
- throw IllegalSnapshotException();
+ SN_THROW(IllegalSnapshotException());
if (!mount_checked)
{
Snapshot::umountFilesystemSnapshot(bool user_request) const
{
if (isCurrent())
- throw IllegalSnapshotException();
+ SN_THROW(IllegalSnapshotException());
if (!mount_checked)
{
Snapshot::createFilesystemSnapshot(unsigned int num_parent, bool read_only) const
{
if (isCurrent())
- throw IllegalSnapshotException();
+ SN_THROW(IllegalSnapshotException());
snapper->getFilesystem()->createSnapshot(num, num_parent, read_only);
}
Snapshot::createFilesystemSnapshotOfDefault(bool read_only) const
{
if (isCurrent())
- throw IllegalSnapshotException();
+ SN_THROW(IllegalSnapshotException());
snapper->getFilesystem()->createSnapshotOfDefault(num, read_only);
}
Snapshot::deleteFilesystemSnapshot() const
{
if (isCurrent())
- throw IllegalSnapshotException();
+ SN_THROW(IllegalSnapshotException());
snapper->getFilesystem()->umountSnapshot(num);
snapper->getFilesystem()->deleteSnapshot(num);
{
if (pre == entries.end() || pre->isCurrent() || pre->getType() != PRE ||
findPost(pre) != entries.end())
- throw IllegalSnapshotException();
+ SN_THROW(IllegalSnapshotException());
checkUserdata(scd.userdata);
}
catch (const CreateSnapshotFailedException& e)
{
+ SN_CAUGHT(e);
+
SDir infos_dir = snapper->openInfosDir();
infos_dir.unlink(decString(snapshot.getNum()), AT_REMOVEDIR);
- throw;
+
+ SN_RETHROW(e);
}
try
}
catch (const IOErrorException& e)
{
+ SN_CAUGHT(e);
+
snapshot.deleteFilesystemSnapshot();
SDir infos_dir = snapper->openInfosDir();
infos_dir.unlink(decString(snapshot.getNum()), AT_REMOVEDIR);
- throw;
+
+ SN_RETHROW(e);
}
Hooks::create_snapshot(snapper->subvolumeDir(), snapper->getFilesystem());
Snapshots::modifySnapshot(iterator snapshot, const SMD& smd)
{
if (snapshot == entries.end() || snapshot->isCurrent())
- throw IllegalSnapshotException();
+ SN_THROW(IllegalSnapshotException());
checkUserdata(smd.userdata);
Snapshots::deleteSnapshot(iterator snapshot)
{
if (snapshot == entries.end() || snapshot->isCurrent())
- throw IllegalSnapshotException();
+ SN_THROW(IllegalSnapshotException());
snapshot->deleteFilesystemSnapshot();
{
y2err("Couldn't get xattributes names-list size. link: " << path
<< ", error: " << stringerror(errno));
- throw XAttributesException();
+ SN_THROW(XAttributesException());
}
y2deb("XAttributes names-list size is: " << size);
{
y2err("Couldn't get xattributes names-list. link: " << path <<
", error: " << stringerror(errno));
- throw XAttributesException();
+ SN_THROW(XAttributesException());
}
ssize_t pos = 0;
{
y2err("Couldn't get a xattribute value size for the xattribute name '" << name
<< "': " << stringerror(errno));
- throw XAttributesException();
+ SN_THROW(XAttributesException());
}
y2deb("XAttribute value size for xattribute name: '" << name << "' is " << v_size);
if (v_size < 0)
{
y2err("Couldn't get xattribute value for the xattribute name '" << name << "': ");
- throw XAttributesException();
+ SN_THROW(XAttributesException());
}
}
if (!xamap.insert(make_pair(name, xa_value_t(buffer.get(), buffer.get() + v_size))).second)
{
y2err("Duplicite extended attribute name in source file!");
- throw XAttributesException();
+ SN_THROW(XAttributesException());
}
}
{
y2err("Couldn't get xattributes names-list size. link: " << file.fullname(true) <<
", error: " << stringerror(errno));
- throw XAttributesException();
+ SN_THROW(XAttributesException());
}
y2deb("XAttributes names-list size is: " << size);
{
y2err("Couldn't get xattributes names-list. link: " << file.fullname(true) <<
", error: " << stringerror(errno));
- throw XAttributesException();
+ SN_THROW(XAttributesException());
}
ssize_t pos = 0;
{
y2err("Couldn't get a xattribute value size for the xattribute name '" <<
name << "': " << stringerror(errno));
- throw XAttributesException();
+ SN_THROW(XAttributesException());
}
y2deb("XAttribute value size for xattribute name: '" << name << "' is " << v_size);
if (v_size < 0)
{
y2err("Couldn't get xattribute value for the xattribute name '" << name << "': ");
- throw XAttributesException();
+ SN_THROW(XAttributesException());
}
}
if (!xamap.insert(make_pair(name, xa_value_t(buffer.get(), buffer.get() + v_size))).second)
{
y2err("Duplicite extended attribute name in source file!");
- throw XAttributesException();
+ SN_THROW(XAttributesException());
}
}