Added "relabel" command to rename volumes.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16888 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
6f850dfd44
commit
a722407264
@ -1669,6 +1669,31 @@ do_sync(int argc, char **argv)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
do_relabel(int argc, char **argv)
|
||||
{
|
||||
if (argc < 2) {
|
||||
printf("usage: relabel <volume name>\n");
|
||||
return FS_EINVAL;
|
||||
}
|
||||
|
||||
struct my_stat st;
|
||||
status_t error = sys_rstat(true, -1, "/myfs", &st, true);
|
||||
if (error == FS_OK) {
|
||||
fs_info info;
|
||||
strncpy(info.volume_name, argv[1], sizeof(info.volume_name));
|
||||
info.volume_name[sizeof(info.volume_name) - 1] = '\0';
|
||||
|
||||
error = sys_write_fs_info(true, st.dev, &info, WFSSTAT_NAME);
|
||||
}
|
||||
|
||||
if (error != FS_OK)
|
||||
printf("Could not create index: %s\n", fs_strerror(error));
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
do_mkindex(int argc, char **argv)
|
||||
{
|
||||
@ -2038,6 +2063,7 @@ static cmd_entry builtin_commands[] =
|
||||
{ "seek", do_seek, "seek to the position specified" },
|
||||
{ "mv", do_rename, "rename a file or directory" },
|
||||
{ "sync", do_sync, "call sync" },
|
||||
{ "relabel", do_relabel, "rename the volume" },
|
||||
{ "wrattr", do_write_attr, "write attribute \"name\" to the current file (N bytes [256])." },
|
||||
{ "rdattr", do_read_attr, "read attribute \"name\" from the current file (N bytes [256])." },
|
||||
{ "rmattr", do_remove_attr, "remove attribute \"name\" from the current file." },
|
||||
|
@ -2084,6 +2084,35 @@ error1:
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
sys_write_fs_info(int kernel, dev_t device, struct fs_info *info, int mask)
|
||||
{
|
||||
int status = FS_EINVAL;
|
||||
fsystem *fs = NULL;
|
||||
vnode *root = NULL;
|
||||
nspace *ns;
|
||||
|
||||
LOCK(vnlock);
|
||||
ns = nsidtons(device);
|
||||
if (ns != NULL) {
|
||||
fs = ns->fs;
|
||||
if (fs->ops.wfsstat != NULL) {
|
||||
status = FS_OK;
|
||||
root = ns->root;
|
||||
root->rcnt++;
|
||||
}
|
||||
}
|
||||
UNLOCK(vnlock);
|
||||
|
||||
if (status == FS_OK) {
|
||||
status = (*fs->ops.wfsstat)(ns->data, info, mask);
|
||||
dec_vnode(root, FALSE);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
sys_mkindex(int kernel, dev_t device, const char *index, int type, int flags)
|
||||
{
|
||||
|
@ -31,6 +31,7 @@ void *sys_mount(int kernel, const char *filesystem, int fd,
|
||||
const char *where, const char *device, ulong flags,
|
||||
void *parms, size_t len);
|
||||
int sys_unmount(int kernel, int fd, const char *where);
|
||||
int sys_write_fs_info(int kernel, dev_t device, struct fs_info *info, int mask);
|
||||
int sys_rstat(int kernel, int fd, const char *path, struct my_stat *st,
|
||||
int eatlink);
|
||||
int sys_wstat(int kernel, int fd, const char *path, struct my_stat *st,
|
||||
|
Loading…
Reference in New Issue
Block a user