Permalink
Browse files

Recognize and ignore non-hierarchical storage.

  • Loading branch information...
1 parent 6f86906 commit 5be46d649e9448964e371b4a15772179de6bfd42 @hanwen committed Jun 12, 2012
Showing with 15 additions and 1 deletion.
  1. +6 −1 fs.go
  2. +9 −0 mtp.go
View
7 fs.go
@@ -148,6 +148,11 @@ func (n *rootNode) StatFs() *fuse.StatfsOut {
func (fs *DeviceFs) OnMount(conn *fuse.FileSystemConnector) {
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())
inode := fs.root.Inode().New(true, folder)
fs.root.Inode().AddChild(s.Description(), inode)
@@ -205,7 +210,7 @@ func (n *fileNode) send() error {
n.error = fuse.OK
n.file.filesize = 0
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)
View
9 mtp.go
@@ -261,6 +261,15 @@ const DateModified = C.LIBMTP_PROPERTY_DateModified
////////////////
// 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 {
return (*C.LIBMTP_devicestorage_t)(d)
}

0 comments on commit 5be46d6

Please sign in to comment.