commit - 33aa3497b959ad985e7fb0f016da798f30f2eef0
commit + 37f25c595daf6b5142475cdc982f6da812672046
blob - 50db83dc79e5f1e7414070beb4d8af7607a5aeeb
blob + fc1ac8f81ed2b51f36fe8dd58a40d03893891ed0
--- README.md
+++ README.md
- `errinj_slowdown` - slowdown invoked file operation.
- `errinj_1byte_read` - amount of data returned by `read()` call is always
limited by a single byte.
+- `errinj_wrong_capacity` - filesystem reports a wrong storage capacity, real
+ capacity increased for 15 percents. Simulated error can happen in a wild, for
+ instance see 'Fake capacity USB sticks' in
+ [SQLite Documentation](https://www.sqlite.org/howtocorrupt.html).
### Building
blob - 217c01a4511b1b701ccc4797cc33df4cd314bbe8
blob + 25bb7b80c400bf27501a05e0b5ed9abc208a08ad
--- unreliablefs-scm-1.rockspec
+++ unreliablefs-scm-1.rockspec
- `errinj_slowdown` - slowdown invoked file operation;
- `errinj_1byte_read` - amount of data returned by `read()` call is always
limited by a single byte.
+ - `errinj_wrong_capacity` - filesystem reports a wrong storage capacity.
]],
homepage = "https://github.com/ligurio/unreliablefs",
maintainer = "Sergey Bronnikov <estetus@gmail.com>",
blob - 80dcc3cbdabbe540e7a9508a1c46da01b70bc22f
blob + d2ba39762b10316a30e69cc0f160ed23cff532b1
--- unreliablefs.conf.5
+++ unreliablefs.conf.5
Return exactly 1 byte on every
.Xr read 2
operation.
+.It Cm errinj_wrong_capacity
+Report a wrong storage capacity. With enabled error injection real filesystem capacity increased for 15 percents.
.El
.Pp
The options are:
path_regexp = *.xlog
probability = 100
+[errinj_wrong_capacity]
+probability = 85
+
.Ed
.Sh SEE ALSO
.Xr unreliablefs 1 ,
blob - 681de370bee5409a2d894725dac3f3e8b7c19dc2
blob + 118cb81ca83ceca7c5fc84017fc9ea795f268318
--- unreliablefs_errinj.c
+++ unreliablefs_errinj.c
"errinj_noop",
"errinj_slowdown",
"errinj_1byte_read",
+ "errinj_wrong_capacity",
};
typedef enum {
ERRINJ_NOOP,
ERRINJ_SLOWDOWN,
ERRINJ_1BYTE_READ,
+ ERRINJ_WRONG_CAPACITY,
} errinj_type;
typedef struct errinj_conf errinj_conf;
if (strcmp(op_name, "read") == 0)
rc = -ERRINJ_1BYTE_READ;
break;
+ case ERRINJ_WRONG_CAPACITY:
+ if (strcmp(op_name, "statfs") == 0)
+ rc = -ERRNO_WRONG_CAPACITY;
+ break;
}
}
blob - 4889de8d7338eb0cba5c6cfb742dce4469fb4e09
blob + d790ffa40c136a5584ff0cbf41dbe84f5b697b71
--- unreliablefs_errinj.h
+++ unreliablefs_errinj.h
#define MAX_PROBABLITY 100
#define ERRNO_NOOP -999
#define ERRNO_1BYTE_READ -998
+#define ERRNO_WRONG_CAPACITY -997
#define DEFAULT_SIGNAL_NAME SIGKILL
int error_inject(const char* path, fuse_op operation);
blob - 2c20d7d3e8f7c14556e8854760919a4e48ef5551
blob + bc8e6e967cdf007cb3dac095b91569a7c14e19f9
--- unreliablefs_ops.c
+++ unreliablefs_ops.c
int ret = error_inject(path, OP_STATFS);
if (ret == -ERRNO_NOOP) {
return 0;
+ } else if (ret == -ERRNO_WRONG_CAPACITY) {
+ /* wrong capacity */
+ ret = statvfs(path, buf);
+ if (ret == -1) {
+ return -errno;
+ }
+ buf->f_blocks = buf->f_blocks + ( 15 / 100.0 ) * (uint64_t)buf->f_blocks;
+ return 0;
} else if (ret) {
return ret;
}