Create avfs run directory under /run instead of /var/run.

CL:186240 migrated /var/run to /run and made /var/run a symlink to /run.
This CL modifies cros-disks to create avfs run directory under /run
directly instead of /var/run.

BUG=chromium:388969
TEST=Tested the following:
1. `FEATURES=test emerge-$BOARD platform2`
2. Run platform_CrosDisksArchive test.
3. Manually open a ZIP file from Files.app.

Change-Id: I55d25499ffae44e994862b4ddc62b2c8dfa99086
Reviewed-on: https://chromium-review.googlesource.com/205760
Reviewed-by: Kazuhiro Inaba <kinaba@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Reviewed-by: Toni Barzic <tbarzic@chromium.org>
diff --git a/archive_manager.cc b/archive_manager.cc
index 85dd282..7d7257f 100644
--- a/archive_manager.cc
+++ b/archive_manager.cc
@@ -44,10 +44,10 @@
 const char kAVFSSeccompFilterPolicyFile[] =
     "/opt/google/cros-disks/avfsd-seccomp.policy";
 const char kAVFSMountProgram[] = "/usr/bin/avfsd";
-const char kAVFSRootDirectory[] = "/var/run/avfsroot";
-const char kAVFSLogFile[] = "/var/run/avfsroot/avfs.log";
-const char kAVFSMediaDirectory[] = "/var/run/avfsroot/media";
-const char kAVFSUsersDirectory[] = "/var/run/avfsroot/users";
+const char kAVFSRootDirectory[] = "/run/avfsroot";
+const char kAVFSLogFile[] = "/run/avfsroot/avfs.log";
+const char kAVFSMediaDirectory[] = "/run/avfsroot/media";
+const char kAVFSUsersDirectory[] = "/run/avfsroot/users";
 const char kMediaDirectory[] = "/media";
 const char kUserRootDirectory[] = "/home/chronos";
 const AVFSPathMapping kAVFSPathMapping[] = {
@@ -217,11 +217,11 @@
   // When mounting an archive within another mounted archive, we need to
   // resolve the virtual path of the inner archive to the "unfolded"
   // form within the AVFS mount, such as
-  //   "/var/run/avfsroot/media/layer2.zip#/test/doc/layer1.zip#"
+  //   "/run/avfsroot/media/layer2.zip#/test/doc/layer1.zip#"
   // instead of the "nested" form, such as
-  //   "/var/run/avfsroot/media/archive/layer2.zip/test/doc/layer1.zip#"
+  //   "/run/avfsroot/media/archive/layer2.zip/test/doc/layer1.zip#"
   // where "/media/archive/layer2.zip" is a mount point to the virtual
-  // path "/var/run/avfsroot/media/layer2.zip#".
+  // path "/run/avfsroot/media/layer2.zip#".
   //
   // Mounting the inner archive using the nested form may cause problems
   // reading files from the inner archive. To avoid that, we first try to
@@ -232,9 +232,9 @@
   //
   // e.g. Given |path| is "/media/archive/layer2.zip/test/doc/layer1.zip",
   //      and "/media/archive/layer2.zip" is a mount point to the virtual
-  //      path "/var/run/avfsroot/media/layer2.zip#" within the AVFS mount.
+  //      path "/run/avfsroot/media/layer2.zip#" within the AVFS mount.
   //      The following code should return the virtual path of |path| as
-  //      "/var/run/avfsroot/media/layer2.zip#/test/doc/layer1.zip#".
+  //      "/run/avfsroot/media/layer2.zip#/test/doc/layer1.zip#".
   map<string, string>::const_iterator handler_iterator =
       extension_handlers_.find(extension);
   if (handler_iterator == extension_handlers_.end())
diff --git a/archive_manager_unittest.cc b/archive_manager_unittest.cc
index 133d523..f69fc4e 100644
--- a/archive_manager_unittest.cc
+++ b/archive_manager_unittest.cc
@@ -187,18 +187,18 @@
 TEST_F(ArchiveManagerTest, GetAVFSPath) {
   manager_.RegisterFileExtension("zip", "#uzip");
 
-  EXPECT_EQ("/var/run/avfsroot/users/user/Downloads/a.zip#uzip",
+  EXPECT_EQ("/run/avfsroot/users/user/Downloads/a.zip#uzip",
             manager_.GetAVFSPath("/home/chronos/user/Downloads/a.zip", "zip"));
-  EXPECT_EQ("/var/run/avfsroot/users/u-0123456789abcdef0123456789abcdef01234567"
+  EXPECT_EQ("/run/avfsroot/users/u-0123456789abcdef0123456789abcdef01234567"
             "/Downloads/a.zip#uzip",
             manager_.GetAVFSPath(
                 "/home/chronos/u-0123456789abcdef0123456789abcdef01234567"
                 "/Downloads/a.zip", "zip"));
-  EXPECT_EQ("/var/run/avfsroot/media/archive/test.zip/doc.zip#uzip",
+  EXPECT_EQ("/run/avfsroot/media/archive/test.zip/doc.zip#uzip",
             manager_.GetAVFSPath("/media/archive/test.zip/doc.zip", "zip"));
-  EXPECT_EQ("/var/run/avfsroot/media/removable/disk1/test.zip#uzip",
+  EXPECT_EQ("/run/avfsroot/media/removable/disk1/test.zip#uzip",
             manager_.GetAVFSPath("/media/removable/disk1/test.zip", "zip"));
-  EXPECT_EQ("/var/run/avfsroot/media/removable/disk1/test.ZIP#uzip",
+  EXPECT_EQ("/run/avfsroot/media/removable/disk1/test.ZIP#uzip",
             manager_.GetAVFSPath("/media/removable/disk1/test.ZIP", "zip"));
 }
 
@@ -219,41 +219,41 @@
 TEST_F(ArchiveManagerTest, GetAVFSPathWithNestedArchives) {
   manager_.RegisterFileExtension("zip", "#uzip");
 
-  EXPECT_EQ("/var/run/avfsroot/media/archive/l2.zip/l1.zip#uzip",
+  EXPECT_EQ("/run/avfsroot/media/archive/l2.zip/l1.zip#uzip",
             manager_.GetAVFSPath("/media/archive/l2.zip/l1.zip", "zip"));
 
   // archive within an archive
   manager_.AddMountVirtualPath("/media/archive/l2.zip",
-                               "/var/run/avfsroot/media/l2.zip#uzip");
-  EXPECT_EQ("/var/run/avfsroot/media/l2.zip#uzip/l1.zip#uzip",
+                               "/run/avfsroot/media/l2.zip#uzip");
+  EXPECT_EQ("/run/avfsroot/media/l2.zip#uzip/l1.zip#uzip",
             manager_.GetAVFSPath("/media/archive/l2.zip/l1.zip", "zip"));
-  EXPECT_EQ("/var/run/avfsroot/media/l2.zip#uzip/t/l1.zip#uzip",
+  EXPECT_EQ("/run/avfsroot/media/l2.zip#uzip/t/l1.zip#uzip",
             manager_.GetAVFSPath("/media/archive/l2.zip/t/l1.zip", "zip"));
-  EXPECT_EQ("/var/run/avfsroot/media/l2.zip#uzip/t/doc/l1.zip#uzip",
+  EXPECT_EQ("/run/avfsroot/media/l2.zip#uzip/t/doc/l1.zip#uzip",
             manager_.GetAVFSPath("/media/archive/l2.zip/t/doc/l1.zip", "zip"));
 
   // archive within an archive within an archive
   manager_.AddMountVirtualPath(
       "/media/archive/l1.zip",
-      "/var/run/avfsroot/media/l2.zip#uzip/l1.zip#uzip");
-  EXPECT_EQ("/var/run/avfsroot/media/l2.zip#uzip/l1.zip#uzip/l0.zip#uzip",
+      "/run/avfsroot/media/l2.zip#uzip/l1.zip#uzip");
+  EXPECT_EQ("/run/avfsroot/media/l2.zip#uzip/l1.zip#uzip/l0.zip#uzip",
             manager_.GetAVFSPath("/media/archive/l1.zip/l0.zip", "zip"));
-  EXPECT_EQ("/var/run/avfsroot/media/l2.zip#uzip/l1.zip#uzip/test/l0.zip#uzip",
+  EXPECT_EQ("/run/avfsroot/media/l2.zip#uzip/l1.zip#uzip/test/l0.zip#uzip",
             manager_.GetAVFSPath("/media/archive/l1.zip/test/l0.zip", "zip"));
   manager_.RemoveMountVirtualPath("/media/archive/l1.zip");
 
   manager_.AddMountVirtualPath(
       "/media/archive/l1.zip",
-      "/var/run/avfsroot/media/l2.zip#uzip/test/l1.zip#uzip");
-  EXPECT_EQ("/var/run/avfsroot/media/l2.zip#uzip/test/l1.zip#uzip/l0.zip#uzip",
+      "/run/avfsroot/media/l2.zip#uzip/test/l1.zip#uzip");
+  EXPECT_EQ("/run/avfsroot/media/l2.zip#uzip/test/l1.zip#uzip/l0.zip#uzip",
             manager_.GetAVFSPath("/media/archive/l1.zip/l0.zip", "zip"));
   EXPECT_EQ(
-      "/var/run/avfsroot/media/l2.zip#uzip/test/l1.zip#uzip/test/l0.zip#uzip",
+      "/run/avfsroot/media/l2.zip#uzip/test/l1.zip#uzip/test/l0.zip#uzip",
       manager_.GetAVFSPath("/media/archive/l1.zip/test/l0.zip", "zip"));
   manager_.RemoveMountVirtualPath("/media/archive/l1.zip");
 
   manager_.RemoveMountVirtualPath("/media/archive/l2.zip");
-  EXPECT_EQ("/var/run/avfsroot/media/archive/l2.zip/l1.zip#uzip",
+  EXPECT_EQ("/run/avfsroot/media/archive/l2.zip/l1.zip#uzip",
             manager_.GetAVFSPath("/media/archive/l2.zip/l1.zip", "zip"));
 }