Skip to content

Commit

Permalink
Recognize and ignore non-hierarchical storage.
Browse files Browse the repository at this point in the history
  • Loading branch information
hanwen committed Jun 12, 2012
1 parent 6f86906 commit 5be46d6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 6 additions & 1 deletion fs.go
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ func (n *rootNode) StatFs() *fuse.StatfsOut {


func (fs *DeviceFs) OnMount(conn *fuse.FileSystemConnector) { func (fs *DeviceFs) OnMount(conn *fuse.FileSystemConnector) {
for _, s := range fs.dev.ListStorage() { for _, s := range fs.dev.ListStorage() {
if !s.IsHierarchical() {
log.Printf("skipping non hierarchical storage %q", s.Description())
continue
}

folder := fs.newFolder(NOPARENT_ID, s.Id()) folder := fs.newFolder(NOPARENT_ID, s.Id())
inode := fs.root.Inode().New(true, folder) inode := fs.root.Inode().New(true, folder)
fs.root.Inode().AddChild(s.Description(), inode) fs.root.Inode().AddChild(s.Description(), inode)
Expand Down Expand Up @@ -205,7 +210,7 @@ func (n *fileNode) send() error {
n.error = fuse.OK n.error = fuse.OK
n.file.filesize = 0 n.file.filesize = 0
log.Printf("not sending file %q due to write errors", n.file.Name()) log.Printf("not sending file %q due to write errors", n.file.Name())
return fuse.EIO // TODO - send back n.error return syscall.EIO // TODO - send back n.error
} }


fi, err := os.Stat(n.backing) fi, err := os.Stat(n.backing)
Expand Down
9 changes: 9 additions & 0 deletions mtp.go
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -261,6 +261,15 @@ const DateModified = C.LIBMTP_PROPERTY_DateModified
//////////////// ////////////////
// DeviceStorage // DeviceStorage


func (d *DeviceStorage) IsHierarchical() bool {
return d.FilesystemType == 0x02
}

func (d *DeviceStorage) IsRemovable() bool {
return (d.StorageType == 0x02 || // PTP_ST_RemovableROM
d.StorageType == 0x04) // C.PTP_ST_RemovableRAM
}

func (d *DeviceStorage) me() *C.LIBMTP_devicestorage_t { func (d *DeviceStorage) me() *C.LIBMTP_devicestorage_t {
return (*C.LIBMTP_devicestorage_t)(d) return (*C.LIBMTP_devicestorage_t)(d)
} }
Expand Down

0 comments on commit 5be46d6

Please sign in to comment.