populateAttr should only be called once n.ss is known to be set and non-nil
()
| 280 | // populateAttr should only be called once n.ss is known to be set and |
| 281 | // non-nil |
| 282 | func (n *node) populateAttr() error { |
| 283 | meta := n.meta |
| 284 | |
| 285 | n.attr.Mode = meta.FileMode() |
| 286 | |
| 287 | if n.fs.IgnoreOwners { |
| 288 | n.attr.Uid = uint32(os.Getuid()) |
| 289 | n.attr.Gid = uint32(os.Getgid()) |
| 290 | executeBit := n.attr.Mode & 0100 |
| 291 | n.attr.Mode = (n.attr.Mode ^ n.attr.Mode.Perm()) | 0400 | executeBit |
| 292 | } else { |
| 293 | n.attr.Uid = uint32(meta.MapUid()) |
| 294 | n.attr.Gid = uint32(meta.MapGid()) |
| 295 | } |
| 296 | |
| 297 | // TODO: inode? |
| 298 | |
| 299 | if mt := meta.ModTime(); !mt.IsZero() { |
| 300 | n.attr.Mtime = mt |
| 301 | } else { |
| 302 | n.attr.Mtime = n.pnodeModTime |
| 303 | } |
| 304 | |
| 305 | switch meta.Type() { |
| 306 | case schema.TypeFile: |
| 307 | n.attr.Size = uint64(meta.PartsSize()) |
| 308 | n.attr.Blocks = 0 // TODO: set? |
| 309 | n.attr.Mode |= 0400 |
| 310 | case schema.TypeDirectory: |
| 311 | n.attr.Mode |= 0500 |
| 312 | case schema.TypeSymlink: |
| 313 | n.attr.Mode |= 0400 |
| 314 | default: |
| 315 | Logger.Printf("unknown attr ss.Type %q in populateAttr", meta.Type()) |
| 316 | } |
| 317 | return nil |
| 318 | } |
| 319 | |
| 320 | func (fs *CamliFileSystem) Root() (fusefs.Node, error) { |
| 321 | return fs.root, nil |