Added inode.SetAttributes.

geesefs-0-30-9
Aaron Jacobs 2015-03-06 05:50:58 +11:00
parent 08f5bb7ced
commit 08afae57de
1 changed files with 19 additions and 0 deletions

View File

@ -369,3 +369,22 @@ func (inode *inode) WriteAt(p []byte, off int64) (n int, err error) {
return
}
// Update attributes from non-nil parameters.
//
// EXCLUSIVE_LOCKS_REQUIRED(inode.mu)
func (inode *inode) SetAttributes(size *uint64) {
// Update the modification time.
inode.attributes.Mtime = inode.clock.Now()
// Do we need to truncate?
if size != nil {
intSize := int(*size)
if intSize <= len(inode.contents) {
inode.contents = inode.contents[:intSize]
} else {
padding := make([]byte, intSize-len(inode.contents))
inode.contents = append(inode.contents, padding...)
}
}
}