chromiumos/platform/cros-disks.git
14 months agoAvoid relaying events from mobile broadband devices supported by mist. 30/65730/2 master
Ben Chan [Tue, 13 Aug 2013 19:21:06 +0000 (12:21 -0700)]
Avoid relaying events from mobile broadband devices supported by mist.

BUG=chromium:272403
TEST=Tested the following:
1. Build and run unit tests.
2. Run platform_CrosDisksDBus and platform_CrosDisksFilesystem tests.
3. Run this command in a root shell:

   dbus-monitor --system --monitor 'interface=org.chromium.CrosDisks'

   Verify that cros-disks does not emit any DeviceScanned, DeviceAdded,
   or DeviceRemoved signal after a 3G dongle is inserted and then
   removed from the system.

Change-Id: If1d1306e2426273b1c4d9fafc0c11c6a7bd3eb26
Reviewed-on: https://gerrit.chromium.org/gerrit/65730
Tested-by: Ben Chan <benchan@chromium.org>
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>

14 months agoIgnore all virtual block devices except loop devices. 66/63666/3 firmware-pit-4482.B stabilize-4512.B
Ben Chan [Mon, 29 Jul 2013 22:52:29 +0000 (15:52 -0700)]
Ignore all virtual block devices except loop devices.

This CL modifies DiskManager to ignore all virtual block devices, except
loop devices, when enumerating devices and processing udev events.

BUG=chromium:265683
TEST=Tested the following:
1. Build and run unit tests.
2. Run the following tests:
   - platform_CrosDisksDBus
   - platform_CrosDisksFilesystem
3. Verify that no virtual block devices, except loop devices, are
   reported when running the following command on lumpy:

   dbus-send --system --print-reply --dest=org.chromium.CrosDisks \
       /org/chromium/CrosDisks org.chromium.CrosDisks.EnumerateDevices

Change-Id: I8315af19de914c75db350dfca5dc27faf713af73
Reviewed-on: https://gerrit.chromium.org/gerrit/63666
Tested-by: Ben Chan <benchan@chromium.org>
Reviewed-by: Luigi Semenzato <semenzato@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>

15 months agoRefine device UUID property. 25/63325/3 factory-pit-4471.B
Ben Chan [Thu, 25 Jul 2013 06:39:29 +0000 (23:39 -0700)]
Refine device UUID property.

This CL refines the computation of the UUID of devices by taking various
device information into account.

BUG=chromium:218439
TEST=Tested the following:
1. Build and run unit tests.
2. Run platform_CrosDisksDBus and platform_CrosDisksFilesystem tests.
3. Manually test mounting different removable USB devices and verify the
   UUID of devices return by org.chromium.CrosDisks.GetDeviceProperties.

Change-Id: Id3d747c5aacdeedeb1dfe3a77ec3065daecf88c5
Reviewed-on: https://gerrit.chromium.org/gerrit/63325
Reviewed-by: Toni Barzic <tbarzic@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
16 months agoRemove unnecessary call to the deprecated g_thread_init(). 81/59681/2 factory-4455.B factory-pit-4390.B firmware-falco_peppy-4389.B firmware-leon-4389.26.B firmware-wolf-4389.24.B release-R29-4319.B stabilize-4443.B
Ben Chan [Sat, 22 Jun 2013 12:53:16 +0000 (05:53 -0700)]
Remove unnecessary call to the deprecated g_thread_init().

g_thread_init() has been deprecated since glib 2.32. This CL removes the
unnecessary call to g_thread_init(), so that we can later migrate to
glib 2.34.

BUG=chromium:253025
TEST=Tested the following:
1. Build and run unit tests.
2. Run the following tests:
   - platform_CrosDisksDBus
   - platform_CrosDisksFilesystem
   - platform_CrosDisksArchive
   - platform_CrosDisksFormat

Change-Id: I1df405d9b30737f89574012369d06ccd52fb5a9f
Reviewed-on: https://gerrit.chromium.org/gerrit/59681
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>

16 months agoHide mobile broadband devices supported by mist. 92/58992/2
Ben Chan [Tue, 18 Jun 2013 06:33:28 +0000 (23:33 -0700)]
Hide mobile broadband devices supported by mist.

BUG=chromium:251180
TEST=Tested the following:
1. Build and run unit tests.
2. Run platform_CrosDisksDBus and platform_CrosDisksFilesystem tests.
3. Manually verify that CrOS File Manager:
   - Mount a regular USB drive
   - Do not mount a USB drive exposed by a 3G dongle

Change-Id: Ia14b11034001cb90cb7d533c0982304b58611e7d
Reviewed-on: https://gerrit.chromium.org/gerrit/58992
Reviewed-by: Darin Petkov <petkov@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
16 months agoExtend archive manager to support multiple user profiles. 97/56897/5 factory-4290.B factory-pit-4280.B factory-spring-4262.B stabilize-4255.B stabilize-4287.B
Ben Chan [Wed, 29 May 2013 03:30:30 +0000 (20:30 -0700)]
Extend archive manager to support multiple user profiles.

This CL extends archive manager to support mounting archives under
/home/chronos/u-<userid>/{Downloads,GCache} in the context of multiple
user profiles. As a side effect, it also removes optional AVFS mount
paths.

BUG=chromium:221769
TEST=Tested the following:
1. Build cros-disks for {x86,amd64,arm}-generic.
2. Run cros-disks unit tests.
3. Run platform_CrosDisksArchive tests.
4. Use CrOS File Manager to open a ZIP file:
   - on a removable USB drive
   - in a user's Downloads folder
   - in a user's Google Drive folder
   - in another mounted ZIP file

Change-Id: I7a9930a0b7eefd40ab66d167bc49d58af628af78
Reviewed-on: https://gerrit.chromium.org/gerrit/56897
Reviewed-by: Darin Petkov <petkov@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>

17 months agoIgnore device events with no associated udev device. 31/55631/2
Ben Chan [Sat, 18 May 2013 22:09:25 +0000 (15:09 -0700)]
Ignore device events with no associated udev device.

This CL removes the assertion on |dev| in DiskManager::GetDeviceEvents()
as udev_monitor_receive_device() sometimes returns NULL even when
g_io_add_watch_full on the udev monitor notifies that there is some data
to read.

BUG=chromium:242057
TEST=Tested the following:
1. Run unit tests.
2. Run platform_CrosDisksDBus and platform_CrosDisksFilesystem tests.
3. Manually verify that CrOS File Manager detects the insertion and
   removal events of an external USB drive.

Change-Id: I0c435a2053a3210a64906a997bd88fe9083ff4f8
Reviewed-on: https://gerrit.chromium.org/gerrit/55631
Reviewed-by: Darin Petkov <petkov@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
17 months agoFix flaky UdevDeviceTest::GetMountPaths unit test. 62/50862/2 factory-4128.B factory-spring-4131.B
Ben Chan [Fri, 10 May 2013 18:51:48 +0000 (11:51 -0700)]
Fix flaky UdevDeviceTest::GetMountPaths unit test.

After UdevDeviceTest::SetUpTestCase runs, the mounted device used for
the unit tests may no longer be mounted, which potentially fails
UdevDeviceTest::GetMountPaths. This CL changes
UdevDeviceTest::SetUpTestCase to use a mounted boot device for tests
that expect a mounted device.

BUG=chromium:239053
TEST=Run cros-disks unit tests repeatedly.

Change-Id: Ic0d1ab7c2987c515a2ad86dd1384e5f61c41f1d4
Reviewed-on: https://gerrit.chromium.org/gerrit/50862
Reviewed-by: Darin Petkov <petkov@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
17 months agoAdd cros-disks GYP file 49/39049/18
Liam McLoughlin [Mon, 6 May 2013 12:06:50 +0000 (08:06 -0400)]
Add cros-disks GYP file

BUG=chromium:220003
TEST=Run emerge-<board> -v platform2 with and without platform2 USE
flag on a range of boards plus the host
Change-Id: I9389840cde2f6567309e41206214d4e3b4954e2c
Reviewed-on: https://gerrit.chromium.org/gerrit/39049
Commit-Queue: Liam McLoughlin <lmcloughlin@chromium.org>
Reviewed-by: Liam McLoughlin <lmcloughlin@chromium.org>
Tested-by: Liam McLoughlin <lmcloughlin@chromium.org>
17 months agoRefacter mount manager registration in CrosDisksServer. 51/50051/2 release-R28-4100.B stabilize-4100.38.B stabilize-spring-4100.53.B toolchainB
Ben Chan [Fri, 3 May 2013 18:28:57 +0000 (11:28 -0700)]
Refacter mount manager registration in CrosDisksServer.

BUG=chromium:237869
TEST=Tested the following:
1. Build cros-disks for {x86,amd64,arm}-generic.
2. Run cros-disks unit tests.
3. Run the following autotest tests:
   - platform_CrosDisksDBus
   - platform_CrosDisksArchive
   - platform_CrosDisksFilesystem

Change-Id: I1c2223904b102c0d326de029ecd3c314709ef778
Reviewed-on: https://gerrit.chromium.org/gerrit/50051
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
18 months agoRemove the 'user' argument from code handling session state changes. 60/48960/2 stabilize-4068.0.B
Ben Chan [Tue, 23 Apr 2013 20:57:55 +0000 (13:57 -0700)]
Remove the 'user' argument from code handling session state changes.

The 'user' argument is being removed from the
SessionManager.OnSessionStateChanged DBus signal. The 'user' argument
has not been used by cros-disks, so this CL does not introduce any
behavioral changes.

BUG=chromium:234767
TEST=Tested the following:
1. Build cros-disks for {x86,amd64,arm}-generic.
2. Run cros-disks unit tests.
3. Run the following autotest tests:
   - platform_CrosDisksDBus
   - platform_CrosDisksArchive
   - platform_CrosDisksFilesystem

Change-Id: I68572ae06d15eced7659230cecbe30752f7d4f9d
Reviewed-on: https://gerrit.chromium.org/gerrit/48960
Reviewed-by: Chris Masone <cmasone@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>

18 months agoUse base::CommandLine instead gflags for parsing command line. 67/48167/3 stabilize-4008.0.B stabilize-4035.0.B
Ben Chan [Mon, 15 Apr 2013 22:40:52 +0000 (15:40 -0700)]
Use base::CommandLine instead gflags for parsing command line.

BUG=chromium:231682
TEST=Tested the following:
1. Build and run unit tests.
2. Verify cros-disks is launched properly by upstart.
3. Verify different command line switches:
     /opt/google/cros-disks/disks --help
     /opt/google/cros-disks/disks --foreground
     /opt/google/cros-disks/disks --foreground --log-level=0

Change-Id: Ib40a6586b25ee8abaec1717e143cae46f3795878
Reviewed-on: https://gerrit.chromium.org/gerrit/48167
Commit-Queue: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Reviewed-by: Darin Petkov <petkov@chromium.org>
19 months agoDetect MMC/SD card readers based on device driver. 17/44117/2 factory-spring-3842.B firmware-spring-3824.4.B firmware-spring-3824.55.B firmware-spring-3824.84.B firmware-spring-3824.B firmware-spring-3833.B release-R27-3912.B stabilize-3881.0.B stabilize-3912.79.B toolchainA
Ben Chan [Wed, 27 Feb 2013 00:09:34 +0000 (16:09 -0800)]
Detect MMC/SD card readers based on device driver.

