// Lookup loads an Inode at name into a Dirent based on the session's cache
// policy.
Lookup loads an Inode at name into a Dirent based on the session's cache
policy.
// Lookup loads an Inode at name into a Dirent based on the session ' s cache // policy .
func (i *inodeOperations) Lookup(ctx context.Context, dir *fs.Inode, name string) (*fs.Dirent, error) {
	if len(name) > maxFilenameLen {
		return nil, syserror.ENAMETOOLONG
	}
	cp := i.session().cachePolicy
	if cp.cacheReaddir() {
		i.readdirMu.Lock()
		if i.readdirCache != nil && !i.readdirCache.Contains(name) {
			i.readdirMu.Unlock()
			if cp.cacheNegativeDirents() {
				return fs.NewNegativeDirent(name), nil
			}
			return nil, syserror.ENOENT
		}
		i.readdirMu.Unlock()
	}
	qids, newFile, mask, p9attr, err := i.fileState.file.walkGetAttr(ctx, []string{name})
	if err != nil {
		if err == syserror.ENOENT {
			if cp.cacheNegativeDirents() {
				return fs.NewNegativeDirent(name), nil
			}
			return nil, syserror.ENOENT
		}
		return nil, err
	}
	if i.session().overrides != nil {
		deviceKey := device.MultiDeviceKey{
			Device:          p9attr.RDev,
			SecondaryDevice: i.session().connID,
			Inode:           qids[0].Path,
		}
		unlock := i.session().overrides.lock()
		if pipeInode := i.session().overrides.getPipe(deviceKey); pipeInode != nil {
			unlock()
			pipeInode.IncRef()
			return fs.NewDirent(ctx, pipeInode, name), nil
		}
		unlock()
	}
	sattr, node := newInodeOperations(ctx, i.fileState.s, newFile, qids[0], mask, p9attr)
	return fs.NewDirent(ctx, fs.NewInode(ctx, node, dir.MountSource, sattr), name), nil
}
func ( i * inodeOperations ) Lookup ( ctx context . Context , dir * fs . Inode , name string ) ( * fs . Dirent , error ) { if len ( name ) > maxFilenameLen { return nil , syserror . ENAMETOOLONG } cp := i . session ( ) . cachePolicy if cp . cacheReaddir ( ) { i . readdirMu . Lock ( ) if i . readdirCache != nil && ! i . readdirCache . Contains ( name ) { i . readdirMu . Unlock ( ) if cp . cacheNegativeDirents ( ) { return fs . NewNegativeDirent ( name ) , nil } return nil , syserror . ENOENT } i . readdirMu . Unlock ( ) } qids , newFile , mask , p9attr , err := i . fileState . file . walkGetAttr ( ctx , [ ] string { name } ) if err != nil { if err == syserror . ENOENT { if cp . cacheNegativeDirents ( ) { return fs . NewNegativeDirent ( name ) , nil } return nil , syserror . ENOENT } return nil , err } if i . session ( ) . overrides != nil { deviceKey := device . MultiDeviceKey { Device : p9attr . RDev , SecondaryDevice : i . session ( ) . connID , Inode : qids [ 0 ] . Path , } unlock := i . session ( ) . overrides . lock ( ) if pipeInode := i . session ( ) . overrides . getPipe ( deviceKey ) ; pipeInode != nil { unlock ( ) pipeInode . IncRef ( ) return fs . NewDirent ( ctx , pipeInode , name ) , nil } unlock ( ) } sattr , node := newInodeOperations ( ctx , i . fileState . s , newFile , qids [ 0 ] , mask , p9attr ) return fs . NewDirent ( ctx , fs . NewInode ( ctx , node , dir . MountSource , sattr ) , name ) , nil }
Lookup loads an Inode at name into a Dirent based on the session's cache
policy.
Lookup loads an Inode at name into a Dirent based on the session ' s cache policy .
// Check to see if we have readdirCache that indicates the // child does not exist.  Avoid holding readdirMu longer than // we need to. // No such child. // Get a p9.File for name. // Return a negative Dirent. It will stay cached until something // is created over it. // Check if file belongs to a internal named pipe. Note that it doesn't need // to check for sockets because it's done in newInodeOperations below. // Construct the Inode operations. // Construct a positive Dirent.