Commit Graph

18 Commits (master)

Author SHA1 Message Date
David Sterba c6d00c3f00 btrfs-progs: props: convert to C99 initializers
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-26 17:46:42 +02:00
David Sterba c9da5695b2 btrfs-progs: props: update descriptions
Drop 'set/get' and update descriptions.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-26 17:46:42 +02:00
David Sterba c07960c8be btrfs-progs: move utils.[ch] to common/
Update include paths and remove some duplicates.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-03 20:49:04 +02:00
David Sterba aac564aca6 btrfs-progs: move commonh to common/
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-03 20:49:03 +02:00
David Sterba e578b59bf6 btrfs-progs: convert strerror to implicit %m
Similar to the changes where strerror(errno) was converted, continue
with the remaining cases where the argument was stored in another
variable.

The savings in object size are about 4500 bytes:

 $ size btrfs.old btrfs.new
   text    data     bss     dec     hex filename
 805055   24248   19748  849051   cf49b btrfs.old
 804527   24248   19748  848523   cf28b btrfs.new

Signed-off-by: David Sterba <dsterba@suse.com>
2018-10-31 18:24:14 +01:00
Omar Sandoval 3e76e9b676 btrfs-progs: use libbtrfsutil for read-only property
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-03-06 11:28:37 +01:00
David Sterba c0f7e29127 btrfs-progs: prop: also allow "none" to disable compression
Some people were asking why disabling compression via properties is not
set by "none" instead. As this is purely userspace conversion to "" that
kernel accepts, let's add "none" as well for convenience.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-11-14 15:59:00 +01:00
Satoru Takeuchi df11e2787b btrfs-progs: allow "no" to disable compression for convenience
It's messy to use "" to disable compression. Introduce the new value "no"
which can also be used for this purpose.

Signed-off-by: Satoru Takeuchi <satoru.takeuchi@gmail.com>
[ coding style fixes ]
Signed-off-by: David Sterba <dsterba@suse.com>
2017-11-14 15:59:00 +01:00
Satoru Takeuchi ece1cef709 btrfs-progs: prop: convert error messages to use error()
props.c uses 'fprintf(stderr, "ERROR: ...")' as its error messages,
however we have generic error() function.

Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-11 16:37:12 +02:00
Byongho Lee 83d0a1727b btrfs-progs: use NULL instead of 0
Fix the code assigning 0 to pointer instead of NULL.

Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12 15:01:05 +01:00
Qu Wenruo 0c8b978881 btrfs-progs: Introduce change_header_uuid function
This function is used to change fsid and chunk_tree_uuid of a node/leaf.
The function does it without transaction protection.

This is the basis of offline uuid change.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-05-14 15:41:07 +02:00
David Sterba 7560f46ea9 btrfs-progs: use system attr instead of attr library
We use the attr version provided by system in other places already,
now we can remove dependency on the separate attr library.

Signed-off-by: David Sterba <dsterba@suse.cz>
2014-11-19 14:42:17 +01:00
Liu Bo 21a1ff8887 Btrfs-progs: set string end sing '\0' for property
Set string "xattr_name" 's end with '\0' so that it won't be
violated in memory.

With this fix, xfstest/btrfs/048 can pass on my box.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: Filipe Manana <fdmanana@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-05-02 17:05:37 +02:00
Filipe David Borba Manana 1e6195885b Btrfs-progs: allow compression property gets for read-only subvolumes
Because the function open_file_or_dir() always opened the input file in
read/write mode (O_RDWR), we were not able to due a compression property
get against a file living in a read-only subvolume/snapshot.
Fix this by opening the file with O_RDONLY mode if we're doing a property
get.

Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Reviewed-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-05-02 17:03:21 +02:00
Qu Wenruo 802ed8c352 btrfs-progs: Fix the return value when executing 'btrfs prop get' on an uncompressed file
When executing 'btrfs prop get' on a file which is not compressed, return
value will always be 50 since prop_compress() return -ENOATTR.

But the codes have already check the errno to avoid unnecessary error
message, so the return value should also set to 0.

Signed-off-by: Qu Wenruo <quwenro@cn.fujitsu.com>
Reviewed-by: Filipe Manana <fdmanana@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-04-22 14:35:15 +02:00
Filipe David Borba Manana e32205997f Btrfs-progs: add support for the compression property
With this property, one can enable compression for individual files
without the need to mount the filesystem with the compress or
compress-force options, and specify the compression algorithm.

When applied against a directory, files created under that directory
will inherit the compression property.

This requires the corresponding kernel patch, which adds the support
for setting and getting properties and implements the compression
property.

Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
2014-01-31 08:22:33 -08:00
Filipe David Borba Manana aea9789800 Btrfs-progs: add type root to label property
So that we can get the label of a mounted filesystem.

Before this change:

        $ btrfs prop get /mnt/btrfs label
        ERROR: object is not compatible with property

        $ btrfs prop get /dev/sdb3 label
        ERROR: dev /dev/sdb3 is mounted, use mount point
        ERROR: failed to set/get property for object.

After this change:

        $ btrfs prop get /mnt/btrfs label
        label=foobar

Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
2014-01-31 08:22:32 -08:00
Alexander Block 85be2aaf91 Btrfs-progs: introduce btrfs property subgroup
"btrfs filesystem property" is a generic interface to set/get
properties on filesystem objects (inodes/subvolumes/filesystems
/devs).

This patch adds the generic framework for properties and also
implements two properties. The first is the read-only property
for subvolumes and the second is the label property for devices.

Signed-off-by: Alexander Block <ablock84@googlemail.com>
Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
2014-01-31 08:22:31 -08:00