BUG=chrome-os-partner:18031
TEST=Tested the following:
1. Build and run unit tests.
2. Insert a SD card to the built-in SD card reader on daisy and verify
   that the following command reports DeviceMediaType as 2 (SD):

     dbus-send --system --print-reply --type=method_call \
         --dest=org.chromium.CrosDisks \
         /org/chromium/CrosDisks \
         org.chromium.CrosDisks.GetDeviceProperties \
         string:/dev/mmcblk1p1

   Also verify that CrOS File Manager shows a SD card icon for the
   mounted SD card.

Change-Id: I4104cdc83b18a40b9463a923de03343d3a4a7370
Reviewed-on: https://gerrit.chromium.org/gerrit/44117
Reviewed-by: Darin Petkov <petkov@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
20 months agoUse base::FilePath instead of FilePath. 02/43402/2
Ben Chan [Fri, 15 Feb 2013 19:40:04 +0000 (11:40 -0800)]
Use base::FilePath instead of FilePath.

FilePath is moved into the base namespace in libchrome-180609.

BUG=chromium-os:38956
TEST=`FEATURES=test emerge-lumpy cros-disks`

Change-Id: I877b5f65c834dc45ee9de58519c42a2290d0bb21
Reviewed-on: https://gerrit.chromium.org/gerrit/43402
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
20 months agoFix Makefile to allow *RunAsRoot* unit tests to run. 92/43292/3
Ben Chan [Thu, 14 Feb 2013 18:32:33 +0000 (10:32 -0800)]
Fix Makefile to allow *RunAsRoot* unit tests to run.

Commit "cros-disks: Updating common.mk to ToT to enable profiling"
(4ded6dba01100c24f47b14736b85e1c10701341a) causes *RunAsRoot* unit tests
no longer run by the Makefile. This CL reverts the Makefile changes.

BUG=chromium-os:38927
TEST=Run unit tests and verify that *RunAsRoot* tests are run.

Change-Id: I40279a0a64a92c52279b48fd311a7354bd36dd9f
Reviewed-on: https://gerrit.chromium.org/gerrit/43292
Tested-by: Ben Chan <benchan@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>

20 months agoUpdate to build against libchrome-180609. 41/43341/3
Ben Chan [Thu, 14 Feb 2013 22:59:33 +0000 (14:59 -0800)]
Update to build against libchrome-180609.

This CL updates code to handle the following changes in
libchrome-180609:
- scoped_temp_dir.h is moved to base/files/scoped_temp_dir.h
- ScopedTempDir is moved to the base namespace

BUG=chromium-os:38956
TEST=`FEATURES=test emerge-lumpy cros-disks`
CQ-DEPEND=I64593fdb1352f46474658a296f347d2333980f9d

Change-Id: Ic5f6472ca9561ed817054154eb9ed08da8c5f4c4
Reviewed-on: https://gerrit.chromium.org/gerrit/43341
Commit-Queue: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Reviewed-by: Chris Masone <cmasone@chromium.org>
20 months agoRemove irrelevant unit tests. 91/43291/2
Ben Chan [Thu, 14 Feb 2013 18:22:10 +0000 (10:22 -0800)]
Remove irrelevant unit tests.

Commit "Filter unsafe mount options."
(8c4eafa201560f9de4afbac4d2648c167af3ddd0) sanitizes mount options being
passed to mounters. This CL removes unit tests that check for invalid
mount options, which are no longer relevant.

BUG=chromium-os:38816
TEST=Build and run unit tests.

Change-Id: I7513c28369099ef5436ce37b1487d559fe41ff42
Reviewed-on: https://gerrit.chromium.org/gerrit/43291
Reviewed-by: Jorge Lucangeli Obes <jorgelo@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
20 months agoFilter unsafe mount options. 87/43087/6 release-R26-3701.B stabilize-3701.30.0 stabilize-3701.30.0b stabilize-3701.46.B stabilize-3701.81.B toolchain-3701.42.B
Jorge Lucangeli Obes [Tue, 12 Feb 2013 05:28:16 +0000 (21:28 -0800)]
Filter unsafe mount options.

Only pass safe mount options to the 'mount' command/system call.

BUG=chromium-os:38816
TEST=unit, platform_CrosDisks* on lumpy
TEST=Insert USB drive (FAT/NTFS), File Manager can read/write.

Change-Id: I6fead8e40130b118df737b470423912f2438ad1e
Reviewed-on: https://gerrit.chromium.org/gerrit/43087
Reviewed-by: Jorge Lucangeli Obes <jorgelo@chromium.org>
Tested-by: Jorge Lucangeli Obes <jorgelo@chromium.org>
Commit-Queue: Jorge Lucangeli Obes <jorgelo@chromium.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
20 months agocros-disks: Updating common.mk to ToT to enable profiling 86/42786/3 stabilize-bluetooth-smart
Ryan Harrison [Wed, 6 Feb 2013 21:40:33 +0000 (16:40 -0500)]
cros-disks: Updating common.mk to ToT to enable profiling

This update replaces the current common.mk used in this project with the newest
version. This will allow all of the common.mk based projects to be on the same
version for debugging and enables profiling support.

BUG=chromium-os:37854
TEST=Exectuted the following commands to confirm the build works:
     MODE=profiling cros_workon_make --board=link
     MODE=profiling cros_workon_make --board=link --test
     cros_workon_make --board=link
     cros_workon_make --board=link --test
     Repeated these with emerge-link, USE=profiling, and
     FEATURES=test as need.
     For the emerge command with profiling and testing enable, confirmed the
     appropriate coverage files were created in /usr/share/profiling/...

Change-Id: I78168028ad67c45fb220ab3d618a8eaaa09e3fe7
Reviewed-on: https://gerrit.chromium.org/gerrit/42786
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Tested-by: Ryan Harrison <rharrison@chromium.org>
21 months agoAdd exFAT support. 00/41600/3 stabilize-3658.0.0
Ben Chan [Tue, 8 Jan 2013 23:29:22 +0000 (15:29 -0800)]
Add exFAT support.

This CL adds exFAT support via a FUSE-based implementation of exFAT
filesystem. The exfat-fuse process is constrained with limited POSIX
capabilities via libminijail.

BUG=chromium-os:38009
TEST=Tested the following:
1. Run unit tests.
2. Run platform_CrosDisksFilesystem tests.
3. Manually verify that CrOS File Manager can detect, mount, and unmount
   an exFAT-formatted removable drive and perform read and write
   operations on the exFAT filesystem. Verify that the exfat-fuse
   process runs as the 'fuse-exfat' user and group.

Change-Id: I70a9bef1b407d1ca688857ba5aefc19520282cba
Reviewed-on: https://gerrit.chromium.org/gerrit/41600
Reviewed-by: Darin Petkov <petkov@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
21 months agoImplement a generic FUSE-based filesystem mounter. 99/41599/3
Ben Chan [Thu, 17 Jan 2013 23:21:01 +0000 (15:21 -0800)]
Implement a generic FUSE-based filesystem mounter.

This CL refactors the NTFSMounter class into a generic FUSEMounter class
for mounting FUSE-based filesystems, which can be extended to support
other FUSE-based filesystem mounters.

BUG=chromium-os:38009
TEST=Tested the following:
1. Run unit tests.
2. Run platform_CrosDisksFilesystem tests.

Change-Id: I54ae6aaf8bf60101c4d1fec76764d3597a3cb792
Reviewed-on: https://gerrit.chromium.org/gerrit/41599
Reviewed-by: Darin Petkov <petkov@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
21 months agoImprove code for device event monitoring via GIO. 67/40267/3 factory-3536.B
Ben Chan [Fri, 28 Dec 2012 14:56:27 +0000 (06:56 -0800)]
Improve code for device event monitoring via GIO.

BUG=chromium-os:37229
TEST=Tested the following:
1. Run unit tests.
2. Run platform_CrosDisksDBus and platform_CrosDisksFilesystem tests.
3. Manually verify that CrOS File Manager detects the insertion and
   removal events of an external USB drive.

Change-Id: I8ec5b048d270d13a9af0aa1c442241adb018d6cc
Reviewed-on: https://gerrit.chromium.org/gerrit/40267
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Reviewed-by: Darin Petkov <petkov@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>

23 months agoPass disk's device_file to format_manager Formatting method. 47/38447/2 stabilize-3428.110.0 stabilize-3428.149.B stabilize2 toolchain-3428.65.B
Toni Barzic [Wed, 21 Nov 2012 02:15:46 +0000 (18:15 -0800)]
Pass disk's device_file to format_manager Formatting method.

The formatting process expects to get device_file, not device_path (chrome used
to call formatting method with device_file, but that has recently changed (mea
culpa)).

BUG=chromium:161904
TEST=confirm formatting works; unit_tests; platform_CrosDisksFormat

Change-Id: Id67dda553152fa8fc88871a617515b5a41783315
Reviewed-on: https://gerrit.chromium.org/gerrit/38447
Reviewed-by: Ben Chan <benchan@chromium.org>
Commit-Ready: Toni Barzic <tbarzic@chromium.org>
Tested-by: Toni Barzic <tbarzic@chromium.org>
2 years agoAllow the 'chronos' user to call org.chromium.CrosDisks.Format.
Ben Chan [Thu, 18 Oct 2012 05:36:56 +0000 (22:36 -0700)]
Allow the 'chronos' user to call org.chromium.CrosDisks.Format.

BUG=none
TEST=Tested the following:
1. Build and run unit tests.
2. Run platform_CrosDisksFormat autotest.
3. Manually invoke org.chromium.CrosDisks.Format using dbus-send under
   the chronos user.

Change-Id: I1ae648d102469f994f61339ed76b44229b751f09
Reviewed-on: https://gerrit.chromium.org/gerrit/35931
Commit-Ready: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Reviewed-by: Darin Petkov <petkov@chromium.org>
2 years agoFix the optical drive check when ejecting devices on unmount. factory-2993.B factory-3004.B
Ben Chan [Wed, 3 Oct 2012 19:55:16 +0000 (12:55 -0700)]
Fix the optical drive check when ejecting devices on unmount.

This CL modifies DiskManager to maintain a mapping of mount paths to
device files that should be ejected on unmount. This avoids the need to
determine if a device is an optical drive through the ID_CDROM udev
property, which is not set at the time DiskManager checks it.

BUG=chrome-os-partner:12608
TEST=Tested the following:
1. Build cros-disks for {x86,amd64,arm}-generic.
2. Run cros-disks unit tests.
3. Run platform_CrosDisksDBus and platform_CrosDisksFilesystem tests.
4. Manually verify that the DVD driver ejects a disc when:
   - Clicking the eject icon from File Manager.
   - Pressing the eject button on the DVD drive only once.

Change-Id: I3ffa7c13fd6be8e507c757d5b6afc09055b18f1b
Reviewed-on: https://gerrit.chromium.org/gerrit/34592
Commit-Ready: Ben Chan <benchan@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
2 years agoDisallow formatting of boot devices. factory-2985.B
Ben Chan [Fri, 28 Sep 2012 06:47:00 +0000 (23:47 -0700)]
Disallow formatting of boot devices.

BUG=chromium-os:34171
TEST=Tested the following:
1. Build and run cros-disks unit tests.
2. Run platform_CrosDisksFormat test.
3. Manually format a non-boot device using org.chromium.CrosDisks.Format
   DBus API and it succeeds.
