Skip to content

Commit 9df70f3

Browse files
committed
Merge branch 'master' of ssh://github.com/abbbi/nullfsvfs
2 parents 3834964 + d8e8ca1 commit 9df70f3

File tree

5 files changed

+88
-18
lines changed

5 files changed

+88
-18
lines changed

README.md

+37-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
![ci](https://github.com/abbbi/nullfsvfs/actions/workflows/ci-ubuntu-latest.yml/badge.svg)
1+
[![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)
22

33
## Index
44

55
- [About](#nullfs)
66
- [Usage](#usage)
7+
- [Installation](#installation)
78
- [Use Cases](#usecases)
89
- [Keeping data](#keep)
910
- [Mount options](#supported)
1011

1112
# nullfs
12-
a virtual file system that behaves like /dev/null
13+
A virtual file system that behaves like /dev/null
1314

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

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

7374

75+
## installation
76+
77+
To install the module for the running linux kernel use:
78+
79+
```
80+
# make -C /lib/modules/$(uname -r)/build M=$PWD modules_install INSTALL_MOD_DIR=kernel/fs/nullfs
81+
# depmod
82+
```
83+
84+
Running `depmod` is mandatory. Now the module can be loaded via:
85+
86+
```
87+
modprobe nullfs
88+
```
89+
90+
To automatically load filesystem module during boot time, create a configuration
91+
file suitable for your distribution, usually located in */etc/modules-load.d*
92+
93+
```
94+
echo nullfs > /etc/modules-load.d/nullfs.conf
95+
```
96+
97+
Example entry for `/etc/fstab`, mounting the filesystem to `/nullfs`:
98+
99+
100+
```
101+
none /nullfs nullfs auto
102+
```
103+
74104
### keep
75105

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

136+
Works with recent linux kernels (5.x), nullfs builds fine with older kernels
137+
(4.x, 3.x) but setting ACL information fails with "Operation not supported".
138+
106139
### usecases
107140

108141
See: [Use Cases ](https://github.com/abbbi/nullfsvfs/labels/Usecase)

debian/changelog

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1-
nullfsvfs (0.10) UNRELEASED; urgency=medium
1+
nullfsvfs (0.12) unstable; urgency=medium
2+
3+
* Fix build on SLES based kernels, add #ifdef for RHEL_MAJOR.
4+
Module now builds on RHEL/Centos7,SLES12,SLES15 and newer.
5+
6+
-- Michael Ablassmeier <[email protected]> Wed, 29 Sep 2021 10:45:37 +0200
7+
8+
nullfsvfs (0.11) unstable; urgency=medium
9+
10+
* Re-Add support for older linux kernel versions (3.10.x) used
11+
by RHEL7 and Centos7 and SLES15, which was broken by adding Posix ACL
12+
and O_DIRECT support.
13+
14+
-- Michael Ablassmeier <[email protected]> Tue, 28 Sep 2021 16:37:59 +0200
15+
16+
nullfsvfs (0.10) unstable; urgency=medium
217

318
* Add support for kernel versions >= 5.14
419

nullfs.c

+30-8
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
#define NULLFS_MAGIC 0x19980123
4343
#define NULLFS_DEFAULT_MODE 0755
4444
#define NULLFS_SYSFS_MODE 0644
45-
#define NULLFS_VERSION "0.11"
45+
#define NULLFS_VERSION "0.12"
4646

4747
MODULE_AUTHOR("Michael Ablassmeier");
4848
MODULE_LICENSE("GPL");
@@ -51,8 +51,16 @@ MODULE_VERSION(NULLFS_VERSION);
5151
/*
5252
* POSIX ACL
5353
* setfacl is possible, but acls are not stored, of course
54+
*
55+
* For older kernel versions (3.x, used on rhel7/centos7 its required to
56+
* redefine some non-public functions to make it "work", so we skip..
5457
*/
55-
58+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
59+
static const struct xattr_handler *nullfs_xattr_handlers[] = {
60+
&posix_acl_access_xattr_handler,
61+
&posix_acl_default_xattr_handler,
62+
NULL
63+
};
5664
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0)
5765
static int nullfs_set_acl(struct user_namespace *mnt_userns,
5866
struct inode *inode, struct posix_acl *acl, int type)
@@ -62,12 +70,7 @@ static int nullfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
6270
{
6371
return 0;
6472
}
65-
static const struct xattr_handler *nullfs_xattr_handlers[] = {
66-
&posix_acl_access_xattr_handler,
67-
&posix_acl_default_xattr_handler,
68-
NULL
69-
};
70-
73+
#endif
7174

7275
/*
7376
* sysfs handlers
@@ -191,19 +194,32 @@ const struct file_operations nullfs_real_file_operations = {
191194
const struct inode_operations nullfs_file_inode_operations = {
192195
.setattr = simple_setattr,
193196
.getattr = nullfs_getattr,
197+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
194198
.set_acl = nullfs_set_acl,
199+
#endif
195200
};
196201
const struct inode_operations nullfs_special_inode_operations = {
197202
.setattr = simple_setattr,
198203
.getattr = nullfs_getattr,
204+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
199205
.set_acl = nullfs_set_acl,
206+
#endif
200207
};
201208
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)
202209
static const struct address_space_operations nullfs_aops = {
203210
.readpage = simple_readpage,
204211
.write_begin = simple_write_begin,
205212
.write_end = simple_write_end,
213+
/**
214+
* RHEL kernel exports noop_direct_IO, SLES15 does not
215+
**/
216+
#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 0, 0)
217+
#ifdef RHEL_MAJOR
206218
.direct_IO = noop_direct_IO
219+
#endif
220+
#else
221+
.direct_IO = noop_direct_IO
222+
#endif
207223
};
208224
#endif
209225

@@ -462,6 +478,7 @@ static int nullfs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
462478
#endif
463479
}
464480

481+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)
465482
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0)
466483
static int nullfs_tmpfile(struct user_namespace *mnt_userns, struct inode *dir, struct dentry *dentry, umode_t mode)
467484
#else
@@ -475,6 +492,7 @@ static int nullfs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode
475492
d_tmpfile(dentry, inode);
476493
return 0;
477494
}
495+
#endif
478496

479497
static const struct inode_operations nullfs_dir_inode_operations = {
480498
.create = nullfs_create,
@@ -487,7 +505,9 @@ static const struct inode_operations nullfs_dir_inode_operations = {
487505
.mknod = nullfs_mknod,
488506
.rename = simple_rename,
489507
.getattr = nullfs_getattr,
508+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
490509
.set_acl = nullfs_set_acl,
510+
#endif
491511
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)
492512
.tmpfile = nullfs_tmpfile,
493513
#endif
@@ -539,8 +559,10 @@ int nullfs_fill_super(struct super_block *sb, void *data, int silent)
539559
sb->s_magic = NULLFS_MAGIC;
540560
sb->s_op = &nullfs_ops;
541561
sb->s_time_gran = 1;
562+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
542563
sb->s_xattr = nullfs_xattr_handlers;
543564
sb->s_flags |= SB_POSIXACL;
565+
#endif
544566

545567
inode = nullfs_get_inode(sb, NULL, S_IFDIR | fsi->mount_opts.mode, 0, sb->s_root);
546568
sb->s_root = d_make_root(inode);

rpm/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ Examples how to build rpm package from source.
55
### RHEL 8.4
66
```
77
yum install git rpm-build elfutils-libelf-devel kernel-abi-stablelists kernel-rpm-macros -y
8-
git clone http://github.com/abbbi/nullfsvfs nullfsvfs-0.9
9-
tar -czvf /root/rpmbuild/SOURCES/nullfsvfs-kmod-0.9.tar.gz nullfsvfs-0.9
10-
rpmbuild -ba nullfsvfs-0.9/rpm/nullfsvfs-kmod.spec
11-
rpm -i /root/rpmbuild/RPMS/x86_64/kmod-nullfsvfs-0.9-1.el8.x86_64.rpm
8+
git clone http://github.com/abbbi/nullfsvfs nullfsvfs-0.12
9+
tar -czvf /root/rpmbuild/SOURCES/nullfsvfs-kmod-0.12.tar.gz nullfsvfs-0.12
10+
rpmbuild -ba nullfsvfs-0.12/rpm/nullfsvfs-kmod.spec
11+
rpm -i /root/rpmbuild/RPMS/x86_64/kmod-nullfsvfs-0.12-1.el8.x86_64.rpm
1212
modprobe nullfs
1313
```

rpm/nullfsvfs-kmod.spec

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
%{!?kversion: %global kversion %(uname -r)}
2020

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

0 commit comments

Comments
 (0)