labels: move ntfslabel to ntfs.c

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
This commit is contained in:
Chen Hanxiao
2015-07-08 17:34:43 +08:00
committed by Pino Toscano
parent d5a60f2148
commit 5c6be8846f
3 changed files with 21 additions and 21 deletions

View File

@@ -281,6 +281,7 @@ extern int btrfs_set_uuid_random (const char *device);
/*-- in ntfs.c --*/
extern char *ntfs_get_label (const char *device);
extern int ntfs_set_label (const char *device, const char *label);
/*-- in swap.c --*/
extern int swap_set_uuid (const char *device, const char *uuid);

View File

@@ -28,7 +28,6 @@
#include "optgroups.h"
GUESTFSD_EXT_CMD(str_dosfslabel, dosfslabel);
GUESTFSD_EXT_CMD(str_ntfslabel, ntfslabel);
GUESTFSD_EXT_CMD(str_xfs_admin, xfs_admin);
static int
@@ -46,25 +45,6 @@ dosfslabel (const char *device, const char *label)
return 0;
}
static int
ntfslabel (const char *device, const char *label)
{
int r;
CLEANUP_FREE char *err = NULL;
/* XXX We should check if the label is longer than 128 unicode
* characters and return an error. This is not so easy since we
* don't have the required libraries.
*/
r = command (NULL, &err, str_ntfslabel, device, label, NULL);
if (r == -1) {
reply_with_error ("%s", err);
return -1;
}
return 0;
}
static int
xfslabel (const char *device, const char *label)
{
@@ -116,7 +96,7 @@ do_set_label (const mountable_t *mountable, const char *label)
r = do_set_e2label (mountable->device, label);
else if (STREQ (vfs_type, "ntfs"))
r = ntfslabel (mountable->device, label);
r = ntfs_set_label (mountable->device, label);
else if (STREQ (vfs_type, "xfs"))
r = xfslabel (mountable->device, label);

View File

@@ -70,6 +70,25 @@ ntfs_get_label (const char *device)
return out;
}
int
ntfs_set_label (const char *device, const char *label)
{
int r;
CLEANUP_FREE char *err = NULL;
/* XXX We should check if the label is longer than 128 unicode
* characters and return an error. This is not so easy since we
* don't have the required libraries.
*/
r = command (NULL, &err, str_ntfslabel, device, label, NULL);
if (r == -1) {
reply_with_error ("%s", err);
return -1;
}
return 0;
}
int
do_ntfs_3g_probe (int rw, const char *device)
{