/*
* Copyright (c) [2011-2015] Novell, Inc.
- * Copyright (c) 2016 SUSE LLC
+ * Copyright (c) [2016-2017] SUSE LLC
*
* All Rights Reserved.
*
#include "snapper/SnapperDefines.h"
#include "snapper/Acls.h"
#include "snapper/Exception.h"
+#include "snapper/Regex.h"
#ifdef ENABLE_ROLLBACK
#include "snapper/MntTable.h"
#endif
}
+ std::pair<bool, unsigned int>
+ Btrfs::getDefault() const
+ {
+ SDir subvolume_dir = openSubvolumeDir();
+
+ subvolid_t id = get_default_id(subvolume_dir.fd());
+
+ string path = get_subvolume(subvolume_dir.fd(), id);
+
+ Regex rx("/([0-9]+)/snapshot$");
+ if (!rx.match(path))
+ return make_pair(false, 0);
+
+ unsigned int num = stoi(rx.cap(1));
+
+ if (get_id(openSnapshotDir(num).fd()) != id)
+ return make_pair(false, 0);
+
+ return make_pair(true, num);
+ }
+
+
void
Btrfs::setDefault(unsigned int num) const
{
}
+ std::pair<bool, unsigned int>
+ Btrfs::getDefault() const
+ {
+ throw std::logic_error("not implemented");
+ }
+
+
void
Btrfs::setDefault(unsigned int num) const
{
/*
* Copyright (c) [2011-2015] Novell, Inc.
- * Copyright (c) 2016 SUSE LLC
+ * Copyright (c) [2016-2017] SUSE LLC
*
* All Rights Reserved.
*
virtual void cmpDirs(const SDir& dir1, const SDir& dir2, cmpdirs_cb_t cb) const;
virtual bool isDefault(unsigned int num) const;
+
+ virtual std::pair<bool, unsigned int> getDefault() const;
virtual void setDefault(unsigned int num) const;
virtual bool isActive(unsigned int num) const;
/*
* Copyright (c) [2011-2015] Novell, Inc.
- * Copyright (c) 2016 SUSE LLC
+ * Copyright (c) [2016-2017] SUSE LLC
*
* All Rights Reserved.
*
}
+ std::pair<bool, unsigned int>
+ Filesystem::getDefault() const
+ {
+ throw std::logic_error("not implemented");
+ }
+
+
void
Filesystem::setDefault(unsigned int num) const
{
/*
* Copyright (c) [2011-2015] Novell, Inc.
- * Copyright (c) 2016 SUSE LLC
+ * Copyright (c) [2016-2017] SUSE LLC
*
* All Rights Reserved.
*
#include <string>
#include <vector>
+#include <utility>
#include "snapper/FileUtils.h"
#include "snapper/Compare.h"
virtual void cmpDirs(const SDir& dir1, const SDir& dir2, cmpdirs_cb_t cb) const;
virtual bool isDefault(unsigned int num) const;
+
+ /**
+ * Query the number of the default snapshot. The first entry of the
+ * pair indicates whether the default snapshot is a snapper snapshot.
+ * Currently only available for btrfs.
+ */
+ virtual std::pair<bool, unsigned int> getDefault() const;
+
virtual void setDefault(unsigned int num) const;
virtual bool isActive(unsigned int num) const;