Skip to content

Commit

Permalink
Add error injection with wrong storage capacity
Browse files Browse the repository at this point in the history
Closes #62
  • Loading branch information
ligurio committed Aug 11, 2021
1 parent 6d538d0 commit ed4d1e2
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Supported fault injections are:
but applicable to any file operation).
- `errinj_slowdown` - slowdown invoked file operation.
- `errinj_1byte_read` - amount of data `read()` is returned is limited by 1 byte.
- `errinj_wrong_capacity` - report a wrong storage capacity.

### Building

Expand Down
2 changes: 2 additions & 0 deletions unreliablefs.conf.5
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ limited by supported errno's.
File operation slowdown for nanoseconds specified by duration parameter.
.It Cm errinj_1byte_read
Return exactly 1 byte on every read() operation.
.It Cm errinj_wrong_capacity
Report a wrong storage capacity.
.El
.Pp
The options are:
Expand Down
2 changes: 2 additions & 0 deletions unreliablefs_errinj.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const char *errinj_name[] =
"errinj_noop",
"errinj_slowdown",
"errinj_1byte_read",
"errinj_wrong_capacity",
};

typedef enum {
Expand All @@ -30,6 +31,7 @@ typedef enum {
ERRINJ_NOOP,
ERRINJ_SLOWDOWN,
ERRINJ_1BYTE_READ,
ERRINJ_WRONG_CAPACITY,
} errinj_type;

typedef struct errinj_conf errinj_conf;
Expand Down
1 change: 1 addition & 0 deletions unreliablefs_errinj.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#define ERRNO_NOOP -999
#define ERRNO_1BYTE_READ -998
#define ERRNO_WRONG_CAPACITY -997

int error_inject(const char* path, fuse_op operation);
struct err_inj_q *config_init(const char* conf_path);
Expand Down
2 changes: 2 additions & 0 deletions unreliablefs_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,8 @@ int unreliable_statfs(const char *path, struct statvfs *buf)
int ret = error_inject(path, OP_STATFS);
if (ret == -ERRNO_NOOP) {
return 0;
if (ret == -ERRNO_WRONG_CAPACITY) {
/* wrong capacity */
} else if (ret) {
return ret;
}
Expand Down

0 comments on commit ed4d1e2

Please sign in to comment.