Skip to content

Commit

Permalink
Allow user to specify new filesystem label or UUID during restfs
Browse files Browse the repository at this point in the history
  • Loading branch information
fdupoux committed Aug 9, 2016
1 parent c6ba47f commit 992021c
Show file tree
Hide file tree
Showing 21 changed files with 103 additions and 49 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ fsarchiver: Filesystem Archiver for Linux [http://www.fsarchiver.org]
=====================================================================
* 0.8.0
- Implemented FAT filesystem support for EFI system partitions
- Allow user to specify new filesystem label or UUID during restfs
* 0.6.24 (2016-08-07):
- Updated man page and description of the commands and options
- Support for sparse inode chunks on XFS v5
Expand Down
6 changes: 5 additions & 1 deletion doc/fsarchiver.8
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ https://github.com/fdupoux/fsarchiver/issues
.I options
.B ] restfs
.I archive
.BI id= n ,dest= device [,mkfs= fstype [,mkfsopt= options ]]
.BI id= n ,dest= device [,mkfs= fstype ,mkfsopt= options ,label= newlabel ,uuid= newuuid ]
.B ...
.PP
.B fsarchiver [
Expand Down Expand Up @@ -182,6 +182,10 @@ fsarchiver restfs /data/arch2.fsa id=0,dest=/dev/sda1 id=1,dest=/dev/sdb1
fsarchiver restfs /data/myarchive1.fsa id=0,dest=/dev/sda1,mkfs=reiserfs
.SS restore a filesystem from an archive and specify extra mkfs options:
fsarchiver restfs /data/myarchive1.fsa id=0,dest=/dev/sda1,mkfs=ext4,mkfsopt="-I 256"
.SS restore a filesystem from an archive and specify a new filesystem label:
fsarchiver restfs /data/myarchive1.fsa id=0,dest=/dev/sda1,label=root
.SS restore a filesystem from an archive and specify a new filesystem UUID:
fsarchiver restfs /data/myarchive1.fsa id=0,dest=/dev/sda1,uuid=5f6e5f4f-dc2a-4dbd-a6ea-9ca997cde75e
.SS save the contents of /usr/src/linux to an archive (similar to tar):
fsarchiver savedir /data/linux-sources.fsa /usr/src/linux
.SS save a filesystem (/dev/sda1) to an archive split into volumes of 680MB:
Expand Down
2 changes: 1 addition & 1 deletion src/filesys.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct s_filesys
int (*mount)(char *partition, char *mntbuf, char *fsname, int flags, char *mntinfo);
int (*umount)(char *partition, char *mntbuf);
int (*getinfo)(struct s_dico *d, char *devname);
int (*mkfs)(struct s_dico *d, char *partition, char *fsoptions);
int (*mkfs)(struct s_dico *d, char *partition, char *fsoptions, char *mkfslabel, char *mkfsuuid);
int (*test)(char *partition);
int (*reqmntopt)(char *partition, struct s_strlist *reqopt, struct s_strlist *badopt);
bool support_for_xattr;
Expand Down
13 changes: 10 additions & 3 deletions src/fs_btrfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ int btrfs_check_compatibility(u64 compat, u64 incompat, u64 ro_compat)
return 0;
}

