// Rename renames this node.
Rename renames this node.
// Rename renames this node .
func (i *inodeOperations) Rename(ctx context.Context, inode *fs.Inode, oldParent *fs.Inode, oldName string, newParent *fs.Inode, newName string, replacement bool) error {
	if len(newName) > maxFilenameLen {
		return syserror.ENAMETOOLONG
	}
	if newParent.MountSource != oldParent.MountSource {
		return syserror.EXDEV
	}
	newParentInodeOperations := newParent.InodeOperations.(*inodeOperations)
	oldParentInodeOperations := oldParent.InodeOperations.(*inodeOperations)
	if err := i.fileState.file.rename(ctx, newParentInodeOperations.fileState.file, newName); err != nil {
		return err
	}
	if fs.IsDir(i.fileState.sattr) {
		if i.session().cachePolicy.cacheUAttrs(oldParent) {
			oldParentInodeOperations.cachingInodeOps.DecLinks(ctx)
		}
		if i.session().cachePolicy.cacheUAttrs(newParent) {
			if !replacement {
				newParentInodeOperations.cachingInodeOps.IncLinks(ctx)
			}
		}
	}
	if i.session().cachePolicy.cacheReaddir() {
		oldParentInodeOperations.markDirectoryDirty()
		if oldParent != newParent {
			newParentInodeOperations.markDirectoryDirty()
		}
	}
	if i.session().cachePolicy.cacheUAttrs(inode) {
		i.cachingInodeOps.TouchStatusChangeTime(ctx)
	}
	return nil
}
func ( i * inodeOperations ) Rename ( ctx context . Context , inode * fs . Inode , oldParent * fs . Inode , oldName string , newParent * fs . Inode , newName string , replacement bool ) error { if len ( newName ) > maxFilenameLen { return syserror . ENAMETOOLONG } if newParent . MountSource != oldParent . MountSource { return syserror . EXDEV } newParentInodeOperations := newParent . InodeOperations . ( * inodeOperations ) oldParentInodeOperations := oldParent . InodeOperations . ( * inodeOperations ) if err := i . fileState . file . rename ( ctx , newParentInodeOperations . fileState . file , newName ) ; err != nil { return err } if fs . IsDir ( i . fileState . sattr ) { if i . session ( ) . cachePolicy . cacheUAttrs ( oldParent ) { oldParentInodeOperations . cachingInodeOps . DecLinks ( ctx ) } if i . session ( ) . cachePolicy . cacheUAttrs ( newParent ) { if ! replacement { newParentInodeOperations . cachingInodeOps . IncLinks ( ctx ) } } } if i . session ( ) . cachePolicy . cacheReaddir ( ) { oldParentInodeOperations . markDirectoryDirty ( ) if oldParent != newParent { newParentInodeOperations . markDirectoryDirty ( ) } } if i . session ( ) . cachePolicy . cacheUAttrs ( inode ) { i . cachingInodeOps . TouchStatusChangeTime ( ctx ) } return nil }
Rename renames this node.
Rename renames this node .
// Don't allow renames across different mounts. // Unwrap the new parent to a *inodeOperations. // Unwrap the old parent to a *inodeOperations. // Do the rename. // Is the renamed entity a directory? Fix link counts. // Update cached state. // Only IncLinks if there is a new addition to // newParent. If this is replacement, then the total // count remains the same. // Mark old directory dirty. // Mark new directory dirty. // Rename always updates ctime.