2021-09-06 14:23:14 +00:00
|
|
|
/*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public
|
|
|
|
* License v2 as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* 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, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 021110-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2019-07-01 22:42:23 +00:00
|
|
|
#ifndef __DEVICE_SCAN_H__
|
|
|
|
#define __DEVICE_SCAN_H__
|
|
|
|
|
|
|
|
#include "kerncompat.h"
|
2021-04-29 17:52:15 +00:00
|
|
|
#include <dirent.h>
|
2023-08-28 20:12:13 +00:00
|
|
|
#include "kernel-lib/bitops.h"
|
2023-04-19 21:17:12 +00:00
|
|
|
#include "kernel-shared/uapi/btrfs.h"
|
2019-07-01 22:42:23 +00:00
|
|
|
|
|
|
|
#define BTRFS_SCAN_MOUNTED (1ULL << 0)
|
|
|
|
#define BTRFS_SCAN_LBLKID (1ULL << 1)
|
|
|
|
|
|
|
|
#define BTRFS_UPDATE_KERNEL 1
|
|
|
|
|
|
|
|
#define BTRFS_ARG_UNKNOWN 0
|
|
|
|
#define BTRFS_ARG_MNTPOINT 1
|
|
|
|
#define BTRFS_ARG_UUID 2
|
|
|
|
#define BTRFS_ARG_BLKDEV 3
|
|
|
|
#define BTRFS_ARG_REG 4
|
|
|
|
|
|
|
|
#define SEEN_FSID_HASH_SIZE 256
|
|
|
|
|
|
|
|
struct btrfs_root;
|
|
|
|
struct btrfs_trans_handle;
|
|
|
|
|
|
|
|
struct seen_fsid {
|
|
|
|
u8 fsid[BTRFS_FSID_SIZE];
|
|
|
|
struct seen_fsid *next;
|
|
|
|
DIR *dirstream;
|
|
|
|
int fd;
|
|
|
|
};
|
|
|
|
|
2019-11-25 10:39:15 +00:00
|
|
|
int btrfs_scan_devices(int verbose);
|
2023-06-13 10:26:56 +00:00
|
|
|
int btrfs_scan_argv_devices(int dev_optind, int argc, char **argv);
|
2019-07-01 22:42:23 +00:00
|
|
|
int btrfs_register_one_device(const char *fname);
|
|
|
|
int btrfs_register_all_devices(void);
|
|
|
|
int btrfs_add_to_fsid(struct btrfs_trans_handle *trans,
|
|
|
|
struct btrfs_root *root, int fd, const char *path,
|
|
|
|
u64 device_total_bytes, u32 io_width, u32 io_align,
|
|
|
|
u32 sectorsize);
|
|
|
|
int btrfs_device_already_in_root(struct btrfs_root *root, int fd,
|
|
|
|
int super_offset);
|
|
|
|
int is_seen_fsid(u8 *fsid, struct seen_fsid *seen_fsid_hash[]);
|
|
|
|
int add_seen_fsid(u8 *fsid, struct seen_fsid *seen_fsid_hash[],
|
|
|
|
int fd, DIR *dirstream);
|
|
|
|
void free_seen_fsid(struct seen_fsid *seen_fsid_hash[]);
|
2021-09-21 13:38:19 +00:00
|
|
|
int test_uuid_unique(const char *uuid_str);
|
2019-07-01 22:42:23 +00:00
|
|
|
|
|
|
|
#endif
|