btrfsprogs/0164-btrfs-progs-convert-set-label-or-copy-from-origin.patch
David Sterba 3821ed946a Accepting request 246571 from home:dsterba:branches:filesystems
- version 3.16
  - show-super: skip unrecognized sb, add option to force
  - debug-tree: print tree by id
  - mkfs: new option to specify UUID
  - receive: new option to limit number of errors
  - check: new option to verify quotas
  - check: reduced memory requirements
  - check: new option to print extent sharing
  - restore: check length before decompression
  - restore: more error handling
  - balance: new filter 'limit'
  - recover: allow to read all sb copies
  - restore: option to loop during restoring
  - mkfs: drop experimental notice
  - btrfstune: new option to force dangerous changes
  - documentation updates
- Deleted patches (upstream):
  * 0001-btrfs-progs-doc-fix-symlink-target-for-btrfsck.8.patch
  * 0200-btrfs-progs-print-qgroup-excl-as-unsigned.patch
  * 0201-btrfs-progs-import-ulist.patch
  * 0202-btrfs-progs-add-quota-group-verify-code.patch
  * 0203-btrfs-progs-show-extent-state-for-a-subvolume.patch
  * 0204-btrfs-progs-ignore-orphaned-qgroups-by-default.patch
  * btrfs-progs-canonicalize-pathnames-for-device-commands
- Refreshed patches:
  * 0006-Btrfs-progs-fsck-clear-out-log-tree-in-repair-mode.patch
  * 0011-btrfs-progs-Enhance-the-command-btrfs-filesystem-df.patch
  * 0012-btrfs-progs-Add-helpers-functions-to-handle-the-prin.patch
  * 0013-btrfs-progs-Add-command-btrfs-filesystem-disk-usage.patch
  * 0028-btrfs-progs-extend-pretty-printers-with-unit-mode.patch
  * 0164-btrfs-progs-convert-set-label-or-copy-from-origin.patch

OBS-URL: https://build.opensuse.org/request/show/246571
OBS-URL: https://build.opensuse.org/package/show/filesystems/btrfsprogs?expand=0&rev=167
2014-08-26 18:51:30 +00:00

107 lines
3.3 KiB
Diff

From f160d979c4f8d46a9d0a52394240d51b78237d89 Mon Sep 17 00:00:00 2001
From: David Sterba <dsterba@suse.cz>
Date: Tue, 31 Jan 2012 14:40:22 +0100
Subject: [PATCH 164/170] btrfs-progs: convert: set label or copy from origin
Signed-off-by: David Sterba <dsterba@suse.cz>
---
btrfs-convert.c | 47 ++++++++++++++++++++++++++++++++++++++---------
1 file changed, 38 insertions(+), 9 deletions(-)
Index: btrfs-progs-v3.16/btrfs-convert.c
===================================================================
--- btrfs-progs-v3.16.orig/btrfs-convert.c
+++ btrfs-progs-v3.16/btrfs-convert.c
@@ -2196,8 +2196,8 @@ err:
return ret;
}
-static int do_convert(const char *devname, int datacsum, int packing,
- int noxattr)
+static int do_convert(const char *devname, int datacsum, int packing, int noxattr,
+ int copylabel, const char *fslabel)
{
int i, ret;
int fd = -1;
@@ -2291,6 +2291,17 @@ static int do_convert(const char *devnam
fprintf(stderr, "error during create_ext2_image %d\n", ret);
goto fail;
}
+ memset(root->fs_info->super_copy->label, 0, BTRFS_LABEL_SIZE);
+ if (copylabel == 1) {
+ strncpy(root->fs_info->super_copy->label,
+ ext2_fs->super->s_volume_name, 16);
+ fprintf(stderr, "copy label '%s'\n",
+ root->fs_info->super_copy->label);
+ } else if (copylabel == -1) {
+ strncpy(root->fs_info->super_copy->label, fslabel, BTRFS_LABEL_SIZE);
+ fprintf(stderr, "set label to '%s'\n", fslabel);
+ }
+
printf("cleaning up system chunk.\n");
ret = cleanup_sys_chunk(root, ext2_root);
if (ret) {
@@ -2685,11 +2696,13 @@ fail:
static void print_usage(void)
{
- printf("usage: btrfs-convert [-d] [-i] [-n] [-r] device\n");
- printf("\t-d disable data checksum\n");
- printf("\t-i ignore xattrs and ACLs\n");
- printf("\t-n disable packing of small files\n");
- printf("\t-r roll back to ext2fs\n");
+ printf("usage: btrfs-convert [-d] [-i] [-n] [-r] [-l label] [-L] device\n");
+ printf("\t-d disable data checksum\n");
+ printf("\t-i ignore xattrs and ACLs\n");
+ printf("\t-n disable packing of small files\n");
+ printf("\t-r roll back to ext2fs\n");
+ printf("\t-l LABEL set filesystem label\n");
+ printf("\t-L use label from converted fs\n");
}
int main(int argc, char *argv[])
@@ -2699,10 +2712,13 @@ int main(int argc, char *argv[])
int noxattr = 0;
int datacsum = 1;
int rollback = 0;
+ int copylabel = 0;
int usage_error = 0;
char *file;
+ char *fslabel = NULL;
+
while(1) {
- int c = getopt(argc, argv, "dinr");
+ int c = getopt(argc, argv, "dinrl:L");
if (c < 0)
break;
switch(c) {
@@ -2718,6 +2734,19 @@ int main(int argc, char *argv[])
case 'r':
rollback = 1;
break;
+ case 'l':
+ copylabel = -1;
+ fslabel = strdup(optarg);
+ if (strlen(fslabel) > BTRFS_LABEL_SIZE) {
+ fprintf(stderr,
+ "warning: label too long, trimmed to %d bytes\n",
+ BTRFS_LABEL_SIZE);
+ fslabel[BTRFS_LABEL_SIZE]=0;
+ }
+ break;
+ case 'L':
+ copylabel = 1;
+ break;
default:
print_usage();
return 1;
@@ -2755,7 +2784,7 @@ int main(int argc, char *argv[])
if (rollback) {
ret = do_rollback(file);
} else {
- ret = do_convert(file, datacsum, packing, noxattr);
+ ret = do_convert(file, datacsum, packing, noxattr, copylabel, fslabel);
}
if (ret)
return 1;