4. Manually format a boot device using org.chromium.CrosDisks.Format
   DBus API and it fails.
CQ-DEPEND=I934bcf44075d38d0326b5b89cbe05ee784d131f4

Change-Id: Id3cd4a3a1ede7fdbc62b10b8bd0114d868fec844
Reviewed-on: https://gerrit.chromium.org/gerrit/34264
Reviewed-by: Darin Petkov <petkov@chromium.org>
Commit-Ready: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
2 years agoAdd support for "lazy" unmount option.
Haixia Shi [Thu, 20 Sep 2012 20:49:07 +0000 (13:49 -0700)]
Add support for "lazy" unmount option.

This allows detaching a mount point from the file system even though
resources are still under use.

BUG=chrome-os-partner:12732
TEST=lumpy manual test
(1) make sure normal USB hot-plug/unplug still works without playback
(2) play media file from removable disk, and hard unplug (remove disk), make sure disk
is unmounted from file manager.
(3) play media file from removable disk, and soft unplug (click on eject button), make
sure disk is unmounted from disk manager.

Change-Id: Ia120823cb3549aadd2605ca6d7e56ea037adc7f6
Reviewed-on: https://gerrit.chromium.org/gerrit/33714
Tested-by: Haixia Shi <hshi@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
Commit-Ready: Haixia Shi <hshi@chromium.org>

2 years agoListen to ScreenIsLocked / ScreenIsUnlocked signal from SessionManager. factory-2914.B
Ben Chan [Tue, 18 Sep 2012 15:32:42 +0000 (08:32 -0700)]
Listen to ScreenIsLocked / ScreenIsUnlocked signal from SessionManager.

The ScreenIsLocked and ScreenIsUnlocked signals from PowerManager have
been deprecated and replaced by the same signals from SessionManager.

BUG=chromium-os:34240
TEST=Tested the following on a Chromebook:
1) While the screen is locked, insert a removable medium and verify that
   it is not auto-mounted. Leave the removable medium plugged and unlock
   the screen. Verify that the removable medium is auto-mounted and a
   notification window followed by a new file broweser tab is opened for
   the mounted disk after the screen is unlocked.
2) While the screen is locked, insert a removable medium and then remove
   it. Unlock the screen and verify that the removable medium is not
   mounted, and no notification window or new file browser tab is
   opened.

Change-Id: Ia5614754586cde026d9feb43daf92685053ea32c
Reviewed-on: https://gerrit.chromium.org/gerrit/33525
Reviewed-by: Darin Petkov <petkov@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Commit-Ready: Ben Chan <benchan@chromium.org>

2 years agoReport vendor and product information via GetDeviceProperties.
Ben Chan [Tue, 11 Sep 2012 06:10:18 +0000 (23:10 -0700)]
Report vendor and product information via GetDeviceProperties.

This CL adds VendorId, VendorName, ProductId, and ProductName to the
properties returned by org.chromium.CrosDisks.GetDeviceProperties. The
vendor and product information is obtained from the USB ID database on
the system.

BUG=chromium-os:33225
TEST=Tested the following:
1. Build cros-disks for {x86,amd64,arm}-generic.
2. Run cros-disks unit tests.
3. Run platform_CrosDisksDBus and platform_CrosDisksFilesystem tests.
4. Manually test mounting different removable USB devices and verify the
   vendor and product information of the devices return by
   org.chromium.CrosDisks.GetDeviceProperties.

Change-Id: I43982e6e72256a4e362beca4753caf11f2a37741
Reviewed-on: https://gerrit.chromium.org/gerrit/33044
Reviewed-by: Darin Petkov <petkov@chromium.org>
Commit-Ready: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
2 years agoHide optical discs without any data track.
Ben Chan [Fri, 7 Sep 2012 06:39:56 +0000 (23:39 -0700)]
Hide optical discs without any data track.

BUG=chrome-os-partner:11576
TEST=Verify that File Manager mounts an optical disc only if there is at least one data track.

Change-Id: I0d5c2fb3c154046c78a03f771d3b18451f6a2335
Reviewed-on: https://gerrit.chromium.org/gerrit/32516
Reviewed-by: Darin Petkov <petkov@chromium.org>
Reviewed-by: Bernie Thompson <bhthompson@chromium.org>
Tested-by: Bernie Thompson <bhthompson@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Commit-Ready: Ben Chan <benchan@chromium.org>

2 years agoHandle devices that already exist when disk manager starts. factory-2846.B factory-2848.B firmware-butterfly-2788.B firmware-stout-2817.B
Ben Chan [Wed, 15 Aug 2012 06:38:12 +0000 (23:38 -0700)]
Handle devices that already exist when disk manager starts.

Disk manager does not receive any udev add event for devices that
exist before it starts. This CL addresses this issue by enumerating
auto-mountable devices and including them to the detected device list
during the initialization of disk manager.

BUG=chrome-os-partner:12404
TEST=Tested the follwoing:
1. Build and run cros-disks unit tests.
2. Run platform_CrosDisksDBus and platform_CrosDisksFilesystem.
3. Test media insertion/removal with internal and external CD-ROM
   drives, and Android USB storage.

Change-Id: I5a3fdd5ab7f5470f1f9382eba55a26633253d2c2
Reviewed-on: https://gerrit.chromium.org/gerrit/30385
Tested-by: Ben Chan <benchan@chromium.org>
Reviewed-by: Darin Petkov <petkov@chromium.org>
Commit-Ready: Ben Chan <benchan@chromium.org>

2 years agoSandbox AVFS process with seccomp filter mechanism on ARM. factory-2717.B factory-2723.14.B firmware-link-2695.2.B firmware-link-2695.B firmware-parrot-2685.B firmware-snow-2695.90.B firmware-snow-2695.B
Ben Chan [Tue, 24 Jul 2012 04:26:17 +0000 (21:26 -0700)]
Sandbox AVFS process with seccomp filter mechanism on ARM.

This CL adds a seccomp filter policy file "avfsd-seccomp-arm.policy" for
sandboxing AVFS processes on ARM platforms.

BUG=chromium-os:31698
TEST=Tested the following:
1. Build cros-disks for arm-generic and verify that
   avfsd-seccomp-arm.policy is installed as
   /opt/google/cros-disks/avfsd-seccomp.policy on the final image.
2. Run the platform_CrosDisksArchive test.
3. Manually test mounting and unmounting some Zip, RAR, tar, tar.gz,
   and tar.bz2 files through the CrOS file manager.

Change-Id: If0f726c5738e3a38fcc45232a19b8e2f6560ce2d
Reviewed-on: https://gerrit.chromium.org/gerrit/28242
Reviewed-by: Jorge Lucangeli Obes <jorgelo@chromium.org>
Commit-Ready: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
2 years agoAllow openat system call in AVFS processes.
Ben Chan [Thu, 12 Jul 2012 22:10:02 +0000 (15:10 -0700)]
Allow openat system call in AVFS processes.

This CL updates the seccomp filter policy files for AVFS processes to
allow the openat system call, which are necessary for AVFS to function
properly.

BUG=chromium-os:32547
TEST=Tested the following:
1. Build cros-disks for {x86,amd64,arm}-generic.
2. Run cros-disks unit tests.
3. Run platform_CrosDisksArchive tests.
4. Manually test mounting archive files in CrOS File Manager.

Change-Id: I285c13924220158f30449f4c9f5fae7c87704b0b
Reviewed-on: https://gerrit.chromium.org/gerrit/27334
Reviewed-by: Jorge Lucangeli Obes <jorgelo@chromium.org>
Commit-Ready: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
2 years agoIndicate whether or not a device is DVD in GetDeviceProperties. factory-2268.16.B factory-2305.B factory-2338.B factory-2368.B factory-2394.B factory-2460.B factory-2475.B factory-2569.B firmware-link-2348.B release-R20-2268.B release-R21-2465.B
Ben Chan [Wed, 2 May 2012 17:02:20 +0000 (10:02 -0700)]
Indicate whether or not a device is DVD in GetDeviceProperties.

BUG=chromium-os:30383
TEST=Tested the following:
1. Build cros-disks for {x86,amd64,arm}-generic.
2. Run cros-disks unit tests.
3. Run platform_CrosDisksDBus test on a Cr48.
4. Examine the 'DeviceMediaType' property returned by
   org.chromium.CrosDisks.GetDeviceProperties on DVD and non-DVD
   devices.

Change-Id: Ic2e8f395db7b558d001b1ea42a308cb2b4daf273
Reviewed-on: https://gerrit.chromium.org/gerrit/21796
Reviewed-by: Toni Barzic <tbarzic@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Commit-Ready: Ben Chan <benchan@chromium.org>

2 years agoAdd priv dropping syscalls to avfs policies.
Jorge Lucangeli Obes [Tue, 1 May 2012 18:28:10 +0000 (11:28 -0700)]
Add priv dropping syscalls to avfs policies.

Since we install the syscall filter before dropping privs,
we need to allow priv dropping syscalls in the policy.

BUG=chromium-os:27878
TEST=cros-disks unittest
TEST=platform_CrosDisksArchive

Change-Id: I931a751c831121b713096ac6b2916fc9b897e299
Reviewed-on: https://gerrit.chromium.org/gerrit/21546
Tested-by: Jorge Lucangeli Obes <jorgelo@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
Commit-Ready: Jorge Lucangeli Obes <jorgelo@chromium.org>

2 years agoUpdate avfs seccomp policy to new BPF implementation syntax.
Jorge Lucangeli Obes [Fri, 27 Apr 2012 16:46:45 +0000 (09:46 -0700)]
Update avfs seccomp policy to new BPF implementation syntax.

BUG=chromium-os:27878
BUG=chromium-os:30289
TEST=Manual, open a zip file, extract a file.

Change-Id: I5b9fb0d76de1e46e8755c0b335e1697859bb5de1
Reviewed-on: https://gerrit.chromium.org/gerrit/21464
Reviewed-by: Jorge Lucangeli Obes <jorgelo@chromium.org>
Tested-by: Jorge Lucangeli Obes <jorgelo@chromium.org>
Commit-Ready: Jorge Lucangeli Obes <jorgelo@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
Reviewed-by: Will Drewry <wad@chromium.org>
2 years agoClean up comments.
Ben Chan [Mon, 30 Apr 2012 15:16:20 +0000 (08:16 -0700)]
Clean up comments.

BUG=none
TEST=Build cros-disks and run unit tests.

Change-Id: I07d1a43e48bd4e95c1f568347c9b7ec412be4c26
Reviewed-on: https://gerrit.chromium.org/gerrit/21462
Tested-by: Ben Chan <benchan@chromium.org>
Commit-Ready: Ben Chan <benchan@chromium.org>
Reviewed-by: Darin Petkov <petkov@chromium.org>
2 years agoUpdate ntfs-3g executable path.
Ben Chan [Thu, 26 Apr 2012 07:17:31 +0000 (00:17 -0700)]
Update ntfs-3g executable path.

The sys-fs/ntfs3g-2012.1.15 ebuild installs the ntfs-3g executable to
/usr/bin instead of /bin. This CL updates NTFSMounter to use the correct
path of ntfs-3g.

