1
0
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:
Alasdair Kergon 2003-11-12 19:16:48 +00:00
parent b8a20fc82a
commit f7dd6d8446
9 changed files with 93 additions and 6 deletions

View File

@ -77,6 +77,12 @@ int lv_activate(struct cmd_context *cmd, const char *lvid_s)
{ {
return 1; return 1;
} }
int lv_mknodes(struct cmd_context *cmd, const struct logical_volume *lv)
{
return 1;
}
void activation_exit(void) void activation_exit(void)
{ {
return; return;
@ -475,6 +481,26 @@ int lv_activate(struct cmd_context *cmd, const char *lvid_s)
return r; 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) void activation_exit(void)
{ {
dev_manager_exit(); dev_manager_exit();

View File

@ -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_activate(struct cmd_context *cmd, const char *lvid_s);
int lv_deactivate(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. * Returns 1 if info structure has been populated, else 0.
*/ */

View File

@ -2180,6 +2180,24 @@ int dev_manager_suspend(struct dev_manager *dm, struct logical_volume *lv)
return _action(dm, lv, SUSPEND); 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) void dev_manager_exit(void)
{ {
dm_lib_exit(); dm_lib_exit();

View File

@ -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_activate(struct dev_manager *dm, struct logical_volume *lv);
int dev_manager_deactivate(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. * Put the desired changes into effect.
*/ */

View File

@ -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)) { 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; 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); 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, return _fs_op(FS_ADD, lv->vg->cmd->dev_dir, lv->vg->name, lv->name,
dev, ""); 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, return _fs_op(FS_DEL, lv->vg->cmd->dev_dir, lv->vg->name, lv->name,
"", ""); "", "");

View File

@ -14,8 +14,8 @@
* up the volume group directory in /dev and the * up the volume group directory in /dev and the
* symbolic links to the dm device. * symbolic links to the dm device.
*/ */
int fs_add_lv(struct logical_volume *lv, const char *dev); int fs_add_lv(const struct logical_volume *lv, const char *dev);
int fs_del_lv(struct logical_volume *lv); int fs_del_lv(const struct logical_volume *lv);
int fs_rename_lv(struct logical_volume *lv, int fs_rename_lv(struct logical_volume *lv,
const char *dev, const char *old_name); const char *dev, const char *old_name);
void fs_unlock(void); void fs_unlock(void);

View File

@ -54,6 +54,7 @@ SOURCES=\
vgextend.c \ vgextend.c \
vgimport.c \ vgimport.c \
vgmerge.c \ vgmerge.c \
vgmknodes.c \
vgreduce.c \ vgreduce.c \
vgremove.c \ vgremove.c \
vgrename.c \ vgrename.c \

View File

@ -11,7 +11,6 @@
int lvmsadc(struct cmd_context *cmd, int argc, char **argv) unimplemented int lvmsadc(struct cmd_context *cmd, int argc, char **argv) unimplemented
int lvmsar(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 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) { int pvdata(struct cmd_context *cmd, int argc, char **argv) {
log_error("There's no 'pvdata' command in LVM2."); log_error("There's no 'pvdata' command in LVM2.");

36
tools/vgmknodes.c Normal file
View 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);
}