034-ramfs-mode-support.patch 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. Index: linux-2.6.21.7/fs/ramfs/inode.c
  2. ===================================================================
  3. --- linux-2.6.21.7.orig/fs/ramfs/inode.c
  4. +++ linux-2.6.21.7/fs/ramfs/inode.c
  5. @@ -33,6 +33,7 @@
  6. #include <linux/smp_lock.h>
  7. #include <linux/backing-dev.h>
  8. #include <linux/ramfs.h>
  9. +#include <linux/ctype.h>
  10. #include <asm/uaccess.h>
  11. #include "internal.h"
  12. @@ -160,10 +161,66 @@ static const struct super_operations ram
  13. .drop_inode = generic_delete_inode,
  14. };
  15. +static int ramfs_parse_options(char *options, int *mode)
  16. +{
  17. + char *this_char, *value, *rest;
  18. +
  19. + while (options != NULL) {
  20. + this_char = options;
  21. + for (;;) {
  22. + /*
  23. + * NUL-terminate this option: unfortunately,
  24. + * mount options form a comma-separated list,
  25. + * but mpol's nodelist may also contain commas.
  26. + */
  27. + options = strchr(options, ',');
  28. + if (options == NULL)
  29. + break;
  30. + options++;
  31. + if (!isdigit(*options)) {
  32. + options[-1] = '\0';
  33. + break;
  34. + }
  35. + }
  36. + if (!*this_char)
  37. + continue;
  38. + if ((value = strchr(this_char,'=')) != NULL) {
  39. + *value++ = 0;
  40. + } else {
  41. + printk(KERN_ERR
  42. + "ramfs: No value for mount option '%s'\n",
  43. + this_char);
  44. + return 1;
  45. + }
  46. +
  47. + if (!strcmp(this_char,"mode")) {
  48. + if (!mode)
  49. + continue;
  50. + *mode = simple_strtoul(value,&rest,8);
  51. + if (*rest)
  52. + goto bad_val;
  53. + } else {
  54. + printk(KERN_ERR "ramfs: Bad mount option %s\n",
  55. + this_char);
  56. + return 1;
  57. + }
  58. + }
  59. + return 0;
  60. +
  61. +bad_val:
  62. + printk(KERN_ERR "ramfs: Bad value '%s' for mount option '%s'\n",
  63. + value, this_char);
  64. + return 1;
  65. +}
  66. +
  67. static int ramfs_fill_super(struct super_block * sb, void * data, int silent)
  68. {
  69. struct inode * inode;
  70. struct dentry * root;
  71. + int mode = 0755;
  72. +
  73. + if (ramfs_parse_options(data, &mode))
  74. + return -EINVAL;
  75. sb->s_maxbytes = MAX_LFS_FILESIZE;
  76. sb->s_blocksize = PAGE_CACHE_SIZE;
  77. @@ -171,7 +228,7 @@ static int ramfs_fill_super(struct super
  78. sb->s_magic = RAMFS_MAGIC;
  79. sb->s_op = &ramfs_ops;
  80. sb->s_time_gran = 1;
  81. - inode = ramfs_get_inode(sb, S_IFDIR | 0755, 0);
  82. + inode = ramfs_get_inode(sb, S_IFDIR | mode, 0);
  83. if (!inode)
  84. return -ENOMEM;