gparted/include/btrfs.h

59 lines
2.1 KiB
C
Raw Normal View History

/* Copyright (C) 2009,2010 Luca Bruno <lucab@debian.org>
* Copyright (C) 2010 Curtis Gedak
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GPARTED_BTRFS_H
#define GPARTED_BTRFS_H
#include "../include/FileSystem.h"
namespace GParted
{
struct BTRFS_Device
{
int devid ;
std::vector<Glib::ustring> members ;
} ;
class btrfs : public FileSystem
{
public:
FS get_filesystem_support() ;
void set_used_sectors( Partition & partition ) ;
Detect busy status of multi-device btrfs file systems (#723842) Busy detection of file systems works by checking if the device is mounted (appears in the mount_info map). For a multi-device btrfs file system this will only report one of the devices as busy, not all of them. # btrfs filesystem show /dev/sdb1 Label: none uuid: 36eb51a2-2927-4c92-820f-b2f0b5cdae50 Total devices 2 FS bytes used 156.00KB devid 2 size 2.00GB used 512.00MB path /dev/sdb2 devid 1 size 2.00GB used 240.75MB path /dev/sdb1 # mount /dev/sdb1 /mnt/1 # grep btrfs /proc/mounts /dev/sdb1 /mnt/1 btrfs rw,seclabel,relatime,ssd,space_cache 0 0 GParted will only report /dev/sdb1 as busy, but not /dev/sdb2. Add btrfs specific is_busy() method which reports the device as busy if any of the devices in the btrfs file system are mounted. This uses a cache which maps device membership in all btrfs file systems. The cache is cleared on GParted refresh and incrementally populated as each btrfs partition is checked for busy status. WARNING: Removal of the mounting device from a btrfs file system makes it impossible to determine whether the file system is mounted or not for linux <= 3.4. This is because /proc/mounts continues to show the old device which is no longer a member of the file system. # btrfs device delete /dev/sdb1 /mnt/1 # sync # grep btrfs /proc/mounts /dev/sdb1 /mnt/1 btrfs rw,seclabel,relatime,ssd,space_cache 0 0 # btrfs filesystem show /dev/sdb1 # btrfs filesystem show /dev/sdb2 Label: none uuid: 36eb51a2-2927-4c92-820f-b2f0b5cdae50 Total devices 1 FS bytes used 28.00KB devid 2 size 2.00GB used 1.02GB path /dev/sdb2 Fixed in linux 3.5 by commit: Btrfs: implement ->show_devname https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=9c5085c147989d48dfe74194b48affc23f376650 Bug #723842 - GParted resizes the wrong filesystem (does not pass the devid to btrfs filesystem resize)
2014-02-17 15:39:34 -07:00
bool is_busy( const Glib::ustring & path ) ;
void read_label( Partition & partition ) ;
bool write_label( const Partition & partition, OperationDetail & operationdetail ) ;
void read_uuid( Partition & partition ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool check_repair( const Partition & partition, OperationDetail & operationdetail ) ;
Detect busy status of multi-device btrfs file systems (#723842) Busy detection of file systems works by checking if the device is mounted (appears in the mount_info map). For a multi-device btrfs file system this will only report one of the devices as busy, not all of them. # btrfs filesystem show /dev/sdb1 Label: none uuid: 36eb51a2-2927-4c92-820f-b2f0b5cdae50 Total devices 2 FS bytes used 156.00KB devid 2 size 2.00GB used 512.00MB path /dev/sdb2 devid 1 size 2.00GB used 240.75MB path /dev/sdb1 # mount /dev/sdb1 /mnt/1 # grep btrfs /proc/mounts /dev/sdb1 /mnt/1 btrfs rw,seclabel,relatime,ssd,space_cache 0 0 GParted will only report /dev/sdb1 as busy, but not /dev/sdb2. Add btrfs specific is_busy() method which reports the device as busy if any of the devices in the btrfs file system are mounted. This uses a cache which maps device membership in all btrfs file systems. The cache is cleared on GParted refresh and incrementally populated as each btrfs partition is checked for busy status. WARNING: Removal of the mounting device from a btrfs file system makes it impossible to determine whether the file system is mounted or not for linux <= 3.4. This is because /proc/mounts continues to show the old device which is no longer a member of the file system. # btrfs device delete /dev/sdb1 /mnt/1 # sync # grep btrfs /proc/mounts /dev/sdb1 /mnt/1 btrfs rw,seclabel,relatime,ssd,space_cache 0 0 # btrfs filesystem show /dev/sdb1 # btrfs filesystem show /dev/sdb2 Label: none uuid: 36eb51a2-2927-4c92-820f-b2f0b5cdae50 Total devices 1 FS bytes used 28.00KB devid 2 size 2.00GB used 1.02GB path /dev/sdb2 Fixed in linux 3.5 by commit: Btrfs: implement ->show_devname https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=9c5085c147989d48dfe74194b48affc23f376650 Bug #723842 - GParted resizes the wrong filesystem (does not pass the devid to btrfs filesystem resize)
2014-02-17 15:39:34 -07:00
static void clear_cache() ;
static Glib::ustring get_mount_device( const Glib::ustring & path ) ;
static std::vector<Glib::ustring> get_members( const Glib::ustring & path ) ;
Detect busy status of multi-device btrfs file systems (#723842) Busy detection of file systems works by checking if the device is mounted (appears in the mount_info map). For a multi-device btrfs file system this will only report one of the devices as busy, not all of them. # btrfs filesystem show /dev/sdb1 Label: none uuid: 36eb51a2-2927-4c92-820f-b2f0b5cdae50 Total devices 2 FS bytes used 156.00KB devid 2 size 2.00GB used 512.00MB path /dev/sdb2 devid 1 size 2.00GB used 240.75MB path /dev/sdb1 # mount /dev/sdb1 /mnt/1 # grep btrfs /proc/mounts /dev/sdb1 /mnt/1 btrfs rw,seclabel,relatime,ssd,space_cache 0 0 GParted will only report /dev/sdb1 as busy, but not /dev/sdb2. Add btrfs specific is_busy() method which reports the device as busy if any of the devices in the btrfs file system are mounted. This uses a cache which maps device membership in all btrfs file systems. The cache is cleared on GParted refresh and incrementally populated as each btrfs partition is checked for busy status. WARNING: Removal of the mounting device from a btrfs file system makes it impossible to determine whether the file system is mounted or not for linux <= 3.4. This is because /proc/mounts continues to show the old device which is no longer a member of the file system. # btrfs device delete /dev/sdb1 /mnt/1 # sync # grep btrfs /proc/mounts /dev/sdb1 /mnt/1 btrfs rw,seclabel,relatime,ssd,space_cache 0 0 # btrfs filesystem show /dev/sdb1 # btrfs filesystem show /dev/sdb2 Label: none uuid: 36eb51a2-2927-4c92-820f-b2f0b5cdae50 Total devices 1 FS bytes used 28.00KB devid 2 size 2.00GB used 1.02GB path /dev/sdb2 Fixed in linux 3.5 by commit: Btrfs: implement ->show_devname https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=9c5085c147989d48dfe74194b48affc23f376650 Bug #723842 - GParted resizes the wrong filesystem (does not pass the devid to btrfs filesystem resize)
2014-02-17 15:39:34 -07:00
private:
static const BTRFS_Device & get_cache_entry( const Glib::ustring & path ) ;
static Byte_Value btrfs_size_to_num( Glib::ustring str, Byte_Value ptn_bytes, bool scale_up ) ;
static gdouble btrfs_size_max_delta( Glib::ustring str ) ;
static gdouble btrfs_size_to_gdouble( Glib::ustring str ) ;
};
} //GParted
#endif /* GPARTED_BTRFS_H */