Skip to content

Commit e7be461

Browse files
committed
basic-server: Allow for the creation of files from the outside
list() would currently fail when retrieving files in a directory that weren't previously mapped to an Inode. Check if the Path exists, and only throw a NoEntException if it doesn't. In all other cases create and map a new Inode to the path. Also handle an edge-case where a path was briefly visible but deleted right away during list(). Related: #149 Signed-off-by: Christian Kohlschütter <[email protected]>
1 parent d3ce089 commit e7be461

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

basic-server/src/main/java/org/dcache/nfs4j/server/LocalFileSystem.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ private Path resolveInode(Inode inodeNumber) throws NoEntException {
9797
private Inode resolvePath(Path path) throws NoEntException {
9898
Inode inodeNumber = pathToInode.get(path);
9999
if (inodeNumber == null) {
100-
throw new NoEntException("path " + path);
100+
if (!Files.exists(path)) {
101+
throw new NoEntException("path " + path);
102+
}
103+
inodeNumber = newInode();
104+
map(inodeNumber, path);
101105
}
102106
return inodeNumber;
103107
}
@@ -281,7 +285,13 @@ public DirectoryStream list(Inode inode, byte[] bytes, long l) throws IOExceptio
281285
for (Path p : ds) {
282286
cookie++;
283287
if (cookie > l) {
284-
Inode ino = resolvePath(p);
288+
Inode ino;
289+
try {
290+
ino = resolvePath(p);
291+
} catch (NoEntException e) {
292+
// File was briefly available, but deleted before we could allocate an inode
293+
continue;
294+
}
285295
list.add(new DirectoryEntry(p.getFileName().toString(), ino, statPath(p, ino), cookie));
286296
}
287297
}

0 commit comments

Comments
 (0)