Skip to content

Commit 10393e4

Browse files
committed
core: Replace VirtualFileSystem.getStatType with getattr EnumSet
As per request, let's handle getting the Stat type not as a special case but via a generalizable getattr method that takes an EnumSet of StatAttributes. Signed-off-by: Christian Kohlschütter <[email protected]>
1 parent aa12121 commit 10393e4

20 files changed

+75
-36
lines changed

core/src/main/java/org/dcache/nfs/v3/MountServer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@ public mountres3 MOUNTPROC3_MNT_3(RpcCall call$, dirpath arg1) {
105105
try {
106106

107107
Inode rootInode = path2Inode(_vfs, mountPoint);
108-
Stat.Type type = _vfs.getStatType(rootInode);
108+
Stat.Type type = _vfs.getattr(rootInode, Stat.STAT_ATTRIBUTES_TYPE_ONLY).type();
109109

110110
if (type == Stat.Type.SYMLINK) {
111111
/*
112112
* we resolve symlink only once
113113
*/
114114
String path = _vfs.readlink(rootInode);
115115
rootInode = path2Inode(_vfs, path);
116-
type = _vfs.getStatType(rootInode);
116+
type = _vfs.getattr(rootInode, Stat.STAT_ATTRIBUTES_TYPE_ONLY).type();
117117
}
118118

119119
if (type != Stat.Type.DIRECTORY) {

core/src/main/java/org/dcache/nfs/v4/OperationLINK.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void process(CompoundContext context, nfs_resop4 result) throws ChimeraNF
5555

5656
Inode parent = context.currentInode();
5757

58-
Stat.Type inodeStatType = context.getFs().getStatType(context.savedInode());
58+
Stat.Type inodeStatType = context.getFs().getattr(context.savedInode(), Stat.STAT_ATTRIBUTES_TYPE_ONLY).type();
5959
if (inodeStatType == Stat.Type.DIRECTORY) {
6060
throw new IsDirException("Can't hard-link a directory");
6161
}

core/src/main/java/org/dcache/nfs/v4/OperationLOCKT.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.dcache.nfs.v4.xdr.offset4;
3838
import org.dcache.nfs.v4.xdr.state_owner4;
3939
import org.dcache.nfs.vfs.Inode;
40+
import org.dcache.nfs.vfs.Stat;
4041
import org.slf4j.Logger;
4142
import org.slf4j.LoggerFactory;
4243

@@ -57,7 +58,7 @@ public void process(CompoundContext context, nfs_resop4 result) throws IOExcepti
5758
throw new InvalException("zero lock len");
5859
}
5960

60-
switch (context.getFs().getStatType(inode)) {
61+
switch (context.getFs().getattr(inode, Stat.STAT_ATTRIBUTES_TYPE_ONLY).type()) {
6162
case REGULAR:
6263
// OK
6364
break;

core/src/main/java/org/dcache/nfs/v4/OperationLOOKUP.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void process(CompoundContext context, nfs_resop4 result) throws ChimeraNF
4848

4949
String name = NameFilter.convertName(_args.oplookup.objname.value);
5050

51-
Stat.Type statType = context.getFs().getStatType(context.currentInode());
51+
Stat.Type statType = context.getFs().getattr(context.currentInode(), Stat.STAT_ATTRIBUTES_TYPE_ONLY).type();
5252
if (statType == Stat.Type.SYMLINK) {
5353
throw new SymlinkException("parent not a symbolic link");
5454
}

core/src/main/java/org/dcache/nfs/v4/OperationLOOKUPP.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public OperationLOOKUPP(nfs_argop4 args) {
4646
public void process(CompoundContext context, nfs_resop4 result) throws ChimeraNFSException, IOException {
4747
final LOOKUPP4res res = result.oplookupp;
4848

49-
Stat.Type statType = context.getFs().getStatType(context.currentInode());
49+
Stat.Type statType = context.getFs().getattr(context.currentInode(), Stat.STAT_ATTRIBUTES_TYPE_ONLY).type();
5050

5151
if (statType == Stat.Type.SYMLINK) {
5252
throw new SymlinkException("get parent on a symlink");

core/src/main/java/org/dcache/nfs/v4/OperationOPEN.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ private void checkCanAccess(CompoundContext context, Inode inode, uint32_t share
316316
throw new AccessException();
317317
}
318318

319-
Stat.Type statType = context.getFs().getStatType(inode);
319+
Stat.Type statType = context.getFs().getattr(inode, Stat.STAT_ATTRIBUTES_TYPE_ONLY).type();
320320
switch (statType) {
321321
case REGULAR:
322322
// OK

core/src/main/java/org/dcache/nfs/v4/OperationOPEN_CONFIRM.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.dcache.nfs.v4.xdr.nfs_opnum4;
3232
import org.dcache.nfs.v4.xdr.nfs_resop4;
3333
import org.dcache.nfs.v4.xdr.stateid4;
34-
import org.dcache.nfs.vfs.Inode;
3534
import org.dcache.nfs.vfs.Stat;
3635
import org.slf4j.Logger;
3736
import org.slf4j.LoggerFactory;
@@ -53,7 +52,7 @@ public void process(CompoundContext context, nfs_resop4 result) throws IOExcepti
5352
throw new NotSuppException("operation OPEN_CONFIRM4 is obsolete in 4.x, x > 0");
5453
}
5554

56-
Stat.Type statType = context.getFs().getStatType(context.currentInode());
55+
Stat.Type statType = context.getFs().getattr(context.currentInode(), Stat.STAT_ATTRIBUTES_TYPE_ONLY).type();
5756

5857
if (statType == Stat.Type.DIRECTORY) {
5958
throw new IsDirException();

core/src/main/java/org/dcache/nfs/v4/OperationREADDIR.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public void process(final CompoundContext context, nfs_resop4 result) throws Chi
9494
throw new BadCookieException("bad cookie : " + startValue);
9595
}
9696

97-
Stat.Type statType = context.getFs().getStatType(dir);
97+
Stat.Type statType = context.getFs().getattr(dir, Stat.STAT_ATTRIBUTES_TYPE_ONLY).type();
9898
if (statType != Stat.Type.DIRECTORY) {
9999
throw new NotDirException();
100100
}

core/src/main/java/org/dcache/nfs/v4/OperationREADLINK.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public OperationREADLINK(nfs_argop4 args) {
4747
public void process(CompoundContext context, nfs_resop4 result) throws ChimeraNFSException, IOException {
4848
final READLINK4res res = result.opreadlink;
4949

50-
Stat.Type statType = context.getFs().getStatType(context.currentInode());
50+
Stat.Type statType = context.getFs().getattr(context.currentInode(), Stat.STAT_ATTRIBUTES_TYPE_ONLY).type();
5151
if (statType != Stat.Type.SYMLINK) {
5252
throw new InvalException("not a symlink");
5353
}

core/src/main/java/org/dcache/nfs/v4/OperationSECINFO.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void process(CompoundContext context, nfs_resop4 result) throws IOExcepti
4848

4949
final SECINFO4res res = result.opsecinfo;
5050
Inode dir = context.currentInode();
51-
Stat.Type statType = context.getFs().getStatType(dir);
51+
Stat.Type statType = context.getFs().getattr(dir, Stat.STAT_ATTRIBUTES_TYPE_ONLY).type();
5252
if (statType != Stat.Type.DIRECTORY) {
5353
throw new NotDirException();
5454
}

0 commit comments

Comments
 (0)