BUG=chromium-os:30038
TEST=Tested the following:
1. Build cros-disks for {x86,amd64,arm}-generic.
2. Run cros-disks unit tests.
3. Run platform_CrosDisksArchive tests.

Change-Id: If01381ea38c41a1477149d7a3f1a81a4e80e7107
Reviewed-on: https://gerrit.chromium.org/gerrit/21198
Reviewed-by: Darin Petkov <petkov@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Commit-Ready: Ben Chan <benchan@chromium.org>

2 years agoAllow overriding mount directory name with mount label option.
Ben Chan [Thu, 26 Apr 2012 05:09:09 +0000 (22:09 -0700)]
Allow overriding mount directory name with mount label option.

This CL modifies MountManager to extract an optional mount label from
the options passed to Mount() and uses that as the directory name of the
mount point.

BUG=chromium-os:29439
TEST=Tested the following:
1. Build cros-disks for {x86,amd64,arm}-generic.
2. Run cros-disks unit tests.
3. Run the following autotest tests on a Cr48:
   - platform_CrosDisksDBus
   - platform_CrosDisksArchive
   - platform_CrosDisksFilesystem

Change-Id: I9bdfcc92445666a3c5b750a018a00adb18884554
Reviewed-on: https://gerrit.chromium.org/gerrit/21171
Reviewed-by: Darin Petkov <petkov@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Commit-Ready: Ben Chan <benchan@chromium.org>

2 years agoProvide getter and setter for process ID in Process base class.
Ben Chan [Wed, 25 Apr 2012 05:50:01 +0000 (22:50 -0700)]
Provide getter and setter for process ID in Process base class.

This CL modifies SandboxedProcess to obtain the process ID of a
sandboxed process using minijail_run_pid(), which then allows the
Process base class to provide a getter and setter for the process ID.

BUG=chromium-os:29968
TEST=Tested the following:
1. Build cros-disks for {x86,amd64,arm}-generic.
2. Run cros-disks unit tests.
3. Run platform_CrosDisksArchive tests.

Change-Id: I10c7779ce9654685f232078106216da5fa115955
Reviewed-on: https://gerrit.chromium.org/gerrit/21029
Reviewed-by: Darin Petkov <petkov@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Commit-Ready: Ben Chan <benchan@chromium.org>

2 years agoSupport mounting archives in GData cache.
Ben Chan [Thu, 12 Apr 2012 00:00:00 +0000 (17:00 -0700)]
Support mounting archives in GData cache.

This CL makes the following changes:
1. Add an AVFS mount point for the GData cache directory.
2. Use the second argument in the Mount method as an alternative way to
   specify the archive format of a source path, so that the source path
   could have any file extension.
3. Explicitly specify archive handlers in AVFS virtual paths to allow
   AVFS to properly handle source paths with any file extension.

BUG=chromium-os:29357
TEST=Tested the following:
1. Build cros-disks for {x86,amd64,arm}-generic.
2. Run cros-disks unit tests.
3. Run platform_CrosDisksArchive tests.

Change-Id: I3778dbea2709ccbf8d0f849513fe8ec70dc900d7
Reviewed-on: https://gerrit.chromium.org/gerrit/20054
Commit-Ready: Ben Chan <benchan@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
2 years agoupdate to newer libbase
Mike Frysinger [Wed, 11 Apr 2012 16:03:44 +0000 (12:03 -0400)]
update to newer libbase

BUG=chromium-os:25872
TEST=`emerge-x86-alex cros-disks` works
TEST=`cros_run_unit_tests --board=x86-alex -p cros-disks` passed

Change-Id: I8b8eb7e2ad7c68b360e723de97f0c0c737c6e028
Reviewed-on: https://gerrit.chromium.org/gerrit/19989
Reviewed-by: Ben Chan <benchan@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
2 years agoInclude devices without media as auto-mountable devices.
Ben Chan [Wed, 11 Apr 2012 00:37:42 +0000 (17:37 -0700)]
Include devices without media as auto-mountable devices.

This CL changes UdevDevice::IsAutoMountable() to include devices without
media such that a DiskAdded event will be sent to the file manager after
a DeviceAdded event for a device without media. The DiskAdded event is
needed by the file manager to dismiss the device notification UI
triggered by the DeviceAdded event. As a result of this change, the file
manager will check to make sure that a device has media before mounting
it.

BUG=chromium-os:27894
TEST=Tested the following:
1. Build cros-disks for {x86,amd64,arm}-generic.
2. Run cros-disks unit tests.
3. Manually insert a device without media to a Cr48 and observe the
   notification from the file manager.

Change-Id: I4524bce0bc8bf9636598c5f11d8134fbdc2d37c0
Reviewed-on: https://gerrit.chromium.org/gerrit/19938
Reviewed-by: Toni Barzic <tbarzic@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Commit-Ready: Ben Chan <benchan@chromium.org>

2 years agopull in base/stringprintf.h explicitly
Mike Frysinger [Fri, 6 Apr 2012 22:32:47 +0000 (18:32 -0400)]
pull in base/stringprintf.h explicitly

Newer libbase no longer implicitly includes the stringprintf.h header,
so building against it fails with missing StringPrintf definitions.

BUG=chromium-os:25872
TEST=`emerge-x86-alex cros-disks` works with old & new libbase

Change-Id: I0c933870e15b09b63bdaf50d48b64a5d77b8fc6e
Reviewed-on: https://gerrit.chromium.org/gerrit/19793
Reviewed-by: Ben Chan <benchan@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
2 years agoAdd LICENSE file and update OWNERS file.
Ben Chan [Mon, 26 Mar 2012 04:37:28 +0000 (21:37 -0700)]
Add LICENSE file and update OWNERS file.

BUG=none
TEST=none

Change-Id: I75843db7905e439c7a387e2deec09912ddc32cd6
Reviewed-on: https://gerrit.chromium.org/gerrit/19049
Reviewed-by: Darin Petkov <petkov@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Commit-Ready: Ben Chan <benchan@chromium.org>

2 years agoEject media from optical disc devices upon unmount.
Ben Chan [Thu, 22 Mar 2012 07:41:52 +0000 (00:41 -0700)]
Eject media from optical disc devices upon unmount.

This CL addes a DeviceEjector class for ejecting media from a device
using the 'eject' program. DiskManager uses DeviceEjector to eject media
from an optical disc device upon unmount.

BUG=chromium-os:26660
TEST=Tested the following:
1. Build cros-disks for {x86,amd64,arm}-generic.
2. Run cros-disks unit tests.
3. Run the following autotest tests on a Cr48:
   - platform_CrosDisksDBus
   - platform_CrosDisksFilesystem
4. Plug in a CD-ROM to a Cr48 and verify that the CD is ejected from a
   CD-ROM when it is unmounted through the CrOS file manager.

Change-Id: Ib11810608533ee12f08e95564c8d642252e482c5
Reviewed-on: https://gerrit.chromium.org/gerrit/18903
Commit-Ready: Ben Chan <benchan@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
2 years agoRefactor code for launching processes.
Ben Chan [Thu, 22 Mar 2012 00:38:21 +0000 (17:38 -0700)]
Refactor code for launching processes.

This CL makes the following changes:
1. Add a Process base class to abstract process creation and implement
   common code.
2. Add a GlibProcess class to implement Process using Glib.
3. Refactor SandboxedProcess to implement Process.

BUG=chromium-os:28208
TEST=Tested the following:
1. Build cros-disks for {x86,amd64,arm}-generic.
2. Run cros-disks unit tests.
3. Run the following autotest tests on a Cr48:
   - platform_CrosDisksDBus
   - platform_CrosDisksArchive
   - platform_CrosDisksFilesystem
   - platform_CrosDisksFormat

Change-Id: I598468da6f5774163aa3f0a47ada4e148d5c44df
Reviewed-on: https://gerrit.chromium.org/gerrit/18811
Reviewed-by: Darin Petkov <petkov@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Commit-Ready: Ben Chan <benchan@chromium.org>

2 years agoconvert to SLOT-ed libbase factory-1987.B
Mike Frysinger [Wed, 7 Mar 2012 13:10:34 +0000 (08:10 -0500)]
convert to SLOT-ed libbase

BUG=chromium-os:16623
TEST=`emerge-x86-alex cros-disks` works
TEST=`cros_run_unit_tests --board x86-alex -p cros-disks` passed

Change-Id: I563806754dd2a6f618704b96fefc0bc41260ade1
Reviewed-on: https://gerrit.chromium.org/gerrit/17854
Reviewed-by: Ben Chan <benchan@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
2 years agodepend on gthread/gobject
Mike Frysinger [Wed, 7 Mar 2012 13:02:00 +0000 (08:02 -0500)]
depend on gthread/gobject

The cros-disks main code refers to funcs from both gthread and gobject,
so make sure we link them in rather than relying on other libraries.

Otherwise, we get link failures like so:
LDCXX disks
ld.gold: main.pie.o: in function main:.../main.cc:70: error: undefined reference to 'g_type_init'
ld.gold: main.pie.o: in function main:.../main.cc:71: error: undefined reference to 'g_thread_init'
collect2: ld returned 1 exit status
make[1]: *** [CXX_BINARY(disks)] Error 1

BUG=chromium-os:26736
TEST=`emerge-x86-alex cros-disks` still works

Change-Id: I617858e9099827cda17160052a0191b0becb81b7
Reviewed-on: https://gerrit.chromium.org/gerrit/17471
Reviewed-by: Brian Harring <ferringb@chromium.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
2 years agofix up toolchain flags/pkg-config handling
Mike Frysinger [Thu, 16 Feb 2012 17:23:49 +0000 (12:23 -0500)]
fix up toolchain flags/pkg-config handling

Since libchrome provides a .pc file now, use that rather than hardcoding
the -lbase.  This lets us drop all the other hardcoded libs too that we
were adding for libbase.

Further, run pkg-config just once per cflags/libs rather than on every
compile line.

This clean up work requires a newer common.mk, so import that first.
Then convert our flag handling over to that.

BUG=chromium-os:16623
TEST=`emerge-x86-alex cros-disks` still works

Change-Id: I33e542cb16e3b04af4b9effbbb17b94b0bb016e7
CQ-DEPEND=I7a47747d3dc4cd24d9240de00b2e17381fed1802
Reviewed-on: https://gerrit.chromium.org/gerrit/16037
Tested-by: Mike Frysinger <vapier@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
2 years agoAllow statfs/statfs64 system calls in AVFS processes.
Ben Chan [Wed, 29 Feb 2012 02:14:53 +0000 (18:14 -0800)]
Allow statfs/statfs64 system calls in AVFS processes.

This CL updates the seccomp filter policy files for AVFS processes to
allow the statfs/statfs64 system calls, which are necessary for AVFS to
function properly.

BUG=chromium-os:27079
TEST=Tested the following:
1. Build cros-disks for {x86,amd64,arm}-generic.
2. Run cros-disks unit tests.
3. Run platform_CrosDisksArchive tests.
4. Open the "ZIP Example.zip/Rar Example.rar/Example.pdf" attached to
   chromium-os:27079 through the file manager on both 32-bit and 64-bit
   platform.

Change-Id: I620f41ff9bbebbdda78a54566e266f397fec6772
Reviewed-on: https://gerrit.chromium.org/gerrit/17072
Reviewed-by: Kees Cook <keescook@chromium.org>
Commit-Ready: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Reviewed-by: Darin Petkov <petkov@chromium.org>
2 years agoEnable RAR archive support.
Ben Chan [Thu, 16 Feb 2012 21:41:14 +0000 (13:41 -0800)]
Enable RAR archive support.

