コード例 #1
0
ファイル: OperationLOOKUP.java プロジェクト: svenin/nfs4j
  @Override
  public void process(CompoundContext context, nfs_resop4 result)
      throws ChimeraNFSException, IOException {
    final LOOKUP4res res = result.oplookup;

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

    Stat stat = context.getFs().getattr(context.currentInode());
    if (stat.type() == Stat.Type.SYMLINK) {
      throw new SymlinkException("parent not a symbolic link");
    }

    if (stat.type() != Stat.Type.DIRECTORY) {
      throw new NotDirException("parent not a directory");
    }

    Inode newInode = context.getFs().lookup(context.currentInode(), name);

    context.currentInode(newInode);
    context.currentStateid(Stateids.ZeroStateId());
    res.status = nfsstat.NFS_OK;
  }
コード例 #2
0
 @Before
 public void setup() throws Exception {
   dirHandle = new FileHandle(0, 1, 0, new byte[] {0, 0, 0, 1}); // the dir we want to read
   dirInode = new Inode(dirHandle);
   dirStat = new Stat(); // the stat marking it as a dir
   //noinspection OctalInteger
   dirStat.setMode(Stat.S_IFDIR | 0755);
   dirStat.setMTime(System.currentTimeMillis());
   dirStat.setATime(System.currentTimeMillis());
   dirStat.setCTime(System.currentTimeMillis());
   dirStat.setGeneration(1);
   dirStat.setNlink(2);
   dirStat.setUid(1);
   dirStat.setGid(2);
   dirStat.setDev(1);
   dirStat.setFileid(1);
   dirStat.setSize(512);
   vfs = Mockito.mock(VirtualFileSystem.class); // the vfs serving it
   Mockito.when(vfs.getattr(Mockito.eq(dirInode))).thenReturn(dirStat);
   ExportFile exportFile =
       new ExportFile(this.getClass().getResource("simpleExports").toURI()); // same package as us
   nfsServer = new NfsServerV3(exportFile, vfs);
 }