int btrfs_mkfs(cdico *d, char *partition, char *fsoptions)
int btrfs_mkfs(cdico *d, char *partition, char *fsoptions, char *mkfslabel, char *mkfsuuid)
{
char command[2048];
char buffer[2048];
Expand Down Expand Up @@ -88,9 +88,16 @@ int btrfs_mkfs(cdico *d, char *partition, char *fsoptions)

strlcatf(options, sizeof(options), " %s ", fsoptions);

if (dico_get_string(d, 0, FSYSHEADKEY_FSLABEL, buffer, sizeof(buffer))==0 && strlen(buffer)>0)
if (strlen(mkfslabel) > 0)
strlcatf(options, sizeof(options), " -L '%s' ", mkfslabel);
else if (dico_get_string(d, 0, FSYSHEADKEY_FSLABEL, buffer, sizeof(buffer))==0 && strlen(buffer)>0)
strlcatf(options, sizeof(options), " -L '%s' ", buffer);


if (strlen(mkfsuuid) > 0)
strlcatf(options, sizeof(options), " -U '%s' ", mkfsuuid);
else if (dico_get_string(d, 0, FSYSHEADKEY_FSUUID, buffer, sizeof(buffer))==0)
strlcatf(options, sizeof(options), " -U '%s' ", buffer);

if (dico_get_u64(d, 0, FSYSHEADKEY_FSBTRFSSECTORSIZE, &temp64)==0)
strlcatf(options, sizeof(options), " -s %ld ", (long)temp64);

Expand Down
2 changes: 1 addition & 1 deletion src/fs_btrfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
struct s_dico;
struct s_strlist;

int btrfs_mkfs(struct s_dico *d, char *partition, char *fsoptions);
int btrfs_mkfs(struct s_dico *d, char *partition, char *fsoptions, char *mkfslabel, char *mkfsuuid);
int btrfs_getinfo(struct s_dico *d, char *devname);
int btrfs_mount(char *partition, char *mntbuf, char *fsbuf, int flags, char *mntinfo);
int btrfs_umount(char *partition, char *mntbuf);
Expand Down
22 changes: 13 additions & 9 deletions src/fs_ext2.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,19 @@ char *format_fstype(int fstype)
}
}

int ext2_mkfs(cdico *d, char *partition, char *fsoptions)
int ext2_mkfs(cdico *d, char *partition, char *fsoptions, char *mkfslabel, char *mkfsuuid)
{
return extfs_mkfs(d, partition, EXTFSTYPE_EXT2, fsoptions);
return extfs_mkfs(d, partition, EXTFSTYPE_EXT2, fsoptions, mkfslabel, mkfsuuid);
}

int ext3_mkfs(cdico *d, char *partition, char *fsoptions)
int ext3_mkfs(cdico *d, char *partition, char *fsoptions, char *mkfslabel, char *mkfsuuid)
{
return extfs_mkfs(d, partition, EXTFSTYPE_EXT3, fsoptions);
return extfs_mkfs(d, partition, EXTFSTYPE_EXT3, fsoptions, mkfslabel, mkfsuuid);
}

int ext4_mkfs(cdico *d, char *partition, char *fsoptions)
int ext4_mkfs(cdico *d, char *partition, char *fsoptions, char *mkfslabel, char *mkfsuuid)
{
return extfs_mkfs(d, partition, EXTFSTYPE_EXT4, fsoptions);
return extfs_mkfs(d, partition, EXTFSTYPE_EXT4, fsoptions, mkfslabel, mkfsuuid);
}

int extfs_get_fstype_from_compat_flags(u32 compat, u32 incompat, u32 ro_compat)
Expand Down Expand Up @@ -137,7 +137,7 @@ int extfs_check_compatibility(u64 compat, u64 incompat, u64 ro_compat)
return 0;
}