This CL registers the RAR file extension in the archive manager in
order to enable the mounting of RAR archives as a virtual filesystem,
which can then be viewed in the Chromium OS File Manager.

The seccomp filter policy files are also updated to allow the system
call 'ioctl(cmd==TCGETS)', which is triggered by the isatty check in
the unrar code.

BUG=chromium-os:26687
TEST=Tested the following:
1. Build cros-disks for {x86,amd64,arm}-generic.
2. Run cros-disks unit tests.
3. Test mounting and unmounting RAR archives using cros-disks DBus API
   on a Cr48.

Change-Id: I30e24355194930bfb9b8c7b214af50d305691f47
Reviewed-on: https://gerrit.chromium.org/gerrit/16418
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Darin Petkov <petkov@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Commit-Ready: Ben Chan <benchan@chromium.org>

2 years agoResolve issues with mounting a nested archive file.
Ben Chan [Fri, 17 Feb 2012 22:36:38 +0000 (14:36 -0800)]
Resolve issues with mounting a nested archive file.

This CL changes ArchiveManager to construct the virtual path of an
archive within another mounted archive using the unfolded form instead
of the nested form, where the latter causes issues reading files from
the inner archive.

BUG=chromium-os:26573
TEST=Tested the following:
1. Build cros-disks for {x86,amd64,arm}-generic.
2. Run cros-disks unit tests.
3. Run platform_CrosDisksArchive tests.
4. Test reading files from nested archives.

Change-Id: I9c5bc6606f5677d6167d7a795cfcf0bbd79e0166
Reviewed-on: https://gerrit.chromium.org/gerrit/16313
Reviewed-by: Darin Petkov <petkov@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Commit-Ready: Ben Chan <benchan@chromium.org>

2 years agoEnsure that only UTF8 strings are passed to a DBus message iterator.
Ben Chan [Mon, 13 Feb 2012 20:37:34 +0000 (12:37 -0800)]
Ensure that only UTF8 strings are passed to a DBus message iterator.

This CL changes UdevDevice to only set the drive model and filesystem
label of a disk if they are valid UTF8 strings, which prevents an
asertion error in DBus message iterator due to non-UTF8 strings.

BUG=chromium-os:26281
TEST=Tested the following:
1. Build cros-disks for {x86,amd64,arm}-generic.
2. Run cros-disks unit tests.

Change-Id: I5bad4431bf2ba49a876922a95162ebd028a4b4cc
Reviewed-on: https://gerrit.chromium.org/gerrit/16268
Reviewed-by: Darin Petkov <petkov@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Commit-Ready: Ben Chan <benchan@chromium.org>

2 years agoEnable tar, gzip-compressed tar, and bzip2-compressed tar support.
Ben Chan [Wed, 15 Feb 2012 06:35:15 +0000 (22:35 -0800)]
Enable tar, gzip-compressed tar, and bzip2-compressed tar support.

This CL registers the tar, gzip-compressed tar, and bzip2-compressed
file extensions in the archive manager in order to enable the mounting
of these archive formats as a virtual filesystem, which can then be
viewed in the Chromium OS File Manager.

BUG=chromium-os:26455
TEST=Tested the following:
1. Build cros-disks for {x86,amd64,arm}-generic.
2. Run cros-disks unit tests.
3. Run the platform_CrosDisksArchive tests (with tar, tar.gz, and
   tar.bz2) on a VM.

Change-Id: Ic25db67020f59f953db53750c7a75e4c050a34ea
Reviewed-on: https://gerrit.chromium.org/gerrit/15951
Reviewed-by: Darin Petkov <petkov@chromium.org>
Commit-Ready: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
2 years agoAdd missing header dependency to .pic.o and .pie.o targets.
Ben Chan [Fri, 20 Jan 2012 22:57:26 +0000 (14:57 -0800)]
Add missing header dependency to .pic.o and .pie.o targets.

This CL pulls the latest common.mk file from src/platform/common-mk, and
adds the .o.depends targets for object files, which depend on
cros-disks-server.h. This ensures that cros-disks-server.h is always
generated before .pic.o and .pie.o are built.

BUG=chromium-os:25251
TEST=Tested the following:
1. Run "make -np disks disks_testrunner" to verify that .o, .pic.o, and
   .pie.o targets depend on the corresponding .o.depends target, which
   depends on cros-disks-server.h.
2. Build cros-disks and run unit tests for {x86,amd64,arm}-generic.

Change-Id: I0d062c3ef6070047925a4faab928d664cbde92be
Reviewed-on: https://gerrit.chromium.org/gerrit/14581
Reviewed-by: David James <davidjames@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Commit-Ready: Ben Chan <benchan@chromium.org>

2 years agoPresent the name of removable storage in a user friendlier way.
Ben Chan [Mon, 6 Feb 2012 07:26:58 +0000 (23:26 -0800)]
Present the name of removable storage in a user friendlier way.

This CL changes the presentation name of removable storage as follows:
1. Use the device media type (such as 'USB Drive', 'SD Card', etc),
   instead of the UUID, to name an unlabeled drive.
2. Drop the parenthesis around the numeric suffix for a fallback
   directory name unless the directory name ends with a number.

BUG=chromium-os:17775
TEST=Tested the following:
1. Build cros-disks for {x86,amd64,arm}-generic.
2. Run cros-disks unit tests.
3. Run platform_CrosDisksFilesystem tests, which are modified
   accordingly w.r.t. this CL.
4. Manually test mounting labeled and unlabeled USB drives and SD cards
   on a Cr48 and verify that appropriate presentation names are used.

Change-Id: I5982f5d5ff9780b84977f1990098ddf20a567100
Reviewed-on: https://gerrit.chromium.org/gerrit/15378
Commit-Ready: Ben Chan <benchan@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
2 years agoUse 'flush' mount option when mounting FAT filesystem.
Ben Chan [Mon, 30 Jan 2012 04:12:15 +0000 (20:12 -0800)]
Use 'flush' mount option when mounting FAT filesystem.

This CL modifies DiskManager to use the 'flush' mount option when
mounting FAT filesystem. To help flush data to disk earlier without
degrading the write performance too much, the 'flush' mount option is
used instead of the previously used 'sync' mount option.

BUG=chromium-os:25623
TEST=Tested the following:
1. Build cros-disks for {x86,amd64,arm}-generic.
2. Run cros-disks unit tests.
3. Run platform_CrosDisksFilesystem autotest.
4. Manually verify the following on a Cr48:
   - Insert a FAT-formatted USB drive.
   - Run "mount" from a root shell to make sure that the USB drive is
     mounted with the 'flush' mount option.
   - Perform file read and write operations on the mounted USB drive.
   - Unplug the USB drive and verify that it is unmounted properly.

Change-Id: I2b5c30c604f5ef24927105393ac75615fe1dd6be
Reviewed-on: https://gerrit.chromium.org/gerrit/15017
Reviewed-by: Thieu Le <thieule@chromium.org>
Reviewed-by: Toni Barzic <tbarzic@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Commit-Ready: Ben Chan <benchan@chromium.org>

2 years agoEnable NTFS write support.
Ben Chan [Tue, 17 Jan 2012 05:21:58 +0000 (21:21 -0800)]
Enable NTFS write support.

BUG=chromium-os:25317
TEST=Tested the following:
1. Run platform_CrosDisksFilesystem (NTFS write test).
2. Manually test using a NTFS formatted USB storage on a Cr48:
   - Run "mount" from a root shell to verify that the USB storage is
     mounted read-write.
   - Read files from the USB storage.
   - Copy and paste files onto the USB storage.

Change-Id: Ifc15ee67cba68a3fe383ec0abdacffc592597f3c
Reviewed-on: https://gerrit.chromium.org/gerrit/14599
Tested-by: Ben Chan <benchan@chromium.org>
Reviewed-by: Darin Petkov <petkov@chromium.org>
Commit-Ready: Ben Chan <benchan@chromium.org>

2 years agoignore more generated files
Mike Frysinger [Wed, 25 Jan 2012 05:59:44 +0000 (00:59 -0500)]
ignore more generated files

BUG=None
TEST=`make && git status` doesn't show generated files anymore

Change-Id: I776af69cd715f8b6b1f84c314f9ee94c815f13b8
Reviewed-on: https://gerrit.chromium.org/gerrit/14777
Reviewed-by: Ben Chan <benchan@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
2 years agoSandbox AVFS process with seccomp filter mechanism on x86-64.
Ben Chan [Fri, 13 Jan 2012 07:04:27 +0000 (23:04 -0800)]
Sandbox AVFS process with seccomp filter mechanism on x86-64.

This CL adds a seccomp filter policy file "avfsd-seccomp-amd64.policy"
for sandboxing AVFS processes on x86-64 platforms.

BUG=chromium-os:25062
TEST=Tested the following:
1. Build cros-disks for amd64-generic and verify that
   avfsd-seccomp-amd64.policy is installed as
   /opt/google/cros-disks/avfsd-seccomp.policy on the final image.
2. Run the platform_CrosDisksArchive test on a VM.
3. Manually test mounting and unmounting some ZIP files through the
   file manager on a VM.

Change-Id: Ib85a7a7083712185ca8d16b9f7e8c627d4b5a035
Reviewed-on: https://gerrit.chromium.org/gerrit/14137
Reviewed-by: Kees Cook <keescook@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Commit-Ready: Ben Chan <benchan@chromium.org>
Reviewed-by: Will Drewry <wad@chromium.org>
2 years ago[cros-disks] use libchromeos.pc
Elly Jones [Wed, 11 Jan 2012 21:18:36 +0000 (16:18 -0500)]
[cros-disks] use libchromeos.pc

BUG=chromium-os:24959
TEST=build,unit

Signed-off-by: Elly Jones <ellyjones@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/14001
Reviewed-by: Mike Frysinger <vapier@chromium.org>
(cherry picked from commit ef748325a8d566ab14772fd7717ffa39aeb4dfae)

Change-Id: I6e40f60d55e847c2c408e4a0e052d3b9c903dea7
Reviewed-on: https://gerrit.chromium.org/gerrit/14495
Reviewed-by: Kees Cook <keescook@chromium.org>
Tested-by: Elly Jones <ellyjones@chromium.org>
Commit-Ready: Elly Jones <ellyjones@chromium.org>

2 years agopull in latest common.mk for make-3.82 fixes
Mike Frysinger [Tue, 17 Jan 2012 22:15:46 +0000 (17:15 -0500)]
pull in latest common.mk for make-3.82 fixes

BUG=chromium-os:24841
TEST=`emerge cros-disks` worked with make-3.82

Change-Id: I7ae72de7f9930ae03bf4a8e7082ffc0a7abdc681
Reviewed-on: https://gerrit.chromium.org/gerrit/14320
Reviewed-by: Will Drewry <wad@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>

2 years agoRevert "[cros-disks] use libchromeos.pc"
Scott James Remnant [Fri, 13 Jan 2012 01:58:58 +0000 (17:58 -0800)]
Revert "[cros-disks] use libchromeos.pc"

This reverts commit 126b7e2e979c2e9cba38a34f7e97ce2a25754014

