OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
3.5 KiB

  1. # --- T2-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # T2 SDE: package/.../embutils/mount.patch
  5. # Copyright (C) 2004 - 2006 The T2 SDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- T2-COPYRIGHT-NOTE-END ---
  16. Hardened mount to not crash when the directory was not found in /etc/fstab and
  17. improved the tokenizing to strip white spaces, since the files are often
  18. indented in tabular form.
  19. - Rene Rebe <rene@exactcode.de>
  20. --- embutils-0.17/mount.c 2004-01-09 17:03:48.000000000 +0100
  21. +++ embutils-0.17-fixed/mount.c 2005-02-09 12:34:56.222517672 +0100
  22. @@ -142,12 +142,20 @@
  23. * isn't really portable
  24. */
  25. -/* tokenizes the string when a space appears (not thread safe) */
  26. +/* tokenizes the string when a space appears and strip leading ones
  27. + (not thread safe) */
  28. static char *spacetok(char *s) {
  29. static char *buffer=NULL;
  30. + char *tmp;
  31. +
  32. if(s)
  33. buffer=s;
  34. - char *tmp=buffer;
  35. +
  36. + /* skip leading spaces */
  37. + while(*buffer && isspace(*buffer))
  38. + ++buffer;
  39. +
  40. + tmp=buffer;
  41. for(;*buffer;++buffer) {
  42. if(isspace(*buffer)) {
  43. *buffer++=0;
  44. @@ -463,13 +470,18 @@
  45. if(fh) {
  46. struct mntentry *mnt;
  47. while((mnt=mnt_entry(fh)))
  48. - if(!strcmp(mnt->dir,device)) {
  49. + if(mnt->dir && !strcmp(mnt->dir,device)) {
  50. device=mnt->device;
  51. dir=mnt->dir;
  52. fs_type=mnt->fs_type;
  53. parse_options(mnt->opts,&flags,data+data_size,DATA_BUFFER_SIZE-data_size);
  54. break;
  55. }
  56. + if (!dir) {
  57. + __write2(device);
  58. + write(2," no found in /etc/fstab\n",24);
  59. + return 1;
  60. + }
  61. }
  62. #ifdef CLEANUP
  63. io_close(fh);
  64. Added bind mount and fixed the option_parser to be able to parse options
  65. with only one part and no , seperator ...
  66. Rene Rebe <rene@exactcode.de>
  67. --- embutils-0.17/mount.c 2004-01-09 17:03:48.000000000 +0100
  68. +++ embutils-0.17-mount/mount.c 2005-06-19 15:13:34.000000000 +0200
  69. @@ -26,6 +26,7 @@
  70. #ifdef LINUX
  71. #include <sys/mount.h>
  72. #include <paths.h>
  73. +#include <linux/fs.h> /* MS_MOVE */
  74. #ifdef _PATH_MOUNTED
  75. const char *const mtab=_PATH_MOUNTED;
  76. #else
  77. @@ -227,6 +228,9 @@
  78. {"suid", ~MS_NOSUID, 0},
  79. {"sync", ~0, MS_SYNCHRONOUS},
  80. {"bind", ~0, MS_BIND},
  81. +#ifdef LINUX
  82. + {"move", ~0, MS_MOVE},
  83. +#endif
  84. {0, 0, 0}
  85. };
  86. /*
  87. @@ -240,10 +244,15 @@
  88. size_t data_set=0;
  89. for(;;) {
  90. const struct mount_options *i;
  91. - char *ptr=strchr(str,',');
  92. - if(!ptr)
  93. + char *ptr;
  94. +
  95. + if (!str || !*str)
  96. break;
  97. - *ptr=0;
  98. +
  99. + ptr=strchr(str,',');
  100. + if(!ptr) ptr=(char*)str+strlen(str)-1;
  101. + else *ptr=0;
  102. +
  103. for(i=options; i->name; ++i)
  104. if(!strcmp(str,i->name)) {
  105. *flags&=i->and;
  106. Do not segfault by default when no type was give, also none might be needed
  107. due bind or move mounts.
  108. - Rene Rebe <rene@exactcode.de>
  109. --- embutils-0.17/mount.c 2005-12-18 23:49:12.000000000 +0100
  110. +++ embutils-0.17-patched/mount.c 2005-12-19 10:02:38.000000000 +0100
  111. @@ -414,7 +414,7 @@
  112. int main(int argc, char **argv) {
  113. unsigned long flags=0;
  114. - const char *fs_type=NULL;
  115. + const char *fs_type="";
  116. const char *device=NULL;
  117. const char *dir=NULL;
  118. enum { DATA_BUFFER_SIZE=100 };