list returns the children of the node with id 'parentID'. Dirent consists of: Inode uint64 Type DirentType (optional) Name string TODO(pmattis): lookup all inodes and fill in the type, this will save a Getattr().
(parentID uint64)
| 153 | // Name string |
| 154 | // TODO(pmattis): lookup all inodes and fill in the type, this will save a Getattr(). |
| 155 | func (cfs CFS) list(parentID uint64) ([]fuse.Dirent, error) { |
| 156 | rows, err := cfs.db.Query(`SELECT name, id FROM fs_namespace WHERE parentID = ?`, parentID) |
| 157 | if err != nil { |
| 158 | return nil, err |
| 159 | } |
| 160 | |
| 161 | var results []fuse.Dirent |
| 162 | for rows.Next() { |
| 163 | dirent := fuse.Dirent{Type: fuse.DT_Unknown} |
| 164 | if err := rows.Scan(&dirent.Name, &dirent.Inode); err != nil { |
| 165 | return nil, err |
| 166 | } |
| 167 | results = append(results, dirent) |
| 168 | } |
| 169 | if err := rows.Err(); err != nil { |
| 170 | return nil, err |
| 171 | } |
| 172 | |
| 173 | return results, nil |
| 174 | } |
| 175 | |
| 176 | // validateRename takes a source and destination node and verifies that |
| 177 | // a rename can be performed from source to destination. |
no test coverage detected