Change-Id: I6395d0491c0e6e5a9149be962b7b0a3733ce533e
Reviewed-on: https://gerrit.chromium.org/gerrit/14120
Reviewed-by: Scott James Remnant <keybuk@chromium.org>
Tested-by: Scott James Remnant <keybuk@chromium.org>
2 years ago[cros-disks] use libchromeos.pc
Elly Jones [Wed, 11 Jan 2012 21:18:36 +0000 (16:18 -0500)]
[cros-disks] use libchromeos.pc

BUG=chromium-os:24959
TEST=build,unit

Change-Id: I7544cc205c0c64495372d3738485bf75e20e9bc2
Signed-off-by: Elly Jones <ellyjones@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/14001
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2 years agoFix type mismatch in forward declarations of the DeviceEvent struct.
Ben Chan [Wed, 21 Dec 2011 17:48:19 +0000 (09:48 -0800)]
Fix type mismatch in forward declarations of the DeviceEvent struct.

BUG=none
TEST=Built and ran unit tests.

Change-Id: I70d57e183575a5b78cea0f675f8a78b8f93466b9
Reviewed-on: https://gerrit.chromium.org/gerrit/13357
Reviewed-by: Thieu Le <thieule@chromium.org>
Commit-Ready: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
2 years agoPrevent AVFS daemon from writing to syslog.
Ben Chan [Tue, 20 Dec 2011 02:08:37 +0000 (18:08 -0800)]
Prevent AVFS daemon from writing to syslog.

The AVFS daemon may log messages to syslog under certain scenarios.
Writing to syslog may trigger the time, socket, connect, and send system
calls, which are currently disabled by the seccomp filters policy file.
This CL sets up AVFS in a way that it logs messages to a file instead of
syslog, which prevents the socket, connect, send system calls from being
called. Only the time system call is needed and thus enabled in the policy
file.

BUG=chromium-os:24407
TEST=Tested the following:
1. Build cros-disks for x86-generic, amd64-generic, and arm-generic.
2. Run cros-disks unit tests.
3. Run the following autotest tests on a Cr48:
   - platform_CrosDisksDBus
   - platform_CrosDisksArchive
   - platform_CrosDisksFilesystem
4. Manually test opening the ZIP file attached to issue 24407.

Change-Id: If16509c1048543eb7bab0fb16164b766afd42359
Reviewed-on: https://gerrit.chromium.org/gerrit/13233
Reviewed-by: Toni Barzic <tbarzic@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
2 years agoReadability review for C++.
Ben Chan [Mon, 28 Nov 2011 21:43:17 +0000 (13:43 -0800)]
Readability review for C++.

BUG=none
TEST=Built and ran unit tests.

Change-Id: I63d75524919496d09221b64585314fab4a27701a
Reviewed-on: https://gerrit.chromium.org/gerrit/12150
Reviewed-by: Dale Woodford <dale@google.com>
Reviewed-by: Chris Masone <cmasone@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Commit-Ready: Ben Chan <benchan@chromium.org>

2 years agoDetect and handle the unmounting of an Android USB storage gracefully.
Ben Chan [Wed, 14 Dec 2011 00:04:34 +0000 (16:04 -0800)]
Detect and handle the unmounting of an Android USB storage gracefully.

When using the Android user interface to unmount a USB storage of an
Android device that is mounted to a Chromebook, the Chromebook does not
receive a udev remove event on the mounted device (e.g. /dev/sdb1) and
thus cannot tell the file manager to unmount the device automatically.
As a workaround, this CL changes DiskManager to listen to the udev
change event on the parent (e.g. /dev/sdb) of the mounted device and
check if it has any available media to determine if the USB storage has
been unmounted from Android.

This CL makes the following changes:
1. Change DeviceEventSourceInterface to return a list of DeviceEvent
   through its GetDeviceEvents() method, which will be dispatched in
   sequence by DeviceEventModerator::ProcessDeviceEvents().
2. Remove the DeviceEventAddedAfterRemoved event type as
   DeviceEventSourceInterface can now return multiple events per
   invocation of GetDeviceEvents().
3. Change DiskManager, upon receiving a media change event on a block
   device, to dispatch a kDiskRemoved event for each immediate child
   of that block device if it has no available media.
4. Modify unit tests accordingly.

BUG=chromium-os:23858
TEST=Tested the following:
1. Build cros-disks for x86-generic, amd64-generic, and arm-generic.
2. Run cros-disks unit tests.
3. Manually test mounting, unmounting, and remounting a USB drive,
   SD card, removable CD-ROM drive, and Android USB storage on a Cr48.

Change-Id: I6bce3fbc3044f3cba2dead2bf468d7d6b6d6b5dc
Reviewed-on: https://gerrit.chromium.org/gerrit/12964
Commit-Ready: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
2 years agocommon.mk: sync to the new version and port the Makefile
Will Drewry [Mon, 14 Nov 2011 19:42:21 +0000 (13:42 -0600)]
common.mk: sync to the new version and port the Makefile

Cleans up the Makefile and revs to the new common.mk to
simplify the non-common.mk portions of the Makefile.

