Advertisement
Guest User

Untitled

a guest
Feb 16th, 2014
3,014
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.71 KB | None | 0 0
  1. diff -Nru prl_fs.orig/SharedFolders/Guest/Linux/prl_fs/inode.c prl_fs/SharedFolders/Guest/Linux/prl_fs/inode.c
  2. --- prl_fs.orig/SharedFolders/Guest/Linux/prl_fs/inode.c 2013-11-11 17:56:58.000000000 +0200
  3. +++ prl_fs/SharedFolders/Guest/Linux/prl_fs/inode.c 2013-11-29 20:41:53.689167040 +0200
  4. @@ -199,10 +199,18 @@
  5. if (attr->valid & _PATTR_MODE)
  6. inode->i_mode = (inode->i_mode & S_IFMT) | (attr->mode & 0777);
  7. if ((attr->valid & _PATTR_UID) &&
  8. - (sbi->plain || sbi->share || attr->uid == -1))
  9. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
  10. + (sbi->plain || sbi->share || __kuid_val(attr->uid) == -1))
  11. +#else
  12. + (sbi->plain || sbi->share || attr->uid == -1)))
  13. +#endif
  14. inode->i_uid = attr->uid;
  15. if ((attr->valid & _PATTR_GID) &&
  16. - (sbi->plain || sbi->share || attr->gid == -1))
  17. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
  18. + (sbi->plain || sbi->share || __kgid_val(attr->gid) == -1))
  19. +#else
  20. + (sbi->plain || sbi->share || attr->gid == -1)))
  21. +#endif
  22. inode->i_gid = attr->gid;
  23. return;
  24. }
  25. @@ -521,13 +529,21 @@
  26.  
  27. generic_fillattr(dentry->d_inode, stat);
  28. if (PRLFS_SB(dentry->d_sb)->share) {
  29. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
  30. + if (__kuid_val(stat->uid) != -1)
  31. +#else
  32. if (stat->uid != -1)
  33. +#endif
  34. #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
  35. stat->uid = current->fsuid;
  36. #else
  37. stat->uid = current->cred->fsuid;
  38. #endif
  39. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
  40. + if (__kgid_val(stat->gid) != -1)
  41. +#else
  42. if (stat->gid != -1)
  43. +#endif
  44. #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
  45. stat->gid = current->fsgid;
  46. #else
  47. @@ -577,9 +593,17 @@
  48. mode = inode->i_mode;
  49. isdir = S_ISDIR(mode);
  50.  
  51. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
  52. + if (__kuid_val(inode->i_uid) != -1)
  53. +#else
  54. if (inode->i_uid != -1)
  55. +#endif
  56. mode = mode >> 6;
  57. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
  58. + else if (__kgid_val(inode->i_gid) != -1)
  59. +#else
  60. else if (inode->i_gid != -1)
  61. +#endif
  62. mode = mode >> 3;
  63. mode &= 0007;
  64. mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
  65. diff -Nru prl_fs.orig/SharedFolders/Guest/Linux/prl_fs/prlfs.h prl_fs/SharedFolders/Guest/Linux/prl_fs/prlfs.h
  66. --- prl_fs.orig/SharedFolders/Guest/Linux/prl_fs/prlfs.h 2013-11-11 17:56:58.000000000 +0200
  67. +++ prl_fs/SharedFolders/Guest/Linux/prl_fs/prlfs.h 2013-11-29 20:46:27.662771996 +0200
  68. @@ -28,8 +28,13 @@
  69. struct pci_dev *pdev;
  70. unsigned sfid;
  71. unsigned ttl;
  72. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
  73. + kuid_t uid;
  74. + kgid_t gid;
  75. +#else
  76. uid_t uid;
  77. gid_t gid;
  78. +#endif
  79. int readonly;
  80. int share;
  81. int plain;
  82. diff -Nru prl_fs.orig/SharedFolders/Guest/Linux/prl_fs/super.c prl_fs/SharedFolders/Guest/Linux/prl_fs/super.c
  83. --- prl_fs.orig/SharedFolders/Guest/Linux/prl_fs/super.c 2013-11-11 17:56:58.000000000 +0200
  84. +++ prl_fs/SharedFolders/Guest/Linux/prl_fs/super.c 2013-11-29 20:28:39.212000000 +0200
  85. @@ -13,6 +13,7 @@
  86. #include <linux/seq_file.h>
  87. #include <linux/ctype.h>
  88. #include <linux/vfs.h>
  89. +#include <linux/parser.h>
  90. #include "prlfs.h"
  91. #include "prlfs_compat.h"
  92.  
  93. @@ -26,38 +27,35 @@
  94. extern struct file_operations prlfs_names_fops;
  95. extern struct inode_operations prlfs_names_iops;
  96.  
  97. -static int prlfs_strtoui(char *cp, unsigned *result){
  98. - int ret = 0;
  99. - unsigned ui = 0;
  100. - unsigned digit;
  101. -
  102. - if (!cp || (*cp == 0))
  103. - return -EINVAL;
  104. -
  105. - while (*cp) {
  106. - if (isdigit(*cp)) {
  107. - digit = *cp - '0';
  108. - } else {
  109. - ret = -EINVAL;
  110. - break;
  111. - }
  112. - if (ui > ui * 10U + digit)
  113. - return -EINVAL;
  114. - ui = ui * 10U + digit;
  115. - cp++;
  116. - }
  117. -
  118. - if (ret == 0)
  119. - *result = ui;
  120. -
  121. - return ret;
  122. -}
  123. +enum {
  124. + Opt_uid,
  125. + Opt_gid,
  126. + Opt_ttl,
  127. + Opt_nls,
  128. + Opt_share,
  129. + Opt_plain,
  130. + Opt_sf,
  131. + Opt_err,
  132. +};
  133. +
  134. +static const match_table_t prlfs_tokens = {
  135. + {Opt_uid, "uid=%d"},
  136. + {Opt_gid, "gid=%d"},
  137. + {Opt_ttl, "ttl=%u"},
  138. + {Opt_nls, "nls=%s"},
  139. + {Opt_share, "share"},
  140. + {Opt_plain, "plain"},
  141. + {Opt_sf, "sf=%s"},
  142. + {Opt_err, NULL}
  143. +};
  144.  
  145. static int
  146. prlfs_parse_mount_options(char *options, struct prlfs_sb_info *sbi)
  147. {
  148. + substring_t args[MAX_OPT_ARGS];
  149. int ret = 0;
  150. - char *opt, *val;
  151. + int val;
  152. + char *opt;
  153.  
  154. DPRINTK("ENTER\n");
  155. #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
  156. @@ -70,35 +68,54 @@
  157. sbi->ttl = HZ;
  158.  
  159. if (!options)
  160. - goto out;
  161. + goto out;
  162.  
  163. - while (!ret && (opt = strsep(&options, ",")) != NULL)
  164. + while (!ret && ((opt = strsep(&options, ",")) != NULL))
  165. {
  166. + int token;
  167. if (!*opt)
  168. continue;
  169.  
  170. - val = strchr(opt, '=');
  171. - if (val) {
  172. - *(val++) = 0;
  173. - if (strlen(val) == 0)
  174. - val = NULL;
  175. - }
  176. - if (!strcmp(opt, "ttl") && val)
  177. - ret = prlfs_strtoui(val, &sbi->ttl);
  178. - else if (!strcmp(opt, "uid") && val)
  179. - ret = prlfs_strtoui(val, &sbi->uid);
  180. - else if (!strcmp(opt, "gid") && val)
  181. - ret = prlfs_strtoui(val, &sbi->gid);
  182. - else if (!strcmp(opt, "nls") && val)
  183. - strncpy(sbi->nls, val, LOCALE_NAME_LEN - 1);
  184. - else if (!strcmp(opt, "share"))
  185. + token = match_token(opt, prlfs_tokens, args);
  186. + switch (token) {
  187. + case Opt_uid:
  188. + if (!(ret = match_int(&args[0], &val)))
  189. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
  190. + sbi->uid = KUIDT_INIT(val);
  191. +#else
  192. + sbi->uid = val;
  193. +#endif
  194. + break;
  195. + case Opt_gid:
  196. + if (!(ret = match_int(&args[0], &val)))
  197. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
  198. + sbi->gid = KGIDT_INIT(val);
  199. +#else
  200. + sbi->gid = val;
  201. +#endif
  202. + break;
  203. + case Opt_ttl:
  204. + if (!(ret = match_int(&args[0], &val)))
  205. + sbi->ttl = val;
  206. + break;
  207. + case Opt_nls:
  208. + if (!match_strlcpy(sbi->nls, &args[0], LOCALE_NAME_LEN - 1))
  209. + ret = -EINVAL;
  210. + break;
  211. + case Opt_share:
  212. sbi->share = 1;
  213. - else if (!strcmp(opt, "plain"))
  214. + break;
  215. + case Opt_plain:
  216. sbi->plain = 1;
  217. - else if (!strcmp(opt, "sf") && val)
  218. - strncpy(sbi->name, val, sizeof(sbi->name));
  219. - else
  220. + break;
  221. + case Opt_sf:
  222. + if (!match_strlcpy(sbi->name, &args[0], sizeof(sbi->name)))
  223. + ret = -EINVAL;
  224. + break;
  225. + default:
  226. ret = -EINVAL;
  227. + }
  228. + DPRINTK("PARSE interating %d:%d:%s\n", token, val, args[0]);
  229. }
  230. out:
  231. DPRINTK("EXIT returning %d\n", ret);
  232. diff -Nru prl_fs.orig/SharedFolders/Interfaces/sf_lin.h prl_fs/SharedFolders/Interfaces/sf_lin.h
  233. --- prl_fs.orig/SharedFolders/Interfaces/sf_lin.h 2013-11-11 18:11:49.000000000 +0200
  234. +++ prl_fs/SharedFolders/Interfaces/sf_lin.h 2013-11-29 03:11:48.924415600 +0200
  235. @@ -40,8 +40,13 @@
  236. unsigned long long mtime;
  237. unsigned long long ctime;
  238. unsigned int mode;
  239. - unsigned int uid;
  240. - unsigned int gid;
  241. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
  242. + kuid_t uid;
  243. + kgid_t gid;
  244. +#else
  245. + uid_t uid;
  246. + gid_t gid;
  247. +#endif
  248. unsigned int valid;
  249. } PACKED;
  250. SFLIN_CHECK_SIZE(prlfs_attr, sizeof(struct prlfs_attr), 48)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement