aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/unix
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/unix')
-rw-r--r--src/main/java/com/google/devtools/build/lib/unix/UnixFileSystem.java66
1 files changed, 26 insertions, 40 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/unix/UnixFileSystem.java b/src/main/java/com/google/devtools/build/lib/unix/UnixFileSystem.java
index 0af17cfb12..033a6a692d 100644
--- a/src/main/java/com/google/devtools/build/lib/unix/UnixFileSystem.java
+++ b/src/main/java/com/google/devtools/build/lib/unix/UnixFileSystem.java
@@ -257,11 +257,9 @@ public class UnixFileSystem extends AbstractFileSystemWithCustomStat {
*/
private void modifyPermissionBits(Path path, int permissionBits, boolean add)
throws IOException {
- synchronized (path) {
- int oldMode = statInternal(path, true).getPermissions();
- int newMode = add ? (oldMode | permissionBits) : (oldMode & ~permissionBits);
- NativePosixFiles.chmod(path.toString(), newMode);
- }
+ int oldMode = statInternal(path, true).getPermissions();
+ int newMode = add ? (oldMode | permissionBits) : (oldMode & ~permissionBits);
+ NativePosixFiles.chmod(path.toString(), newMode);
}
@Override
@@ -281,9 +279,7 @@ public class UnixFileSystem extends AbstractFileSystemWithCustomStat {
@Override
protected void chmod(Path path, int mode) throws IOException {
- synchronized (path) {
- NativePosixFiles.chmod(path.toString(), mode);
- }
+ NativePosixFiles.chmod(path.toString(), mode);
}
@Override
@@ -308,19 +304,17 @@ public class UnixFileSystem extends AbstractFileSystemWithCustomStat {
@Override
public boolean createDirectory(Path path) throws IOException {
- synchronized (path) {
- // Note: UNIX mkdir(2), FilesystemUtils.mkdir() and createDirectory all
- // have different ways of representing failure!
- if (NativePosixFiles.mkdir(path.toString(), 0777)) {
- return true; // successfully created
- }
+ // Note: UNIX mkdir(2), FilesystemUtils.mkdir() and createDirectory all
+ // have different ways of representing failure!
+ if (NativePosixFiles.mkdir(path.toString(), 0777)) {
+ return true; // successfully created
+ }
- // false => EEXIST: something is already in the way (file/dir/symlink)
- if (isDirectory(path, false)) {
- return false; // directory already existed
- } else {
- throw new IOException(path + " (File exists)");
- }
+ // false => EEXIST: something is already in the way (file/dir/symlink)
+ if (isDirectory(path, false)) {
+ return false; // directory already existed
+ } else {
+ throw new IOException(path + " (File exists)");
}
}
@@ -332,9 +326,7 @@ public class UnixFileSystem extends AbstractFileSystemWithCustomStat {
@Override
protected void createSymbolicLink(Path linkPath, PathFragment targetFragment)
throws IOException {
- synchronized (linkPath) {
- NativePosixFiles.symlink(targetFragment.toString(), linkPath.toString());
- }
+ NativePosixFiles.symlink(targetFragment.toString(), linkPath.toString());
}
@Override
@@ -355,9 +347,7 @@ public class UnixFileSystem extends AbstractFileSystemWithCustomStat {
@Override
public void renameTo(Path sourcePath, Path targetPath) throws IOException {
- synchronized (sourcePath) {
- NativePosixFiles.rename(sourcePath.toString(), targetPath.toString());
- }
+ NativePosixFiles.rename(sourcePath.toString(), targetPath.toString());
}
@Override
@@ -369,12 +359,10 @@ public class UnixFileSystem extends AbstractFileSystemWithCustomStat {
public boolean delete(Path path) throws IOException {
String name = path.toString();
long startTime = Profiler.nanoTimeMaybe();
- synchronized (path) {
- try {
- return NativePosixFiles.remove(name);
- } finally {
- profiler.logSimpleTask(startTime, ProfilerTask.VFS_DELETE, name);
- }
+ try {
+ return NativePosixFiles.remove(name);
+ } finally {
+ profiler.logSimpleTask(startTime, ProfilerTask.VFS_DELETE, name);
}
}
@@ -385,14 +373,12 @@ public class UnixFileSystem extends AbstractFileSystemWithCustomStat {
@Override
public void setLastModifiedTime(Path path, long newTime) throws IOException {
- synchronized (path) {
- if (newTime == -1L) { // "now"
- NativePosixFiles.utime(path.toString(), true, 0);
- } else {
- // newTime > MAX_INT => -ve unixTime
- int unixTime = (int) (newTime / 1000);
- NativePosixFiles.utime(path.toString(), false, unixTime);
- }
+ if (newTime == -1L) { // "now"
+ NativePosixFiles.utime(path.toString(), true, 0);
+ } else {
+ // newTime > MAX_INT => -ve unixTime
+ int unixTime = (int) (newTime / 1000);
+ NativePosixFiles.utime(path.toString(), false, unixTime);
}
}