int extfs_mkfs(cdico *d, char *partition, int extfstype, char *fsoptions)
int extfs_mkfs(cdico *d, char *partition, int extfstype, char *fsoptions, char *mkfslabel, char *mkfsuuid)
{
cstrlist strfeatures;
u64 features_tab[3];
Expand Down Expand Up @@ -185,7 +185,9 @@ int extfs_mkfs(cdico *d, char *partition, int extfstype, char *fsoptions)
strlcatf(options, sizeof(options), " %s ", fsoptions);

// ---- set the advanced filesystem settings from the dico
if (dico_get_string(d, 0, FSYSHEADKEY_FSLABEL, buffer, sizeof(buffer))==0 && strlen(buffer)>0)
if (strlen(mkfslabel) > 0)
strlcatf(options, sizeof(options), " -L '%.16s' ", mkfslabel);
else if (dico_get_string(d, 0, FSYSHEADKEY_FSLABEL, buffer, sizeof(buffer))==0 && strlen(buffer)>0)
strlcatf(options, sizeof(options), " -L '%.16s' ", buffer);

if (dico_get_u64(d, 0, FSYSHEADKEY_FSEXTBLOCKSIZE, &temp64)==0)
Expand Down Expand Up @@ -288,7 +290,9 @@ int extfs_mkfs(cdico *d, char *partition, int extfstype, char *fsoptions)

// ---- use tune2fs to set the other advanced options
memset(options, 0, sizeof(options));
if (dico_get_string(d, 0, FSYSHEADKEY_FSUUID, buffer, sizeof(buffer))==0 && strlen(buffer)==36)
if (strlen(mkfsuuid) > 0)
strlcatf(options, sizeof(options), " -U %s ", mkfsuuid);
else if (dico_get_string(d, 0, FSYSHEADKEY_FSUUID, buffer, sizeof(buffer))==0 && strlen(buffer)==36)
strlcatf(options, sizeof(options), " -U %s ", buffer);

if (dico_get_string(d, 0, FSYSHEADKEY_FSEXTDEFMNTOPT, buffer, sizeof(buffer))==0 && strlen(buffer)>0)
Expand Down
8 changes: 4 additions & 4 deletions src/fs_ext2.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ struct s_strlist;

enum {EXTFSTYPE_EXT2, EXTFSTYPE_EXT3, EXTFSTYPE_EXT4};

int ext2_mkfs(struct s_dico *d, char *partition, char *fsoptions);
int ext3_mkfs(struct s_dico *d, char *partition, char *fsoptions);
int ext4_mkfs(struct s_dico *d, char *partition, char *fsoptions);
int ext2_mkfs(struct s_dico *d, char *partition, char *fsoptions, char *mkfslabel, char *mkfsuuid);
int ext3_mkfs(struct s_dico *d, char *partition, char *fsoptions, char *mkfslabel, char *mkfsuuid);
int ext4_mkfs(struct s_dico *d, char *partition, char *fsoptions, char *mkfslabel, char *mkfsuuid);
int extfs_getinfo(struct s_dico *d, char *devname);
int extfs_get_fstype_from_compat_flags(u32 compat, u32 incompat, u32 ro_compat);
int extfs_get_reqmntopt(char *partition, struct s_strlist *reqopt, struct s_strlist *badopt);
int extfs_mkfs(struct s_dico *d, char *partition, int extfstype, char *fsoptions);
int extfs_mkfs(struct s_dico *d, char *partition, int extfstype, char *fsoptions, char *mkfslabel, char *mkfsuuid);
int extfs_mount(char *partition, char *mntbuf, char *fsbuf, int flags, char *mntinfo);
int extfs_umount(char *partition, char *mntbuf);
int extfs_test(char *partition, int extfstype);
Expand Down
10 changes: 7 additions & 3 deletions src/fs_jfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "strlist.h"
#include "error.h"

int jfs_mkfs(cdico *d, char *partition, char *fsoptions)
int jfs_mkfs(cdico *d, char *partition, char *fsoptions, char *mkfslabel, char *mkfsuuid)
{
char command[2048];
char buffer[2048];
Expand All @@ -53,7 +53,9 @@ int jfs_mkfs(cdico *d, char *partition, char *fsoptions)

strlcatf(options, sizeof(options), " %s ", fsoptions);

if (dico_get_string(d, 0, FSYSHEADKEY_FSLABEL, buffer, sizeof(buffer))==0 && strlen(buffer)>0)
if (strlen(mkfslabel) > 0)
strlcatf(options, sizeof(options), " -L '%s' ", mkfslabel);
else if (dico_get_string(d, 0, FSYSHEADKEY_FSLABEL, buffer, sizeof(buffer))==0 && strlen(buffer)>0)
strlcatf(options, sizeof(options), " -L '%s' ", buffer);

if (exec_command(command, sizeof(command), &exitst, NULL, 0, NULL, 0, "mkfs.jfs -q %s %s", options, partition)!=0 || exitst!=0)
Expand All @@ -63,7 +65,9 @@ int jfs_mkfs(cdico *d, char *partition, char *fsoptions)

// ---- use jfs_tune to set the other advanced options
memset(options, 0, sizeof(options));
if (dico_get_string(d, 0, FSYSHEADKEY_FSUUID, buffer, sizeof(buffer))==0 && strlen(buffer)==36)
if (strlen(mkfsuuid) > 0)
strlcatf(options, sizeof(options), " -U %s ", mkfsuuid);
else if (dico_get_string(d, 0, FSYSHEADKEY_FSUUID, buffer, sizeof(buffer))==0 && strlen(buffer)==36)
strlcatf(options, sizeof(options), " -U %s ", buffer);

if (options[0])
Expand Down
2 changes: 1 addition & 1 deletion src/fs_jfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
struct s_dico;
struct s_strlist;

int jfs_mkfs(struct s_dico *d, char *partition, char *fsoptions);
int jfs_mkfs(struct s_dico *d, char *partition, char *fsoptions, char *mkfslabel, char *mkfsuuid);
int jfs_getinfo(struct s_dico *d, char *devname);
int jfs_mount(char *partition, char *mntbuf, char *fsbuf, int flags, char *mntinfo);
int jfs_get_reqmntopt(char *partition, struct s_strlist *reqopt, struct s_strlist *badopt);
Expand Down
6 changes: 4 additions & 2 deletions src/fs_ntfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "strlist.h"
#include "error.h"

int ntfs_mkfs(cdico *d, char *partition, char *fsoptions)
int ntfs_mkfs(cdico *d, char *partition, char *fsoptions, char *mkfslabel, char *mkfsuuid)
{
char command[2048];
char buffer[2048];
Expand All @@ -55,7 +55,9 @@ int ntfs_mkfs(cdico *d, char *partition, char *fsoptions)

strlcatf(options, sizeof(options), " %s ", fsoptions);

if (dico_get_string(d, 0, FSYSHEADKEY_FSLABEL, buffer, sizeof(buffer))==0 && strlen(buffer)>0)
if (strlen(mkfslabel) > 0)
strlcatf(options, sizeof(options), " --label '%s' ", mkfslabel);
else if (dico_get_string(d, 0, FSYSHEADKEY_FSLABEL, buffer, sizeof(buffer))==0 && strlen(buffer)>0)
strlcatf(options, sizeof(options), " --label '%s' ", buffer);

if (dico_get_u16(d, 0, FSYSHEADKEY_NTFSSECTORSIZE, &temp16)==0)
Expand Down
2 changes: 1 addition & 1 deletion src/fs_ntfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct s_ntfsinfo
u64 uuid;
};

int ntfs_mkfs(struct s_dico *d, char *partition, char *fsoptions);
int ntfs_mkfs(struct s_dico *d, char *partition, char *fsoptions, char *mkfslabel, char *mkfsuuid);
int ntfs_getinfo(struct s_dico *d, char *devname);
int ntfs_mount(char *partition, char *mntbuf, char *fsbuf, int flags, char *mntinfo);
int ntfs_get_reqmntopt(char *partition, struct s_strlist *reqopt, struct s_strlist *badopt);
Expand Down
10 changes: 7 additions & 3 deletions src/fs_reiser4.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "strlist.h"
#include "error.h"

int reiser4_mkfs(cdico *d, char *partition, char *fsoptions)
int reiser4_mkfs(cdico *d, char *partition, char *fsoptions, char *mkfslabel, char *mkfsuuid)
{
char command[2048];
char buffer[2048];
Expand All @@ -54,13 +54,17 @@ int reiser4_mkfs(cdico *d, char *partition, char *fsoptions)

strlcatf(options, sizeof(options), " %s ", fsoptions);

if (dico_get_string(d, 0, FSYSHEADKEY_FSLABEL, buffer, sizeof(buffer))==0 && strlen(buffer)>0)
if (strlen(mkfslabel) > 0)
strlcatf(options, sizeof(options), " -L '%.16s' ", mkfslabel);
else if (dico_get_string(d, 0, FSYSHEADKEY_FSLABEL, buffer, sizeof(buffer))==0 && strlen(buffer)>0)
strlcatf(options, sizeof(options), " -L '%.16s' ", buffer);

if (dico_get_u64(d, 0, FSYSHEADKEY_FSREISER4BLOCKSIZE, &temp64)==0)
strlcatf(options, sizeof(options), " -b %ld ", (long)temp64);

if (dico_get_string(d, 0, FSYSHEADKEY_FSUUID, buffer, sizeof(buffer))==0 && strlen(buffer)==36)
if (strlen(mkfsuuid) > 0)
strlcatf(options, sizeof(options), " -U %s ", mkfsuuid);
else if (dico_get_string(d, 0, FSYSHEADKEY_FSUUID, buffer, sizeof(buffer))==0 && strlen(buffer)==36)
strlcatf(options, sizeof(options), " -U %s ", buffer);

if (exec_command(command, sizeof(command), &exitst, NULL, 0, NULL, 0, "mkfs.reiser4 -y %s %s", partition, options)!=0 || exitst!=0)
Expand Down
2 changes: 1 addition & 1 deletion src/fs_reiser4.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
struct s_dico;
struct s_strlist;

int reiser4_mkfs(struct s_dico *d, char *partition, char *fsoptions);
int reiser4_mkfs(struct s_dico *d, char *partition, char *fsoptions, char *mkfslabel, char *mkfsuuid);
int reiser4_getinfo(struct s_dico *d, char *devname);
int reiser4_mount(char *partition, char *mntbuf, char *fsbuf, int flags, char *mntinfo);
int reiser4_get_reqmntopt(char *partition, struct s_strlist *reqopt, struct s_strlist *badopt);
Expand Down
10 changes: 7 additions & 3 deletions src/fs_reiserfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "strlist.h"
#include "error.h"

int reiserfs_mkfs(cdico *d, char *partition, char *fsoptions)
int reiserfs_mkfs(cdico *d, char *partition, char *fsoptions, char *mkfslabel, char *mkfsuuid)
{
char command[2048];
char buffer[2048];
Expand All @@ -54,13 +54,17 @@ int reiserfs_mkfs(cdico *d, char *partition, char *fsoptions)

strlcatf(options, sizeof(options), " %s ", fsoptions);

if (dico_get_string(d, 0, FSYSHEADKEY_FSLABEL, buffer, sizeof(buffer))==0 && strlen(buffer)>0)
if (strlen(mkfslabel) > 0)
strlcatf(options, sizeof(options), " -l '%.16s' ", mkfslabel);
else if (dico_get_string(d, 0, FSYSHEADKEY_FSLABEL, buffer, sizeof(buffer))==0 && strlen(buffer)>0)
strlcatf(options, sizeof(options), " -l '%.16s' ", buffer);

if (dico_get_u64(d, 0, FSYSHEADKEY_FSREISERBLOCKSIZE, &temp64)==0)
strlcatf(options, sizeof(options), " -b %ld ", (long)temp64);

if (dico_get_string(d, 0, FSYSHEADKEY_FSUUID, buffer, sizeof(buffer))==0 && strlen(buffer)==36)
if (strlen(mkfsuuid) > 0)
strlcatf(options, sizeof(options), " -u %s ", mkfsuuid);
else if (dico_get_string(d, 0, FSYSHEADKEY_FSUUID, buffer, sizeof(buffer))==0 && strlen(buffer)==36)
strlcatf(options, sizeof(options), " -u %s ", buffer);

if (exec_command(command, sizeof(command), &exitst, NULL, 0, NULL, 0, "mkreiserfs -f %s %s", partition, options)!=0 || exitst!=0)
Expand Down
2 changes: 1 addition & 1 deletion src/fs_reiserfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
struct s_dico;
struct s_strlist;

int reiserfs_mkfs(struct s_dico *d, char *partition, char *fsoptions);
int reiserfs_mkfs(struct s_dico *d, char *partition, char *fsoptions, char *mkfslabel, char *mkfsuuid);
int reiserfs_getinfo(struct s_dico *d, char *devname);
int reiserfs_mount(char *partition, char *mntbuf, char *fsbuf, int flags, char *mntinfo);
int reiserfs_get_reqmntopt(char *partition, struct s_strlist *reqopt, struct s_strlist *badopt);
Expand Down
6 changes: 4 additions & 2 deletions src/fs_vfat.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "fs_vfat.h"
#include "error.h"

int vfat_mkfs(cdico *d, char *partition, char *fsoptions)
int vfat_mkfs(cdico *d, char *partition, char *fsoptions, char *mkfslabel, char *mkfsuuid)
{
char stdoutbuf[2048];
char command[2048];
Expand All @@ -59,7 +59,9 @@ int vfat_mkfs(cdico *d, char *partition, char *fsoptions)
strlcatf(mkfsopts, sizeof(mkfsopts), " -F 32 ");

// ---- filesystem label
if (dico_get_string(d, 0, FSYSHEADKEY_FSLABEL, buffer, sizeof(buffer))==0 && strlen(buffer)>0)
if (strlen(mkfslabel) > 0)
strlcatf(mkfsopts, sizeof(mkfsopts), " -n '%.11s' ", mkfslabel);
else if (dico_get_string(d, 0, FSYSHEADKEY_FSLABEL, buffer, sizeof(buffer))==0 && strlen(buffer)>0)
strlcatf(mkfsopts, sizeof(mkfsopts), " -n '%.11s' ", buffer);

// ---- filesystem serial
Expand Down
2 changes: 1 addition & 1 deletion src/fs_vfat.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
struct s_dico;
struct s_strlist;

int vfat_mkfs(struct s_dico *d, char *partition, char *fsoptions);
int vfat_mkfs(struct s_dico *d, char *partition, char *fsoptions, char *mkfslabel, char *mkfsuuid);
int vfat_getinfo(struct s_dico *d, char *devname);
int vfat_mount(char *partition, char *mntbuf, char *fsbuf, int flags, char *mntinfo);
int vfat_get_reqmntopt(char *partition, struct s_strlist *reqopt, struct s_strlist *badopt);
Expand Down
12 changes: 9 additions & 3 deletions src/fs_xfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ int xfs_check_compatibility(u64 compat, u64 ro_compat, u64 incompat, u64 log_inc
}
}

int xfs_mkfs(cdico *d, char *partition, char *fsoptions)
int xfs_mkfs(cdico *d, char *partition, char *fsoptions, char *mkfslabel, char *mkfsuuid)
{
char stdoutbuf[2048];
char command[2048];
Expand Down Expand Up @@ -105,7 +105,9 @@ int xfs_mkfs(cdico *d, char *partition, char *fsoptions)

strlcatf(mkfsopts, sizeof(mkfsopts), " %s ", fsoptions);

if (dico_get_string(d, 0, FSYSHEADKEY_FSLABEL, buffer, sizeof(buffer))==0 && strlen(buffer)>0)
if (strlen(mkfslabel) > 0)
strlcatf(mkfsopts, sizeof(mkfsopts), " -L '%.12s' ", mkfslabel);
else if (dico_get_string(d, 0, FSYSHEADKEY_FSLABEL, buffer, sizeof(buffer))==0 && strlen(buffer)>0)
strlcatf(mkfsopts, sizeof(mkfsopts), " -L '%.12s' ", buffer);

if ((dico_get_u64(d, 0, FSYSHEADKEY_FSXFSBLOCKSIZE, &temp64)==0) && (temp64%512==0) && (temp64>=512) && (temp64<=65536))
Expand Down Expand Up @@ -176,7 +178,11 @@ int xfs_mkfs(cdico *d, char *partition, char *fsoptions)
// - the UUID of XFSv4 can be successfully set using either xfs_admin or mkfs.xfs >= 4.3.0
// - it is impossible to set both types of UUIDs of an XFSv5 filesystem using xfsprogs < 4.3.0
// for this reason the XFS version is forced to v4 if xfsprogs version < 4.3.0
if (dico_get_string(d, 0, FSYSHEADKEY_FSUUID, uuid, sizeof(uuid))==0 && strlen(uuid)==36)
if (strlen(mkfsuuid) > 0)
snprintf(uuid, sizeof(uuid), "%s", mkfsuuid);
else if (dico_get_string(d, 0, FSYSHEADKEY_FSUUID, buffer, sizeof(buffer))==0)
snprintf(uuid, sizeof(uuid), "%s", buffer);
if (strlen(uuid)==36)
{
if (xfstoolsver >= PROGVER(4,3,0))
strlcatf(mkfsopts, sizeof(mkfsopts), " -m uuid=%s ", uuid);
Expand Down
2 changes: 1 addition & 1 deletion src/fs_xfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct s_strlist;
#define XFS_SB_VERSION_BORGBIT 0x4000 /* ASCII only case-insens. */
#define XFS_SB_VERSION_MOREBITSBIT 0x8000

int xfs_mkfs(struct s_dico *d, char *partition, char *fsoptions);
int xfs_mkfs(struct s_dico *d, char *partition, char *fsoptions, char *mkfslabel, char *mkfsuuid);
int xfs_getinfo(struct s_dico *d, char *devname);
int xfs_mount(char *partition, char *mntbuf, char *fsbuf, int flags, char *mntinfo);
int xfs_get_reqmntopt(char *partition, struct s_strlist *reqopt, struct s_strlist *badopt);
Expand Down
2 changes: 2 additions & 0 deletions src/fsarchiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ void usage(char *progname, bool examples)
msgprintf(MSG_FORCE, " fsarchiver restfs /data/myarchive1.fsa id=0,dest=/dev/sda1,mkfs=reiserfs\n");
msgprintf(MSG_FORCE, " * \e[1mrestore a filesystem from an archive and specify extra mkfs options:\e[0m\n");
msgprintf(MSG_FORCE, " fsarchiver restfs /data/myarchive1.fsa id=0,dest=/dev/sda1,mkfs=ext4,mkfsopt=\"-I 256\"\n");
msgprintf(MSG_FORCE, " * \e[1mrestore a filesystem from an archive and specify a new label and a new UUID:\e[0m\n");
msgprintf(MSG_FORCE, " fsarchiver restfs /data/myarchive1.fsa id=0,dest=/dev/sda1,label=root,uuid=5f6e5f4f-dc2a-4dbd-a6ea-9ca997cde75e\n");
msgprintf(MSG_FORCE, " * \e[1msave the contents of /usr/src/linux to an archive (similar to tar):\e[0m\n");
msgprintf(MSG_FORCE, " fsarchiver savedir /data/linux-sources.fsa /usr/src/linux\n");
msgprintf(MSG_FORCE, " * \e[1msave a filesystem (/dev/sda1) to an archive split into volumes of 680MB:\e[0m\n");
Expand Down
Loading

0 comments on commit 992021c

Please sign in to comment.