mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
The LVM2 part of vgmknodes [still to do the non-devfs device-mapper bit].
This commit is contained in:
parent
b8a20fc82a
commit
f7dd6d8446
@ -77,6 +77,12 @@ int lv_activate(struct cmd_context *cmd, const char *lvid_s)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int lv_mknodes(struct cmd_context *cmd, const struct logical_volume *lv)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void activation_exit(void)
|
||||
{
|
||||
return;
|
||||
@ -475,6 +481,26 @@ int lv_activate(struct cmd_context *cmd, const char *lvid_s)
|
||||
return r;
|
||||
}
|
||||
|
||||
int lv_mknodes(struct cmd_context *cmd, const struct logical_volume *lv)
|
||||
{
|
||||
struct lvinfo info;
|
||||
int r = 1;
|
||||
|
||||
if (!lv_info(lv, &info)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (info.exists)
|
||||
r = dev_manager_mknodes(lv);
|
||||
else
|
||||
r = dev_manager_rmnodes(lv);
|
||||
|
||||
fs_unlock();
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
void activation_exit(void)
|
||||
{
|
||||
dev_manager_exit();
|
||||
|
@ -35,6 +35,8 @@ int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s);
|
||||
int lv_activate(struct cmd_context *cmd, const char *lvid_s);
|
||||
int lv_deactivate(struct cmd_context *cmd, const char *lvid_s);
|
||||
|
||||
int lv_mknodes(struct cmd_context *cmd, const struct logical_volume *lv);
|
||||
|
||||
/*
|
||||
* Returns 1 if info structure has been populated, else 0.
|
||||
*/
|
||||
|
@ -2180,6 +2180,24 @@ int dev_manager_suspend(struct dev_manager *dm, struct logical_volume *lv)
|
||||
return _action(dm, lv, SUSPEND);
|
||||
}
|
||||
|
||||
int dev_manager_mknodes(const struct logical_volume *lv)
|
||||
{
|
||||
char *name;
|
||||
|
||||
if (!(name = _build_name(lv->vg->cmd->mem, lv->vg->name,
|
||||
lv->name, NULL))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return fs_add_lv(lv, name);
|
||||
}
|
||||
|
||||
int dev_manager_rmnodes(const struct logical_volume *lv)
|
||||
{
|
||||
return fs_del_lv(lv);
|
||||
}
|
||||
|
||||
void dev_manager_exit(void)
|
||||
{
|
||||
dm_lib_exit();
|
||||
|
@ -38,6 +38,9 @@ int dev_manager_suspend(struct dev_manager *dm, struct logical_volume *lv);
|
||||
int dev_manager_activate(struct dev_manager *dm, struct logical_volume *lv);
|
||||
int dev_manager_deactivate(struct dev_manager *dm, struct logical_volume *lv);
|
||||
|
||||
int dev_manager_mknodes(const struct logical_volume *lv);
|
||||
int dev_manager_rmnodes(const struct logical_volume *lv);
|
||||
|
||||
/*
|
||||
* Put the desired changes into effect.
|
||||
*/
|
||||
|
@ -182,7 +182,9 @@ static int _rm_link(const char *dev_dir, const char *vg_name,
|
||||
}
|
||||
|
||||
if (lstat(lv_path, &buf) || !S_ISLNK(buf.st_mode)) {
|
||||
log_error("%s not symbolic link - not removing", lv_path);
|
||||
if (errno != ENOENT)
|
||||
log_error("%s not symbolic link - not removing",
|
||||
lv_path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -309,13 +311,13 @@ static int _fs_op(fs_op_t type, const char *dev_dir, const char *vg_name,
|
||||
return _do_fs_op(type, dev_dir, vg_name, lv_name, dev, old_lv_name);
|
||||
}
|
||||
|
||||
int fs_add_lv(struct logical_volume *lv, const char *dev)
|
||||
int fs_add_lv(const struct logical_volume *lv, const char *dev)
|
||||
{
|
||||
return _fs_op(FS_ADD, lv->vg->cmd->dev_dir, lv->vg->name, lv->name,
|
||||
dev, "");
|
||||
}
|
||||
|
||||
int fs_del_lv(struct logical_volume *lv)
|
||||
int fs_del_lv(const struct logical_volume *lv)
|
||||
{
|
||||
return _fs_op(FS_DEL, lv->vg->cmd->dev_dir, lv->vg->name, lv->name,
|
||||
"", "");
|
||||
|
@ -14,8 +14,8 @@
|
||||
* up the volume group directory in /dev and the
|
||||
* symbolic links to the dm device.
|
||||
*/
|
||||
int fs_add_lv(struct logical_volume *lv, const char *dev);
|
||||
int fs_del_lv(struct logical_volume *lv);
|
||||
int fs_add_lv(const struct logical_volume *lv, const char *dev);
|
||||
int fs_del_lv(const struct logical_volume *lv);
|
||||
int fs_rename_lv(struct logical_volume *lv,
|
||||
const char *dev, const char *old_name);
|
||||
void fs_unlock(void);
|
||||
|
@ -54,6 +54,7 @@ SOURCES=\
|
||||
vgextend.c \
|
||||
vgimport.c \
|
||||
vgmerge.c \
|
||||
vgmknodes.c \
|
||||
vgreduce.c \
|
||||
vgremove.c \
|
||||
vgrename.c \
|
||||
|
@ -11,7 +11,6 @@
|
||||
int lvmsadc(struct cmd_context *cmd, int argc, char **argv) unimplemented
|
||||
int lvmsar(struct cmd_context *cmd, int argc, char **argv) unimplemented
|
||||
int pvresize(struct cmd_context *cmd, int argc, char **argv) unimplemented
|
||||
int vgmknodes(struct cmd_context *cmd, int argc, char **argv) unimplemented
|
||||
|
||||
int pvdata(struct cmd_context *cmd, int argc, char **argv) {
|
||||
log_error("There's no 'pvdata' command in LVM2.");
|
||||
|
36
tools/vgmknodes.c
Normal file
36
tools/vgmknodes.c
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2003 Sistina Software
|
||||
*
|
||||
* LVM 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, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* LVM 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 LVM; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "tools.h"
|
||||
|
||||
static int _vgmknodes_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
void *handle)
|
||||
{
|
||||
if (!lv_mknodes(cmd, lv))
|
||||
return ECMD_FAILED;
|
||||
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
||||
int vgmknodes(struct cmd_context *cmd, int argc, char **argv)
|
||||
{
|
||||
return process_each_lv(cmd, argc, argv, LCK_VG_READ, NULL,
|
||||
&_vgmknodes_single);
|
||||
}
|
Loading…
Reference in New Issue
Block a user