(New common.mk: https://gerrit.chromium.org/gerrit/#change,11620 )

Expands common.mk to work with cros-disks for issues pointed out
by benchan@.  These will be sync'd back to the main repo when all
tests pass as expected.

BUG=chromium-os:23064
TEST=cros_run_unittests -p cros-disks -b x86-alex with new ebuuild
     emerge-x86-alex cros-disks

The following all pass:
 FEATURES="noclean test" USE=test emerge-x86-alex  cros-disks
 FEATURES="noclean test" USE=test emerge-arm-generic  cros-disks
 FEATURES="noclean test" USE=test emerge-amd64-generic  cros-disks
 cros_run_unit_tests --board=x86-alex -p cros-disks
 cros_run_unit_tests --board=arm-generic -p cros-disks
 cros_run_unit_tests --board=amd64-generic -p cros-disks
 cros_workon_make --board=amd64-generic --test --reconf cros-disks
 cros_workon_make --board=x86-alex --test --reconf cros-disks

arm and anything running tests in qemu will not work since the SYSROOT
will be incorrect and chroot will fail. E.g.,
 cros_workon_make --board=arm-generic --test --reconf cros-disks

Change-Id: I751cc9764b8b71d4d18231fa7f426eab4b93d872
Reviewed-on: https://gerrit.chromium.org/gerrit/11639
Reviewed-by: Ben Chan <benchan@chromium.org>
Commit-Ready: Will Drewry <wad@chromium.org>
Reviewed-by: Will Drewry <wad@chromium.org>
Tested-by: Will Drewry <wad@chromium.org>
2 years agoAdd a more generic Format/FormatCompleted API for formatting devices.
Ben Chan [Mon, 21 Nov 2011 20:56:59 +0000 (12:56 -0800)]
Add a more generic Format/FormatCompleted API for formatting devices.

This CL makes the following changes:
1. Add a more generic FormatCompleted signal, which carries the status
   code of the formatting operation. This signal replaces the
   FormattingFinished signal, which encodes the failure status with a
   '!' prefix on the returned device path.
2. Add a more generic Format method, which takes additional options
   for the formatting operation. This method replaces the FormatDevice
   method.
3. Add a FormatManagerObserverInterface interface for observing the
   completion of a formatting operation. This avoids FormatManager
   from directly depending on CrosDisksServerImpl.
4. Clean up the style of the FormatManager code to make it consistent
   with other cros-disks code.

BUG=chromium-os:22981
TEST=Tested the following on a Cr48:
1. Run this command in a root shell:
   dbus-monitor --system --monitor 'interface=org.chromium.CrosDisks'
2. Insert a USB drive.
3. Select the inserted drive from the File Browser and click the
   "Format device" button.
4. Verify from dbus-monitor that a FormatCompleted signal is emitted
   upon the completion of the formatting operation. The signal shows
   the device path of the USB drive and a zero status code.
5. Run platform_CrosDisksFormat autotest test.

Change-Id: I7729cbad70d75d391116d526fcdb24716c86e359
Reviewed-on: https://gerrit.chromium.org/gerrit/12022
Reviewed-by: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
2 years agoFix typos and add comments in MountManager unit tests.
Ben Chan [Wed, 23 Nov 2011 00:24:06 +0000 (16:24 -0800)]
Fix typos and add comments in MountManager unit tests.

BUG=none
TEST=Built cros-disks and ran unit tests.

Change-Id: I3724eaf1cfa42db4248d5d9e66304778dadf5aa9
Reviewed-on: https://gerrit.chromium.org/gerrit/12131
Reviewed-by: Darin Petkov <petkov@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
2 years agoClean up code style issues.
Ben Chan [Mon, 21 Nov 2011 17:18:50 +0000 (09:18 -0800)]
Clean up code style issues.

This CL cleans up some style issues:
- Make all member variables in MountManager private.
- Use arraysize instead of ARRAYSIZE_UNSAFE in ArchiveManager.

BUG=none
TEST=Tested the following:
1. Build cros-disks for x86-mario and arm-generic.
2. Run unit tests.
3. Run the following autotest tests on a Cr48:
   - platform_CrosDisksDBus
   - platform_CrosDisksArchive
   - platform_CrosDisksFilesystem

Change-Id: Ic26f81955d87f03b28bab7877e759a7d001c00b7
Reviewed-on: https://gerrit.chromium.org/gerrit/11989
Reviewed-by: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
2 years agoUse MountErrorType enum values defined in chromeos/dbus/service_constants.h
Ben Chan [Mon, 21 Nov 2011 17:44:07 +0000 (09:44 -0800)]
Use MountErrorType enum values defined in chromeos/dbus/service_constants.h

This CL replaces locally defined MountErrorType enum values with the
equivalent ones defined in chromeos/dbus/service_constants.h
(src/platform/system_api), which helps keep cros-disks and Chrome in
sync.

BUG=chromium-os:23195
TEST=Tested the following:
1. Build cros-disks for x86-mario and arm-generic.
2. Run unit tests.
3. Run the following autotest tests on a Cr48:
   - platform_CrosDisksDBus
   - platform_CrosDisksArchive
   - platform_CrosDisksFilesystem

Change-Id: Iba8d7e8983d7e6aa87c25110ab0394edc96e4bb4
Reviewed-on: https://gerrit.chromium.org/gerrit/11987
Reviewed-by: Satoru Takabayashi <satorux@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
2 years agoUse DBus service constants defined in chromeos/dbus/service_constants.h
Ben Chan [Fri, 18 Nov 2011 16:24:14 +0000 (08:24 -0800)]
Use DBus service constants defined in chromeos/dbus/service_constants.h

This CL replaces locally defined DBus service constants with the
equivalent ones defined in chromeos/dbus/service_constants.h
(src/platform/system_api), which helps keep cros-disks and Chrome in
sync.

BUG=chromium-os:23195
TEST=Tested the following:
1. Build cros-disks for x86-mario and arm-generic.
2. Run unit tests.
3. Run the following autotest tests on a Cr48:
   - platform_CrosDisksDBus
   - platform_CrosDisksArchive
   - platform_CrosDisksFilesystem

Change-Id: I1c7b59e877666a94850bb6b338de9be95545a846
Reviewed-on: https://gerrit.chromium.org/gerrit/11927
Reviewed-by: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
2 years agoUpdate DBus configuration file.
Ben Chan [Wed, 16 Nov 2011 04:47:03 +0000 (20:47 -0800)]
Update DBus configuration file.

This CL updates the cros-disks DBus configuration file to remove
references to methods that no longer exist (FilesystemMount,
FilesystemUnmount, GetDeviceFilesystem) and add the UnmountAll method
policy for the chronos user.

BUG=chromium-os:22959
TEST=Tested the following on a Cr48:
1. Run the following autotest tests:
   - platform_CrosDisksDBus
   - platform_CrosDisksArchive
   - platform_CrosDisksFilesystem
2. Run "dbus-send --system --dest=org.chromium.CrosDisks
        /org/chromium/CrosDisks org.chromium.CrosDisks.UnmountAll"
   under the chronos user to unmount all paths mounted by cros-disks.

Change-Id: Ic78698a920f4f933f4f71c819145e09705f03994
Reviewed-on: https://gerrit.chromium.org/gerrit/11753
Reviewed-by: Jim Hebert <jimhebert@chromium.org>
Reviewed-by: Will Drewry <wad@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
2 years agoAdd org.chromium.CrosDisks.UnmountAll DBus method.
Ben Chan [Mon, 14 Nov 2011 20:44:42 +0000 (12:44 -0800)]
Add org.chromium.CrosDisks.UnmountAll DBus method.

This CL adds org.chromium.CrosDisks.UnmountAll DBus method for
unmounting all paths mounted by cros-disks. It also fixes the
desctructor of ArchiveManager to properly unmount all AVFS mount
points.

BUG=chromium-os:22959
TEST=Manually verify the following on a Cr48:
1. Mount a SD card and a ZIP file via cros-disks.
2. Run "dbus-send --system --dest=org.chromium.CrosDisks
       /org/chromium/CrosDisks org.chromium.CrosDisks.UnmountAll"
   from a root shell to unmount all paths mounted by cros-disks.
3. Run "mount" from a root shell to make sure that the SD card and
   ZIP file are unmounted.
4. Make sure no leftover directories inside /media/removable and
   /media/archive.

Change-Id: Ic0a123042e235a95b4c9e4e4c56606c37c1f4369
Reviewed-on: https://gerrit.chromium.org/gerrit/11682
Reviewed-by: Darin Petkov <petkov@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
2 years agoRefactor code in main() and add SIGINT/SIGTERM handler.
Ben Chan [Fri, 11 Nov 2011 17:47:55 +0000 (09:47 -0800)]
Refactor code in main() and add SIGINT/SIGTERM handler.

This CL makes the following changes:
1. Move the code for composing various cros-disks classes from main()
   into a Daemon class.
2. Add a signal handler to gracefully terminate the cros-disks process
   upon receiving SIGINT or SIGTERM in order to ensure that mounted
   devices and archive files are properly unmounted.
3. Fix a crash in the MountManager destructor by moving the invocation
   of UnmountAll() from the MountManager destructor to the destructor of
   ArchiveManager and DiskManager.

BUG=chromium-os:22865
TEST=Tested the following:
1. Build cros-disks for x86-mario and arm-generic.
2. Run unit tests.
3. Run the following autotest tests on a Cr48:
   - platform_CrosDisksDBus
   - platform_CrosDisksArchive
   - platform_CrosDisksFilesystem
4. Manually verify the following on a Cr48:
   - Mount a SD card and a ZIP file via cros-disks.
   - Run "stop cros-disks" from a root shell to terminate
     the disks process.
   - Run "mount" from a root shell to make sure that the SD card and ZIP
     file are unmounted.
   - Make sure no leftover directories inside /media/removable and
     /media/archive.

Change-Id: I6cfe67918241ce1aab3f5c1750909f99eecf3087
Reviewed-on: https://gerrit.chromium.org/gerrit/11594
Reviewed-by: Darin Petkov <petkov@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
2 years agoCollect UMA metrics for mount operations.
Ben Chan [Tue, 8 Nov 2011 21:42:23 +0000 (13:42 -0800)]
Collect UMA metrics for mount operations.

This CL modifies DiskManager and ArchiveManager to collect UMA metrics
for mount operations regarding the device media type, filesystem type,
and archive type.

BUG=chromium-os:22698
TEST=Ran unit tests. Observed metrics recorded on chrome://histograms
after mounting different types of filesystem, archive and device media.

Change-Id: I1a3ebf95da6dcbcbcf6890c0046f24a2d02543ae
Reviewed-on: https://gerrit.chromium.org/gerrit/11404
Reviewed-by: Darin Petkov <petkov@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
2 years agoRun the avfsd process under the avfs user and the chronos-access group. factory-1235.B factory-1284.B firmware-kiev-2.112.B firmware-uboot_v2-1299.B
Ben Chan [Thu, 20 Oct 2011 23:42:21 +0000 (16:42 -0700)]
Run the avfsd process under the avfs user and the chronos-access group.

This CL makes the following changes:
1. Modify ArchiveManager to run the avfsd process under the avfsd user
   and the chronos-access group.
2. Enable the archive support by default.

BUG=chromium-os:21790
TEST=Ran unit tests and tested mounting zip files on Cr48.

Change-Id: I2c1a5890a71a764cb6729d558c72ee211537c569
Reviewed-on: https://gerrit.chromium.org/gerrit/10486
Reviewed-by: Will Drewry <wad@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Commit-Ready: Ben Chan <benchan@chromium.org>

3 years agoSandbox AVFS process with seccomp filter mechanism on x86-32.
Ben Chan [Tue, 4 Oct 2011 23:34:34 +0000 (16:34 -0700)]
Sandbox AVFS process with seccomp filter mechanism on x86-32.

This CL makes the following changes:
1. Modify SandboxedProcess to support the seccomp filter API provided by
   libminijail.
2. Modify ArchiveManager to sandbox the avfsd process with the seccomp
   filter mechanism via libminijail if a seccomp policy file is provided
   for a targeted platform, and fall back to the POSIX capabilities
   mechanism if no policy file is available. It also defers the
   initialization of AVFS mounts until a request to mount an archive is
   made.
3. Include a policy file "avfsd-seccomp-x86.policy" for x86-32
   platforms, while x86-64 and arm specific policy files are to be added
   later.

BUG=chromium-os:21285
TEST=Ran unit tests and tested mounting zip files on Cr48 with
experimental storage features enabled/disabled.

Change-Id: I49af8d3f08ddbb64ff39fe8a014d20e98d165c25
Reviewed-on: http://gerrit.chromium.org/gerrit/8783
Reviewed-by: Will Drewry <wad@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
3 years agoFix the setting of QEMU_ARCH in common.mk for amd64-generic.
Ben Chan [Fri, 21 Oct 2011 14:56:32 +0000 (07:56 -0700)]
Fix the setting of QEMU_ARCH in common.mk for amd64-generic.

This CL also cleans up trailing whitespace in common.mk.

BUG=chromium-os:21948
TEST='cros_run_unit_tests --board=amd64-generic -p cros-disks' shows
QEMU_ARCH=x86_64 instead of amd64 on a x86_64 machine.

Change-Id: Ib554fde870dcc7c5047dc96fb7ddb79ba7e3003a
Reviewed-on: http://gerrit.chromium.org/gerrit/10490
Reviewed-by: Will Drewry <wad@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
3 years agoDetect device media type of removable storage.
Ben Chan [Mon, 3 Oct 2011 22:02:34 +0000 (15:02 -0700)]
Detect device media type of removable storage.

This CL adds a usb-device-info file to look up the device media type of
a list of USB removable storage based on their vendor and product IDs.
The org.chromium.CrosDisks.GetDeviceProperties DBus method is modified
to return the device media type of a given device via a DeviceMediaType
field.

BUG=chromium-os:21191
TEST=Ran unit tests and examined the value of DeviceMediaType returned
by org.chromium.CrosDisks.GetDeviceProperties after plugging in the
following devices into a Cr48:
1. USB flash
2. SD card
3. Optical drive
4. Android USB mass storage

Change-Id: I47a53ba0f09f6fefe467cfbd6bcac82b43455b70
Reviewed-on: http://gerrit.chromium.org/gerrit/8671
Reviewed-by: Toni Barzic <tbarzic@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
3 years agoStore the error associated with a reserved mount point.
Ben Chan [Tue, 11 Oct 2011 19:22:16 +0000 (12:22 -0700)]
Store the error associated with a reserved mount point.

MountManager currently reserves a virtual mount point for a removable
device with an unrecognized or unsupported filesystem and notifies
Chrome an error. When Chrome crashes, the virtual mount point is
preserved but the error information is not. So after Chrome restarts,
the virtual mount point is incorrectly reported as a real mount point.
This CL modifies MountManager to store the error associated with a
reserved mount path, so that the error can be reported to Chrome after
Chrome recovers from a crash.

BUG=chromium-os:21519
TEST=Tested the following on a Cr48:
1. Log in to a new session and then plug in an unpartitioned USB drive.
2. Verify that the USB drive is mounted as a virtual mount point to a
   folder under External Storage in the file browser.
3. ssh into the Chromebook and kill the chrome process with SIGKILL.
4. After Chrome restarts, verify that the unpartitioned USB drive is
   again mounted as a virtual mount point to a folder under External
   Storage in the file browser.
5. Repeat 1-4 with a FAT-formatted USB drive and verify that the mounted
   folder is preserved after Chrome recopvers from a crash.

Change-Id: I4c924a20dca2cffc83e7820317e47af48c0522b7
Reviewed-on: http://gerrit.chromium.org/gerrit/9882
Reviewed-by: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
3 years agoChange the handling of parent block devices.
Ben Chan [Mon, 19 Sep 2011 19:14:28 +0000 (12:14 -0700)]
Change the handling of parent block devices.

This CL modifies the handling of parent block devices such that what
used to be considered non-automountable are now reported as
automountable but marked as hidden so that the file browser does not
show and mount them, but the image burner can see and use them.

BUG=chromium-os:20476
TEST=Verified parent block devices are reported by
EnumerateAutoMountableDevices and are marked as hidden by
GetDeviceProperties if they contain at least one partition.

Change-Id: Ia005a3ff1b3fee20add034c7cbac5133268499de
Reviewed-on: http://gerrit.chromium.org/gerrit/7941
Reviewed-by: Toni Barzic <tbarzic@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
3 years agoUnmount all removable devices or reserved mount points when a session ends.
Ben Chan [Fri, 30 Sep 2011 22:35:44 +0000 (15:35 -0700)]
Unmount all removable devices or reserved mount points when a session ends.

DiskManager currently reserves a virtual mount point for a device with
an unrecognized or unsupported filesystem and notifies Chrome an error.
When the user logs out and logs back in again, the virtual mount point
is preserved across sessions, but the error information is not. Chrome
thus cannot differentiate between a real mount point and a virtual one,
and mistakenly treat the virtual mount point as real. This CL resolves
this issue by forcing DiskManager to unmount all its managed mount
points when a session ends.

BUG=chromium-os:21111
TEST=Tested the following on a Cr48:
1. Log in to a new session and then plug in a USB drive.
2. Verify that the USB drive is mounted to a folder under External
   Storage in the file browser.
3. Log out the session.
4. ssh into the Chromebook and verify that no directory remains in
   /media/removable.
5. Log in to a new session again.
6. Verify that the USB drive is again mounted to a folder under
   External Storage in the file browser.

Change-Id: I49185c8129530d500ff598859858849406c08b58
Reviewed-on: http://gerrit.chromium.org/gerrit/8581
Reviewed-by: Toni Barzic <tbarzic@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
3 years agoPrevent a device with no media from being auto-mounted.
Ben Chan [Fri, 30 Sep 2011 21:35:08 +0000 (14:35 -0700)]
Prevent a device with no media from being auto-mounted.

This CL modifies UdevDevice::IsAutoMountable to report a device as
non-automountable if there is no media available on the device. This
prevents, for example, an optical drive without any disc from being
auto-mounted by the Chrome file browser, which causes an unwanted
virtual mount point being created.

BUG=chromium-os:20859
TEST=Tested the following:
1. Plug in a removable optical drive, with no disc in it, to a Chromebook.
2. Reboot the Chromebook and log in to a new session.
3. Open the file browser and navigate into External Storage.
4. Verify that the optical drive is not being mounted as a virtual folder.
5. Insert an optical disc, formatted with a supported filesystem, into
   the optical drive.
6. A new file browser tab is opened to show the content of the optical disc.
7. Reboot the Chromebook and log in to a new session again (with the
   optical disc still inserted in the optical drive).
8. Open the file browser and navigate into External Storage.
9. Verify that the optical drive is being mounted as a folder.

Change-Id: I4ec06592bcb3cb089b1967e5118d2c4fc35eda39
Reviewed-on: http://gerrit.chromium.org/gerrit/8578
Reviewed-by: Toni Barzic <tbarzic@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
3 years agocommon.mk: allow stripping disable and clean up opt v dbg
Will Drewry [Wed, 21 Sep 2011 17:53:08 +0000 (12:53 -0500)]
common.mk: allow stripping disable and clean up opt v dbg

Fixes incompatibility with ebuild stripdebug and STRIPDEBUG.

Adds -O2 back to "opt". Not sure when it was dropped.

TEST=cros-disks builds, ebuild doesn't complain:
"""
* QA Notice: Pre-stripped files found:
* /opt/google/cros-disks/disks
"""
is gone and it strips disks on install.
BUG=none

Change-Id: Idf317d8b05c27adbab541882b5f5106491830520
Reviewed-on: http://gerrit.chromium.org/gerrit/8054
Reviewed-by: Ben Chan <benchan@chromium.org>
Reviewed-by: Ken Mixter <kmixter@chromium.org>
Tested-by: Will Drewry <wad@chromium.org>
3 years agoAllow format manager to format the entire device using vfat.
Szymon Sidor [Wed, 14 Sep 2011 19:45:12 +0000 (12:45 -0700)]
Allow format manager to format the entire device using vfat.

Set defult formeted device label to UNTITLED.

BUG=chromium-os:20081
TEST=Manually tested it for devices with:
no partition table: plain, one filesystem, one corrupted filesystem
with partition table: existing partitions, corrupted partitions

Change-Id: I2589b9fb84a651337b1fecebf731f3e480b9288b
Reviewed-on: http://gerrit.chromium.org/gerrit/7726
Reviewed-by: Ben Chan <benchan@chromium.org>
Tested-by: Szymon Sidor <sidor@chromium.org>
3 years agoUse C++ unnamed namespace instead of static globals.
Ben Chan [Tue, 13 Sep 2011 16:16:28 +0000 (09:16 -0700)]
Use C++ unnamed namespace instead of static globals.

This CL cleans up the code to consistently define file scope constants
using C++ unnamed namespace instead of static globals.

BUG=none
TEST=Built and ran unit tests.

Change-Id: Ie86fcaf704b35d16b5e17a31acc4a1f9c8edca09
Reviewed-on: http://gerrit.chromium.org/gerrit/7605
Reviewed-by: Darin Petkov <petkov@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
3 years agoDetermine if a device has any partition.
Ben Chan [Sun, 11 Sep 2011 00:03:05 +0000 (17:03 -0700)]
Determine if a device has any partition.

This CL modifies UdevDevice to include a method for determining if a
device has any partition via libparted, and to report a device without
any partition as auto-mountable such that the device is exposed to the
file browser where users can select and format the entire device.

BUG=chromium-os:20293
TEST=Tested the following cases on Cr48:
1. Insert a formatted USB drive with no partitions and verify that
   the org.chromium.CrosDisks.EnumerateAutoMountableDevices DBus method
   reports /dev/sdb (assuming that /dev/sdb is assigned to the inserted
   USB).
2. Insert a formatted USB drive with one partition and verify that
   the org.chromium.CrosDisks.EnumerateAutoMountableDevices DBus method
   reports /dev/sdb1, but not /dev/sdb.
3. Insert a formatted USB drive with multiple partitions and verify
   that the org.chromium.CrosDisks.EnumerateAutoMountableDevices DBus
   method reports /dev/sdb1, /dev/sdb2, etc, but not /dev/sdb.

Change-Id: I94b20fa48630415e503ff436d3c3b99a4afffdc4
Reviewed-on: http://gerrit.chromium.org/gerrit/7524
Reviewed-by: Toni Barzic <tbarzic@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
3 years agoTemporarily remove the check for removable storage. factory-1020.B release-1011.B
Ben Chan [Wed, 7 Sep 2011 17:57:09 +0000 (10:57 -0700)]
Temporarily remove the check for removable storage.

This CL modifies the UdevDevice::IsAutoMountable() method such that it
does not check if a device is on a removable storage based on the removable
attribute in sysfs, which does not always tell the truth. A more
reliable solution is to be found.

BUG=chromium-os:19976
TEST=Tested mounting an external hard drive that manifested the problem.

Change-Id: If74557a0eabefddda6b14959331d419c129eaa7f
Reviewed-on: http://gerrit.chromium.org/gerrit/7338
Reviewed-by: Ryan Cairns <rtc@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
3 years agoFix gcc 4.6.0 compiler warning in unit test.
Ben Chan [Tue, 6 Sep 2011 22:55:10 +0000 (15:55 -0700)]
Fix gcc 4.6.0 compiler warning in unit test.

This CL works around an issue with the EXPECT_EQ macro in gtest when
gcc 4.6.0 is used to compile the code. gcc 4.6.0 throws a
null-conversion warning if a bool-type value is passed as the first
argument to EXPECT_EQ.

BUG=chromium-os:20069
TEST=Ran cros-disks unit tests with gcc-4.6.0 toolchain.

Change-Id: I74e943ac5043f922399b1560d3ae0caf0d3c7635
Reviewed-on: http://gerrit.chromium.org/gerrit/7301
Reviewed-by: asharif <asharif@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
3 years agoEnable NTFS filesystem support by default.
Ben Chan [Tue, 6 Sep 2011 14:43:03 +0000 (07:43 -0700)]
Enable NTFS filesystem support by default.

BUG=chromium-os:14981
TEST=Tested mounting NTFS-formatted filesystem on Cr48 without enabling
experimental storage features in crosh.

Change-Id: If12c4e42528b330f65632d94fe9bec5c6e0a9416
Reviewed-on: http://gerrit.chromium.org/gerrit/7266
Reviewed-by: Zelidrag Hornung <zelidrag@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
3 years agoRun the ntfs-3g process under the ntfs-3g user and group. factory-980.B test-982.B
Ben Chan [Wed, 31 Aug 2011 21:34:03 +0000 (14:34 -0700)]
Run the ntfs-3g process under the ntfs-3g user and group.

This CL modifies NTFSMounter to run the ntfs-3g process under the
ntfs-3g user and group instead of chronos when the ntfs-3g executable is
setuid-root.

BUG=chromium-os:19887
TEST=Tested mounting/unmounting NTFS-formatted filesystem on Cr48.

Change-Id: Ieb418c86d6d779831f78f18c4309ca8856470ac7
Reviewed-on: http://gerrit.chromium.org/gerrit/7036
Reviewed-by: Darin Petkov <petkov@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
3 years agoDetermine filesystem label and UUID directly through blkid.
Ben Chan [Thu, 25 Aug 2011 06:37:53 +0000 (23:37 -0700)]
Determine filesystem label and UUID directly through blkid.

This CL modifies the UdevDevice class to determine the filesystem type,
label and UUID of a device directly through the blkid API instead of using
the device properties from udev, which may not have been updated when the
information is needed before a udev change event occurs.

BUG=chromium-os:19631
TEST=Tested the following scenario on Cr48:

1. Insert a FAT-formatted USB storage with a non-empty filesystem label.
   The USB storage is mounted to a folder named with the same label.
2. Format the USB storage through the File Browser.
3. Verify that the remounted folder for the USB storage has a different
   name, which is the UUID of the newly formatted filesystem.
4. Repeat the test for a few times.

Change-Id: I01f43a5c46e3989f3ff7d9fa1c21f3de7cec0827
Reviewed-on: http://gerrit.chromium.org/gerrit/6754
Reviewed-by: Darin Petkov <petkov@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
3 years agoRemove deprecated and unused cros-disks DBus methods and signals.
Ben Chan [Thu, 25 Aug 2011 22:42:28 +0000 (15:42 -0700)]
Remove deprecated and unused cros-disks DBus methods and signals.

BUG=none
TEST=Built and ran unit tests.

Change-Id: I097a5fd9097c4a9041b5d412d7ed44fb8d8ef91c
Reviewed-on: http://gerrit.chromium.org/gerrit/6693
Reviewed-by: Darin Petkov <petkov@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
3 years agoAdd an option in mount managers to reserve mount paths on errors.
Ben Chan [Sun, 21 Aug 2011 17:15:30 +0000 (10:15 -0700)]
Add an option in mount managers to reserve mount paths on errors.

This CL introduces an option in mount managers to reserve a mount path
when the mount operation fails due to certain types of error. This
change is required by the File Browser UI to keep the mount directory
for an unknown or unsupported filesystem on an external storage in order
to allow users to select the directory and format the corresponding
filesystem.

BUG=chromium-os:19469
TEST=Ran unit tests and tested mounting unknown filesystem on Cr48.

Change-Id: I0b680b0730dc344f17284217a30ebb7357b689cc
Reviewed-on: http://gerrit.chromium.org/gerrit/6406
Reviewed-by: Darin Petkov <petkov@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
3 years agoSandbox avfsd process with limited process capabilities via libminijail.
Ben Chan [Wed, 24 Aug 2011 22:17:22 +0000 (15:17 -0700)]
Sandbox avfsd process with limited process capabilities via libminijail.

BUG=chromium-os:19627
TEST=Tested mounting/unmounting zip files on Cr48.

Change-Id: I688b86233cff75a5ecd3ceb6ea15603ace72b419
Reviewed-on: http://gerrit.chromium.org/gerrit/6614
Reviewed-by: Darin Petkov <petkov@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
3 years agoSandbox ntfs-3g process with limited process capabilities via libminijail.
Ben Chan [Tue, 23 Aug 2011 17:11:08 +0000 (10:11 -0700)]
Sandbox ntfs-3g process with limited process capabilities via libminijail.

BUG=chromium-os:19492
TEST=Tested mounting/unmounting NTFS-formatted filesystems on Cr48.

Change-Id: Ife5bcee265aa241d96d48b0d1f0bced5cf8afb4b
Reviewed-on: http://gerrit.chromium.org/gerrit/6570
Reviewed-by: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>