diff options
author | Mike Lockwood <lockwood@android.com> | 2010-11-19 13:52:20 -0500 |
---|---|---|
committer | Mike Lockwood <lockwood@android.com> | 2010-11-19 13:55:22 -0500 |
commit | 929b3da2fcf061219a82dcced85ffa186c742cc4 (patch) | |
tree | c957be8bd5a51c1e5290e05b7b4e7c354671f11b /media/mtp/MtpDevice.cpp | |
parent | 49fd5d99571b825bdb0c1a7a31b163872094d53d (diff) | |
download | frameworks_base-929b3da2fcf061219a82dcced85ffa186c742cc4.zip frameworks_base-929b3da2fcf061219a82dcced85ffa186c742cc4.tar.gz frameworks_base-929b3da2fcf061219a82dcced85ffa186c742cc4.tar.bz2 |
PTP: Fix permissions problems with files imported via PTP
Change-Id: I630a89c67e5b3d6d0c29e6c257f84e1909fa4de2
Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'media/mtp/MtpDevice.cpp')
-rw-r--r-- | media/mtp/MtpDevice.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/media/mtp/MtpDevice.cpp b/media/mtp/MtpDevice.cpp index 1b23a8e..416ebfe 100644 --- a/media/mtp/MtpDevice.cpp +++ b/media/mtp/MtpDevice.cpp @@ -349,7 +349,7 @@ MtpProperty* MtpDevice::getDevicePropDesc(MtpDeviceProperty code) { } // reads the object's data and writes it to the specified file path -bool MtpDevice::readObject(MtpObjectHandle handle, const char* destPath) { +bool MtpDevice::readObject(MtpObjectHandle handle, const char* destPath, int group, int perm) { LOGD("readObject: %s", destPath); int fd = ::open(destPath, O_RDWR | O_CREAT | O_TRUNC); if (fd < 0) { @@ -357,6 +357,12 @@ bool MtpDevice::readObject(MtpObjectHandle handle, const char* destPath) { return false; } + fchown(fd, getuid(), group); + // set permissions + int mask = umask(0); + fchmod(fd, perm); + umask(mask); + Mutex::Autolock autoLock(mMutex); bool result = false; |