Skip to content

Commit d4205dc

Browse files
committed
HADOOP-16582. LocalFileSystem's mkdirs() does not work as expected under viewfs. Contributed by Kihwal Lee
1 parent c9900a0 commit d4205dc

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFileSystem.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,10 @@ public boolean mkdirs(Path f, FsPermission permission) throws IOException {
334334
return fs.mkdirs(f, permission);
335335
}
336336

337+
@Override
338+
public boolean mkdirs(Path f) throws IOException {
339+
return fs.mkdirs(f);
340+
}
337341

338342
/**
339343
* The src file is on the local disk. Add it to FS at

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ChRootedFileSystem.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,11 @@ public boolean mkdirs(final Path f, final FsPermission permission)
279279
return super.mkdirs(fullPath(f), permission);
280280
}
281281

282+
@Override
283+
public boolean mkdirs(final Path f) throws IOException {
284+
return super.mkdirs(fullPath(f));
285+
}
286+
282287
@Override
283288
public FSDataInputStream open(final Path f, final int bufferSize)
284289
throws IOException {

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,12 +549,19 @@ private Path getChrootedPath(InodeTree.ResolveResult<FileSystem> res,
549549
suffix.length() == 0 ? f : new Path(res.resolvedPath, suffix));
550550
}
551551

552+
@Override
553+
public boolean mkdirs(Path dir) throws IOException {
554+
InodeTree.ResolveResult<FileSystem> res =
555+
fsState.resolve(getUriPath(dir), false);
556+
return res.targetFileSystem.mkdirs(res.remainingPath);
557+
}
558+
552559
@Override
553560
public boolean mkdirs(final Path dir, final FsPermission permission)
554561
throws IOException {
555562
InodeTree.ResolveResult<FileSystem> res =
556-
fsState.resolve(getUriPath(dir), false);
557-
return res.targetFileSystem.mkdirs(res.remainingPath, permission);
563+
fsState.resolve(getUriPath(dir), false);
564+
return res.targetFileSystem.mkdirs(res.remainingPath, permission);
558565
}
559566

560567
@Override
@@ -1171,6 +1178,12 @@ public boolean mkdirs(Path dir, FsPermission permission)
11711178
throw readOnlyMountTable("mkdirs", dir);
11721179
}
11731180

1181+
@Override
1182+
public boolean mkdirs(Path dir)
1183+
throws AccessControlException, FileAlreadyExistsException {
1184+
return mkdirs(dir, null);
1185+
}
1186+
11741187
@Override
11751188
public FSDataInputStream open(Path f, int bufferSize)
11761189
throws AccessControlException, FileNotFoundException, IOException {

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFilterFileSystem.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ public FSDataOutputStream createNonRecursive(Path f, FsPermission permission,
7777
boolean overwrite, int bufferSize, short replication, long blockSize,
7878
Progressable progress) throws IOException;
7979

80-
public boolean mkdirs(Path f);
8180
public FSDataInputStream open(Path f);
8281
public FSDataInputStream open(PathHandle f);
8382
public FSDataOutputStream create(Path f);

0 commit comments

Comments
 (0)