ANDROID: Incremental fs: Separate pseudo-file code

Also fixed two bugs in the process:

is_pseudo_filename was not previously checking for .log, so an attempt
to create a .log would succeed.

All ioctls could be called on all files. ioctls now set on the correct
files.

Bug: 162856396
Test: incfs_test passes
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I3f1e87d018836f51a97897880dd70181db4f7169
This commit is contained in:
Paul Lawrence
2020-08-20 12:45:41 -07:00
parent ea3a54ef5d
commit 664b742715
7 changed files with 1159 additions and 1106 deletions

View File

@@ -6,4 +6,5 @@ incrementalfs-y := \
format.o \
integrity.o \
main.o \
pseudo_files.o \
vfs.o

View File

@@ -927,9 +927,7 @@ static int wait_for_data_block(struct data_file *df, int block_index,
mi = df->df_mount_info;
segment = get_file_segment(df, block_index);
error = down_read_killable(&segment->rwsem);
if (error)
return error;
down_read(&segment->rwsem);
/* Look up the given block */
error = get_data_file_block(df, block_index, &block);
@@ -977,9 +975,7 @@ static int wait_for_data_block(struct data_file *df, int block_index,
return wait_res;
}
error = down_read_killable(&segment->rwsem);
if (error)
return error;
down_read(&segment->rwsem);
/*
* Re-read block's info now, it has just arrived and
@@ -1094,9 +1090,7 @@ int incfs_process_new_data_block(struct data_file *df,
if (block->compression == COMPRESSION_LZ4)
flags |= INCFS_BLOCK_COMPRESSED_LZ4;
error = down_read_killable(&segment->rwsem);
if (error)
return error;
down_read(&segment->rwsem);
error = get_data_file_block(df, block->block_index, &existing_block);

1068
fs/incfs/pseudo_files.c Normal file

File diff suppressed because it is too large Load Diff

15
fs/incfs/pseudo_files.h Normal file
View File

@@ -0,0 +1,15 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright 2020 Google LLC
*/
#ifndef _INCFS_PSEUDO_FILES_H
#define _INCFS_PSEUDO_FILES_H
#define PSEUDO_FILE_COUNT 2
#define INCFS_START_INO_RANGE 10
int dir_lookup_pseudo_files(struct super_block *sb, struct dentry *dentry);
int emit_pseudo_files(struct dir_context *ctx);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -6,8 +6,33 @@
#ifndef _INCFS_VFS_H
#define _INCFS_VFS_H
enum FILL_PERMISSION {
CANT_FILL = 0,
CAN_FILL = 1,
};
extern const struct file_operations incfs_file_ops;
extern const struct inode_operations incfs_file_inode_ops;
void incfs_kill_sb(struct super_block *sb);
struct dentry *incfs_mount_fs(struct file_system_type *type, int flags,
const char *dev_name, void *data);
int incfs_link(struct dentry *what, struct dentry *where);
int incfs_unlink(struct dentry *dentry);
static inline struct mount_info *get_mount_info(struct super_block *sb)
{
struct mount_info *result = sb->s_fs_info;
WARN_ON(!result);
return result;
}
static inline struct super_block *file_superblock(struct file *f)
{
struct inode *inode = file_inode(f);
return inode->i_sb;
}
#endif

View File

@@ -227,8 +227,7 @@ int open_file_by_id(const char *mnt_dir, incfs_uuid_t id, bool use_ioctl)
goto out;
}
if (ioctl(fd, INCFS_IOC_PERMIT_FILL, &permit_fill) != -1 ||
errno != EPERM) {
if (ioctl(fd, INCFS_IOC_PERMIT_FILL, &permit_fill) != -1) {
print_error(
"Successfully called PERMIT_FILL on non pending_read file");
return -errno;