Commit Diff


commit - fa47663f7915ef6db546dc4223093aa1e48b902c
commit + 1d270e941a4df43bb433716d6ec1e8c20839c9ce
blob - a3a80bc2534eca7e88f084768b08d501d56b315c
blob + 790671dc70ff0d53100a26e534e71a9f70c820ea
--- unreliablefs_ops.c
+++ unreliablefs_ops.c
@@ -655,12 +655,33 @@ int unreliable_fallocate(const char *path, int mode,
     int ret = error_inject(path, "fallocate");
     if (ret) {
         return ret;
+    }
+
+    int fd;
+    (void) fi;
+
+    if (mode) {
+	return -EOPNOTSUPP;
     }
 
+    if(fi == NULL) {
+	fd = open(path, O_WRONLY);
+    } else {
+	fd = fi->fh;
+    }
+
+    if (fd == -1) {
+	return -errno;
+    }
+
     ret = fallocate((int) fi->fh, mode, offset, len);
     if (ret == -1) {
         return -errno;
     }
+
+    if(fi == NULL) {
+	close(fd);
+    }
     
     return 0;    
 }