mirror of
https://github.com/linux-apfs/linux-apfs-rw.git
synced 2026-08-18 02:19:59 -07:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
af0671f58f | ||
|
|
740d7db44b | ||
|
|
bc2be91bb4 | ||
|
|
5c4773c036 | ||
|
|
1e3fa28c4f |
No files matched your search
+5
-2
@@ -36,8 +36,11 @@ static inline void *kvmalloc(size_t size, gfp_t flags)
|
||||
|
||||
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0) */
|
||||
|
||||
/* maximum size of compressed data currently supported */
|
||||
#define MAX_FBUF_SIZE (128 * 1024 * 1024)
|
||||
/*
|
||||
* Maximum size of compressed data currently supported. This is getting too
|
||||
* big already. TODO: avoid vmalloc().
|
||||
*/
|
||||
#define MAX_FBUF_SIZE (256 * 1024 * 1024)
|
||||
|
||||
struct apfs_compress_file_data {
|
||||
struct apfs_compress_hdr hdr;
|
||||
|
||||
@@ -268,7 +268,7 @@ static int apfs_build_dentry_unhashed_key(struct qstr *qname, u64 parent_id,
|
||||
|
||||
apfs_key_set_hdr(APFS_TYPE_DIR_REC, parent_id, key);
|
||||
key->name_len = cpu_to_le16(namelen);
|
||||
strcpy(key->name, qname->name);
|
||||
strscpy(key->name, qname->name, namelen);
|
||||
|
||||
*key_p = key;
|
||||
return key_len;
|
||||
@@ -297,7 +297,7 @@ static int apfs_build_dentry_hashed_key(struct qstr *qname, u64 hash, u64 parent
|
||||
|
||||
apfs_key_set_hdr(APFS_TYPE_DIR_REC, parent_id, key);
|
||||
key->name_len_and_hash = cpu_to_le32(namelen | hash);
|
||||
strcpy(key->name, qname->name);
|
||||
strscpy(key->name, qname->name, namelen);
|
||||
|
||||
*key_p = key;
|
||||
return key_len;
|
||||
@@ -434,7 +434,7 @@ static int apfs_build_sibling_val(struct dentry *dentry,
|
||||
|
||||
val->parent_id = cpu_to_le64(apfs_ino(parent));
|
||||
val->name_len = cpu_to_le16(namelen);
|
||||
strcpy(val->name, qname->name);
|
||||
strscpy(val->name, qname->name, namelen);
|
||||
|
||||
*val_p = val;
|
||||
return val_len;
|
||||
@@ -1089,7 +1089,7 @@ static int apfs_sibling_link_from_query(struct apfs_query *query,
|
||||
*name = kmalloc(namelen, GFP_KERNEL);
|
||||
if (!*name)
|
||||
return -ENOMEM;
|
||||
strcpy(*name, siblink->name);
|
||||
strscpy(*name, siblink->name, namelen);
|
||||
*parent = le64_to_cpu(siblink->parent_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
PACKAGE_NAME="linux-apfs-rw"
|
||||
PACKAGE_VERSION="0.3.3"
|
||||
PACKAGE_VERSION="0.3.4"
|
||||
|
||||
BUILT_MODULE_NAME[0]="apfs"
|
||||
DEST_MODULE_LOCATION[0]="/extra"
|
||||
|
||||
@@ -679,6 +679,12 @@ static void apfs_noop_invalidate_folio(struct folio *folio, size_t offset, size_
|
||||
|
||||
/* bmap is not implemented to avoid issues with CoW on swapfiles */
|
||||
static const struct address_space_operations apfs_aops = {
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
|
||||
.dirty_folio = block_dirty_folio,
|
||||
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)
|
||||
.set_page_dirty = __set_page_dirty_buffers,
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 0)
|
||||
.read_folio = apfs_read_folio,
|
||||
#else
|
||||
|
||||
+2
-2
@@ -116,7 +116,7 @@ static int apfs_create_snap_metadata_rec(struct inode *mntpoint, struct apfs_nod
|
||||
raw_val->extentref_tree_type = vsb_raw->apfs_extentref_tree_type;
|
||||
raw_val->flags = 0;
|
||||
raw_val->name_len = cpu_to_le16(name_len + 1); /* Count the null byte */
|
||||
strcpy(raw_val->name, name);
|
||||
strscpy(raw_val->name, name, name_len + 1);
|
||||
|
||||
apfs_assert_in_transaction(sb, &vsb_raw->apfs_o);
|
||||
raw_val->inum = vsb_raw->apfs_next_obj_id;
|
||||
@@ -173,7 +173,7 @@ static int apfs_create_snap_name_rec(struct apfs_node *snap_root, const char *na
|
||||
}
|
||||
apfs_key_set_hdr(APFS_TYPE_SNAP_NAME, APFS_SNAP_NAME_OBJ_ID, raw_key);
|
||||
raw_key->name_len = cpu_to_le16(name_len + 1); /* Count the null byte */
|
||||
strcpy(raw_key->name, name);
|
||||
strscpy(raw_key->name, name, name_len + 1);
|
||||
|
||||
raw_val.snap_xid = cpu_to_le64(APFS_NXI(sb)->nx_xid);
|
||||
|
||||
|
||||
@@ -272,11 +272,13 @@ static void apfs_update_software_info(struct super_block *sb)
|
||||
memmove(mod_by + 1, mod_by, (APFS_MAX_HIST - 1) * sizeof(*mod_by));
|
||||
|
||||
memset(mod_by->id, 0, sizeof(mod_by->id));
|
||||
strcpy(mod_by->id, APFS_MODULE_ID_STRING);
|
||||
strscpy(mod_by->id, APFS_MODULE_ID_STRING, sizeof(mod_by->id));
|
||||
mod_by->timestamp = cpu_to_le64(ktime_get_real_ns());
|
||||
mod_by->last_xid = cpu_to_le64(APFS_NXI(sb)->nx_xid);
|
||||
}
|
||||
|
||||
static struct file_system_type apfs_fs_type;
|
||||
|
||||
/**
|
||||
* apfs_unmap_main_super - Clean up apfs_map_main_super()
|
||||
* @sbi: in-memory superblock info
|
||||
@@ -286,11 +288,15 @@ static void apfs_update_software_info(struct super_block *sb)
|
||||
static inline void apfs_unmap_main_super(struct apfs_sb_info *sbi)
|
||||
{
|
||||
struct apfs_nxsb_info *nxi = sbi->s_nxi;
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0)
|
||||
fmode_t mode = FMODE_READ | FMODE_EXCL;
|
||||
#endif
|
||||
struct apfs_object *obj = NULL;
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0)
|
||||
if (nxi->nx_flags & APFS_READWRITE)
|
||||
mode |= FMODE_WRITE;
|
||||
#endif
|
||||
|
||||
lockdep_assert_held(&nxs_mutex);
|
||||
|
||||
@@ -304,7 +310,12 @@ static inline void apfs_unmap_main_super(struct apfs_sb_info *sbi)
|
||||
obj->o_bh = NULL;
|
||||
obj = NULL;
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 0)
|
||||
blkdev_put(nxi->nx_bdev, &apfs_fs_type);
|
||||
#else
|
||||
blkdev_put(nxi->nx_bdev, mode);
|
||||
#endif
|
||||
|
||||
list_del(&nxi->nx_list);
|
||||
kfree(nxi);
|
||||
out:
|
||||
@@ -1450,8 +1461,6 @@ static int apfs_set_super(struct super_block *sb, void *data)
|
||||
return err;
|
||||
}
|
||||
|
||||
static struct file_system_type apfs_fs_type;
|
||||
|
||||
/*
|
||||
* Wrapper for lookup_bdev() that supports older kernels.
|
||||
*/
|
||||
@@ -1480,7 +1489,11 @@ static int apfs_lookup_bdev(const char *pathname, dev_t *dev)
|
||||
*
|
||||
* Returns 0 on success, or a negative error code in case of failure.
|
||||
*/
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 0)
|
||||
static int apfs_attach_nxi(struct apfs_sb_info *sbi, const char *dev_name, blk_mode_t mode)
|
||||
#else
|
||||
static int apfs_attach_nxi(struct apfs_sb_info *sbi, const char *dev_name, fmode_t mode)
|
||||
#endif
|
||||
{
|
||||
struct apfs_nxsb_info *nxi;
|
||||
dev_t dev = 0;
|
||||
@@ -1500,7 +1513,11 @@ static int apfs_attach_nxi(struct apfs_sb_info *sbi, const char *dev_name, fmode
|
||||
if (!nxi)
|
||||
return -ENOMEM;
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 0)
|
||||
bdev = blkdev_get_by_path(dev_name, mode, &apfs_fs_type, NULL);
|
||||
#else
|
||||
bdev = blkdev_get_by_path(dev_name, mode, &apfs_fs_type);
|
||||
#endif
|
||||
if (IS_ERR(bdev)) {
|
||||
kfree(nxi);
|
||||
return PTR_ERR(bdev);
|
||||
@@ -1527,7 +1544,11 @@ static struct dentry *apfs_mount(struct file_system_type *fs_type, int flags,
|
||||
struct apfs_nxsb_info *nxi;
|
||||
struct super_block *sb;
|
||||
struct apfs_sb_info *sbi;
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 0)
|
||||
blk_mode_t mode = sb_open_mode(flags);
|
||||
#else
|
||||
fmode_t mode = FMODE_READ | FMODE_EXCL;
|
||||
#endif
|
||||
int error = 0;
|
||||
|
||||
mutex_lock(&nxs_mutex);
|
||||
@@ -1544,8 +1565,10 @@ static struct dentry *apfs_mount(struct file_system_type *fs_type, int flags,
|
||||
if (sbi->s_snap_name)
|
||||
flags |= SB_RDONLY;
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0)
|
||||
if (!(flags & SB_RDONLY))
|
||||
mode |= FMODE_WRITE;
|
||||
#endif
|
||||
|
||||
error = apfs_attach_nxi(sbi, dev_name, mode);
|
||||
if (error)
|
||||
@@ -1572,7 +1595,9 @@ static struct dentry *apfs_mount(struct file_system_type *fs_type, int flags,
|
||||
error = apfs_map_main_super(sb);
|
||||
if (error)
|
||||
goto out_deactivate_super;
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0)
|
||||
sb->s_mode = mode;
|
||||
#endif
|
||||
snprintf(sb->s_id, sizeof(sb->s_id), "%xg", sb->s_dev);
|
||||
error = apfs_fill_super(sb, data, flags & SB_SILENT ? 1 : 0);
|
||||
if (error)
|
||||
|
||||
Reference in new issue
Block a user