hds: change mkdir permission and 9pfs packet payload size 72/56572/3
authorChulHo Song <ch81.song@samsung.com>
Mon, 11 Jan 2016 08:28:30 +0000 (17:28 +0900)
committerChulHo Song <ch81.song@samsung.com>
Fri, 22 Jan 2016 03:55:35 +0000 (12:55 +0900)
Change-Id: I34266e8ccdc4688d75519a1ad03b3524f48f606c
Signed-off-by: ChulHo Song <ch81.song@samsung.com>
src/common.cpp

index d7ba09c2d87decaca5d400c9e3558994cc22b8d4..b5a8d1048edf2c79d5fa7e21573d1bb4de41dc6a 100644 (file)
 #include "emuld.h"
 
 #define CMD_BUF 1024
+#define OPT_SIZE 64
+#define P9_FCALL_SIZE 20
+#define DEFAULT_PAYLOAD_SIZE 8192
+#define MAX_PAYLOAD_SIZE 65536
+#define MKDIR_MODE (S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)
+
+unsigned int msize = MAX_PAYLOAD_SIZE;
 
 void add_vconf_map_common(void)
 {
@@ -131,11 +138,24 @@ int get_vconf_status(char** value, vconf_t type, const char* key)
 int try_mount(char* tag, char* path)
 {
     int ret = 0;
+    char mount_opt[OPT_SIZE] = {0, };
+
+    snprintf(mount_opt, sizeof(mount_opt), "trans=virtio,version=9p2000.L,msize=%u", msize - P9_FCALL_SIZE);
+
+
+    ret = mount(tag, path, "9p", 0, mount_opt);
 
-    ret = mount(tag, path, "9p", 0,
-                "trans=virtio,version=9p2000.L,msize=65536");
     if (ret == -1)
+    {
+        if (errno == ENOMEM && msize > DEFAULT_PAYLOAD_SIZE)
+        {
+            LOGWARN("Mount failed with ENOMEM. Payload size (%u)", msize);
+            msize = msize >> 1;
+            LOGWARN("Shrink payload size (%u)", msize);
+        }
         return errno;
+    }
+    msize = MAX_PAYLOAD_SIZE;
 
     return ret;
 }
@@ -172,13 +192,13 @@ static int do_mkdir(const char *dir)
         if (*p == '/')
         {
             *p = 0;
-            if (mkdir(tmp, 0644) == -1 && errno != EEXIST)
+            if (mkdir(tmp, MKDIR_MODE) == -1 && errno != EEXIST)
                 return -1;
             *p = '/';
         }
     }
 
-    return mkdir(tmp, 0644);
+    return mkdir(tmp, MKDIR_MODE);
 }
 
 bool valid_hds_path(char* path) {