Skip to content

Commit

Permalink
return summary about storages from statfs
Browse files Browse the repository at this point in the history
  • Loading branch information
whoozle committed Apr 23, 2015
1 parent 5892fcb commit e8cfd44
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion mtp/fuse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,25 @@ namespace
return 0;
}

int StatFS (const char *path, struct statvfs *stat)
int StatFS (const char *path_, struct statvfs *stat)
{
stat->f_namemax = 254;

std::string path(path_);
if (path != "/")
return -ENOENT;

mtp::u64 freeSpace = 0, capacity = 0;
mtp::scoped_mutex_lock l(_mutex);
for(auto storage = _storages.begin(); storage != _storages.end(); ++storage)
{
mtp::msg::StorageInfo si = _session->GetStorageInfo(storage->second);
freeSpace += si.FreeSpaceInBytes;
capacity += si.MaxCapacity;
}
stat->f_frsize = 1024;
stat->f_blocks = capacity / stat->f_frsize;
stat->f_bfree = stat->f_bavail = freeSpace / stat->f_frsize;
return 0;
}

Expand Down

0 comments on commit e8cfd44

Please sign in to comment.