return 0;
}
-static int do_kernel_add(const char *poolname, const char *imgname, const char *secretfile, const char *user)
+static int do_kernel_add(const char *poolname, const char *imgname,
+ const char *snapname, const char *secretfile,
+ const char *user)
{
MonMap monmap;
int r = MonClient::build_initial_monmap(g_ceph_context, monmap);
oss << " " << poolname << " " << imgname;
+ if (snapname) {
+ oss << " " << snapname;
+ }
+
// write to /sys/bus/rbd/add
int fd = open("/sys/bus/rbd/add", O_WRONLY);
if (fd < 0) {
(char **)&imgname, (char **)&snapname);
if (snapname && opt_cmd != OPT_SNAP_CREATE && opt_cmd != OPT_SNAP_ROLLBACK &&
opt_cmd != OPT_SNAP_REMOVE && opt_cmd != OPT_INFO &&
- opt_cmd != OPT_EXPORT && opt_cmd != OPT_COPY) {
+ opt_cmd != OPT_EXPORT && opt_cmd != OPT_COPY &&
+ opt_cmd != OPT_MAP) {
cerr << "error: snapname specified for a command that doesn't use it" << std::endl;
usage_exit();
}
break;
case OPT_MAP:
- r = do_kernel_add(poolname, imgname, secretfile, user);
+ r = do_kernel_add(poolname, imgname, snapname, secretfile, user);
if (r < 0) {
cerr << "add failed: " << cpp_strerror(-r) << std::endl;
exit(1);