Skip to content

Commit

Permalink
Merge branch 'master' of ssh://github.com/abbbi/nullfsvfs
Browse files Browse the repository at this point in the history
  • Loading branch information
abbbi committed Dec 10, 2021
2 parents 3834964 + d8e8ca1 commit 9df70f3
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 18 deletions.
41 changes: 37 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
![ci](https://github.com/abbbi/nullfsvfs/actions/workflows/ci-ubuntu-latest.yml/badge.svg)
[![nullfsvfs CI on ubuntu-latest](https://github.com/abbbi/nullfsvfs/actions/workflows/ci-ubuntu-latest.yml/badge.svg?branch=master)](https://github.com/abbbi/nullfsvfs/actions/workflows/ci-ubuntu-latest.yml)

## Index

- [About](#nullfs)
- [Usage](#usage)
- [Installation](#installation)
- [Use Cases](#usecases)
- [Keeping data](#keep)
- [Mount options](#supported)

# nullfs
a virtual file system that behaves like /dev/null
A virtual file system that behaves like /dev/null

It can handle regular file operations like mkdir/rmdir/ln but writing to files
does not store any data. The file size is however saved, so reading from the
files behaves like reading from /dev/zero with a fixed size.
does not store any data. The file size is however saved, reading from the
files behaves like reading from /dev/zero.

Writing and reading is basically an NOOP, so it can be used for performance
testing with applications that require directory structures. Implemented as
Expand Down Expand Up @@ -71,6 +72,35 @@ makes it behave like reading from /dev/zero:
```


## installation

To install the module for the running linux kernel use:

```
# make -C /lib/modules/$(uname -r)/build M=$PWD modules_install INSTALL_MOD_DIR=kernel/fs/nullfs
# depmod
```

Running `depmod` is mandatory. Now the module can be loaded via:

```
modprobe nullfs
```

To automatically load filesystem module during boot time, create a configuration
file suitable for your distribution, usually located in */etc/modules-load.d*

```
echo nullfs > /etc/modules-load.d/nullfs.conf
```

Example entry for `/etc/fstab`, mounting the filesystem to `/nullfs`:


```
none /nullfs nullfs auto
```

### keep

There is the possiblity to exclude certain files from beeing sent into the void.
Expand Down Expand Up @@ -103,6 +133,9 @@ nulled.
It is possible to set POSIX ACL attributes via `setfacl` so it appears the
filesystem supports them, they are not saved.

Works with recent linux kernels (5.x), nullfs builds fine with older kernels
(4.x, 3.x) but setting ACL information fails with "Operation not supported".

### usecases

See: [Use Cases ](https://github.com/abbbi/nullfsvfs/labels/Usecase)
Expand Down
17 changes: 16 additions & 1 deletion debian/changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
nullfsvfs (0.10) UNRELEASED; urgency=medium
nullfsvfs (0.12) unstable; urgency=medium

* Fix build on SLES based kernels, add #ifdef for RHEL_MAJOR.
Module now builds on RHEL/Centos7,SLES12,SLES15 and newer.

-- Michael Ablassmeier <abi@grinser.de> Wed, 29 Sep 2021 10:45:37 +0200

nullfsvfs (0.11) unstable; urgency=medium

* Re-Add support for older linux kernel versions (3.10.x) used
by RHEL7 and Centos7 and SLES15, which was broken by adding Posix ACL
and O_DIRECT support.

-- Michael Ablassmeier <abi@grinser.de> Tue, 28 Sep 2021 16:37:59 +0200

nullfsvfs (0.10) unstable; urgency=medium

* Add support for kernel versions >= 5.14

Expand Down
38 changes: 30 additions & 8 deletions nullfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#define NULLFS_MAGIC 0x19980123
#define NULLFS_DEFAULT_MODE 0755
#define NULLFS_SYSFS_MODE 0644
#define NULLFS_VERSION "0.11"
#define NULLFS_VERSION "0.12"

MODULE_AUTHOR("Michael Ablassmeier");
MODULE_LICENSE("GPL");
Expand All @@ -51,8 +51,16 @@ MODULE_VERSION(NULLFS_VERSION);
/*
* POSIX ACL
* setfacl is possible, but acls are not stored, of course
*
* For older kernel versions (3.x, used on rhel7/centos7 its required to
* redefine some non-public functions to make it "work", so we skip..
*/

#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
static const struct xattr_handler *nullfs_xattr_handlers[] = {
&posix_acl_access_xattr_handler,
&posix_acl_default_xattr_handler,
NULL
};
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0)
static int nullfs_set_acl(struct user_namespace *mnt_userns,
struct inode *inode, struct posix_acl *acl, int type)
Expand All @@ -62,12 +70,7 @@ static int nullfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
{
return 0;
}
static const struct xattr_handler *nullfs_xattr_handlers[] = {
&posix_acl_access_xattr_handler,
&posix_acl_default_xattr_handler,
NULL
};

#endif

/*
* sysfs handlers
Expand Down Expand Up @@ -191,19 +194,32 @@ const struct file_operations nullfs_real_file_operations = {
const struct inode_operations nullfs_file_inode_operations = {
.setattr = simple_setattr,
.getattr = nullfs_getattr,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
.set_acl = nullfs_set_acl,
#endif
};
const struct inode_operations nullfs_special_inode_operations = {
.setattr = simple_setattr,
.getattr = nullfs_getattr,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
.set_acl = nullfs_set_acl,
#endif
};
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)
static const struct address_space_operations nullfs_aops = {
.readpage = simple_readpage,
.write_begin = simple_write_begin,
.write_end = simple_write_end,
/**
* RHEL kernel exports noop_direct_IO, SLES15 does not
**/
#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 0, 0)
#ifdef RHEL_MAJOR
.direct_IO = noop_direct_IO
#endif
#else
.direct_IO = noop_direct_IO
#endif
};
#endif

Expand Down Expand Up @@ -462,6 +478,7 @@ static int nullfs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
#endif
}

#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0)
static int nullfs_tmpfile(struct user_namespace *mnt_userns, struct inode *dir, struct dentry *dentry, umode_t mode)
#else
Expand All @@ -475,6 +492,7 @@ static int nullfs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode
d_tmpfile(dentry, inode);
return 0;
}
#endif

static const struct inode_operations nullfs_dir_inode_operations = {
.create = nullfs_create,
Expand All @@ -487,7 +505,9 @@ static const struct inode_operations nullfs_dir_inode_operations = {
.mknod = nullfs_mknod,
.rename = simple_rename,
.getattr = nullfs_getattr,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
.set_acl = nullfs_set_acl,
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)
.tmpfile = nullfs_tmpfile,
#endif
Expand Down Expand Up @@ -539,8 +559,10 @@ int nullfs_fill_super(struct super_block *sb, void *data, int silent)
sb->s_magic = NULLFS_MAGIC;
sb->s_op = &nullfs_ops;
sb->s_time_gran = 1;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
sb->s_xattr = nullfs_xattr_handlers;
sb->s_flags |= SB_POSIXACL;
#endif

inode = nullfs_get_inode(sb, NULL, S_IFDIR | fsi->mount_opts.mode, 0, sb->s_root);
sb->s_root = d_make_root(inode);
Expand Down
8 changes: 4 additions & 4 deletions rpm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Examples how to build rpm package from source.
### RHEL 8.4
```
yum install git rpm-build elfutils-libelf-devel kernel-abi-stablelists kernel-rpm-macros -y
git clone http://github.com/abbbi/nullfsvfs nullfsvfs-0.9
tar -czvf /root/rpmbuild/SOURCES/nullfsvfs-kmod-0.9.tar.gz nullfsvfs-0.9
rpmbuild -ba nullfsvfs-0.9/rpm/nullfsvfs-kmod.spec
rpm -i /root/rpmbuild/RPMS/x86_64/kmod-nullfsvfs-0.9-1.el8.x86_64.rpm
git clone http://github.com/abbbi/nullfsvfs nullfsvfs-0.12
tar -czvf /root/rpmbuild/SOURCES/nullfsvfs-kmod-0.12.tar.gz nullfsvfs-0.12
rpmbuild -ba nullfsvfs-0.12/rpm/nullfsvfs-kmod.spec
rpm -i /root/rpmbuild/RPMS/x86_64/kmod-nullfsvfs-0.12-1.el8.x86_64.rpm
modprobe nullfs
```
2 changes: 1 addition & 1 deletion rpm/nullfsvfs-kmod.spec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
%{!?kversion: %global kversion %(uname -r)}

Name: %{kmod_name}-kmod
Version: 0.10
Version: 0.11
Release: 1%{?dist}
Summary: A virtual file system that behaves like /dev/null
License: GPLv3+
Expand Down

0 comments on commit 9df70f3

Please sign in to comment.