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.

266 lines
6.2 KiB

Added all changes from old 4.0 version: PSTACK, libmysqld and MySQL filesystem UPDATE ... ORDER BY DELETE ... ORDER BY New faster fulltext handling Faster compressed keys Makefile.am: Added support for pstack and libmysqld_dir acconfig.h: MySQL filesystem and PSTACK acinclude.m4: MySQL File system client/mysql.cc: Support for --xml configure.in: Pstack, MySQL FS and libmysqld_dir include/ft_global.h: Faster fulltext include/my_pthread.h: Made c++ safe include/myisam.h: Update for faster fulltext include/mysql_com.h: new my_net_read() include/violite.h: libmysqld libmysql/net.c: New protocol that supports big packets myisam/Makefile.am: Faster fulltext myisam/ft_parser.c: Faster fulltext myisam/ft_search.c: Faster fulltext myisam/ft_update.c: Faster fulltext myisam/ftdefs.h: Faster fulltext myisam/mi_check.c: Faster fulltext myisam/mi_open.c: Faster compressed keys myisam/mi_search.c: Faster compressed keys myisam/mi_update.c: Faster compressed keys myisam/myisamdef.h: Faster compressed keys myisam/sort.c: Faster compressed keys mysql-test/mysql-test-run.sh: --skip-innobase and --skip-bdb sql/ChangeLog: Changelog sql/Makefile.am: PSTACK sql/mysql_priv.h: New ORDER BY options and libmysqld sql/mysqld.cc: PSTACK sql/net_serv.cc: New protocol that supports big packets sql/share/estonian/errmsg.txt: New error messages sql/sql_base.cc: Better list_open_tabels sql/sql_delete.cc: ORDER BY for delete sql/sql_lex.cc: Added language convertation of all strings sql/sql_parse.cc: Changes for libmysqld Use new ORDER BY options sql/sql_show.cc: Character set convertations Use new list_open_tables function. sql/sql_update.cc: UPDATE ... ORDER BY sql/sql_yacc.yy: Clean up symbol definitions DELETE .. ORDER BY UPDATE .. ORDER BY sql/table.h: new OPEN_TABLE_LIST structure BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted
25 years ago
  1. /* filemode.c -- make a string describing file modes
  2. Copyright (C) 1985, 90, 91, 94, 95, 1997 Free Software Foundation, Inc.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2, or (at your option)
  6. any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  14. 02111-1307, USA. */
  15. #include "bfd.h"
  16. #include "bucomm.h"
  17. static char ftypelet PARAMS ((unsigned long));
  18. static void setst PARAMS ((unsigned long, char *));
  19. /* filemodestring - fill in string STR with an ls-style ASCII
  20. representation of the st_mode field of file stats block STATP.
  21. 10 characters are stored in STR; no terminating null is added.
  22. The characters stored in STR are:
  23. 0 File type. 'd' for directory, 'c' for character
  24. special, 'b' for block special, 'm' for multiplex,
  25. 'l' for symbolic link, 's' for socket, 'p' for fifo,
  26. '-' for any other file type
  27. 1 'r' if the owner may read, '-' otherwise.
  28. 2 'w' if the owner may write, '-' otherwise.
  29. 3 'x' if the owner may execute, 's' if the file is
  30. set-user-id, '-' otherwise.
  31. 'S' if the file is set-user-id, but the execute
  32. bit isn't set.
  33. 4 'r' if group members may read, '-' otherwise.
  34. 5 'w' if group members may write, '-' otherwise.
  35. 6 'x' if group members may execute, 's' if the file is
  36. set-group-id, '-' otherwise.
  37. 'S' if it is set-group-id but not executable.
  38. 7 'r' if any user may read, '-' otherwise.
  39. 8 'w' if any user may write, '-' otherwise.
  40. 9 'x' if any user may execute, 't' if the file is "sticky"
  41. (will be retained in swap space after execution), '-'
  42. otherwise.
  43. 'T' if the file is sticky but not executable. */
  44. #if 0
  45. /* This is not used; only mode_string is used. */
  46. void
  47. filemodestring (statp, str)
  48. struct stat *statp;
  49. char *str;
  50. {
  51. mode_string ((unsigned long) statp->st_mode, str);
  52. }
  53. #endif
  54. /* Get definitions for the file permission bits. */
  55. #ifndef S_IRWXU
  56. #define S_IRWXU 0700
  57. #endif
  58. #ifndef S_IRUSR
  59. #define S_IRUSR 0400
  60. #endif
  61. #ifndef S_IWUSR
  62. #define S_IWUSR 0200
  63. #endif
  64. #ifndef S_IXUSR
  65. #define S_IXUSR 0100
  66. #endif
  67. #ifndef S_IRWXG
  68. #define S_IRWXG 0070
  69. #endif
  70. #ifndef S_IRGRP
  71. #define S_IRGRP 0040
  72. #endif
  73. #ifndef S_IWGRP
  74. #define S_IWGRP 0020
  75. #endif
  76. #ifndef S_IXGRP
  77. #define S_IXGRP 0010
  78. #endif
  79. #ifndef S_IRWXO
  80. #define S_IRWXO 0007
  81. #endif
  82. #ifndef S_IROTH
  83. #define S_IROTH 0004
  84. #endif
  85. #ifndef S_IWOTH
  86. #define S_IWOTH 0002
  87. #endif
  88. #ifndef S_IXOTH
  89. #define S_IXOTH 0001
  90. #endif
  91. /* Like filemodestring, but only the relevant part of the `struct stat'
  92. is given as an argument. */
  93. void
  94. mode_string (mode, str)
  95. unsigned long mode;
  96. char *str;
  97. {
  98. str[0] = ftypelet ((unsigned long) mode);
  99. str[1] = (mode & S_IRUSR) != 0 ? 'r' : '-';
  100. str[2] = (mode & S_IWUSR) != 0 ? 'w' : '-';
  101. str[3] = (mode & S_IXUSR) != 0 ? 'x' : '-';
  102. str[4] = (mode & S_IRGRP) != 0 ? 'r' : '-';
  103. str[5] = (mode & S_IWGRP) != 0 ? 'w' : '-';
  104. str[6] = (mode & S_IXGRP) != 0 ? 'x' : '-';
  105. str[7] = (mode & S_IROTH) != 0 ? 'r' : '-';
  106. str[8] = (mode & S_IWOTH) != 0 ? 'w' : '-';
  107. str[9] = (mode & S_IXOTH) != 0 ? 'x' : '-';
  108. setst ((unsigned long) mode, str);
  109. }
  110. /* Return a character indicating the type of file described by
  111. file mode BITS:
  112. 'd' for directories
  113. 'b' for block special files
  114. 'c' for character special files
  115. 'm' for multiplexor files
  116. 'l' for symbolic links
  117. 's' for sockets
  118. 'p' for fifos
  119. '-' for any other file type. */
  120. #ifndef S_ISDIR
  121. #ifdef S_IFDIR
  122. #define S_ISDIR(i) (((i) & S_IFMT) == S_IFDIR)
  123. #else /* ! defined (S_IFDIR) */
  124. #define S_ISDIR(i) (((i) & 0170000) == 040000)
  125. #endif /* ! defined (S_IFDIR) */
  126. #endif /* ! defined (S_ISDIR) */
  127. #ifndef S_ISBLK
  128. #ifdef S_IFBLK
  129. #define S_ISBLK(i) (((i) & S_IFMT) == S_IFBLK)
  130. #else /* ! defined (S_IFBLK) */
  131. #define S_ISBLK(i) 0
  132. #endif /* ! defined (S_IFBLK) */
  133. #endif /* ! defined (S_ISBLK) */
  134. #ifndef S_ISCHR
  135. #ifdef S_IFCHR
  136. #define S_ISCHR(i) (((i) & S_IFMT) == S_IFCHR)
  137. #else /* ! defined (S_IFCHR) */
  138. #define S_ISCHR(i) 0
  139. #endif /* ! defined (S_IFCHR) */
  140. #endif /* ! defined (S_ISCHR) */
  141. #ifndef S_ISFIFO
  142. #ifdef S_IFIFO
  143. #define S_ISFIFO(i) (((i) & S_IFMT) == S_IFIFO)
  144. #else /* ! defined (S_IFIFO) */
  145. #define S_ISFIFO(i) 0
  146. #endif /* ! defined (S_IFIFO) */
  147. #endif /* ! defined (S_ISFIFO) */
  148. #ifndef S_ISSOCK
  149. #ifdef S_IFSOCK
  150. #define S_ISSOCK(i) (((i) & S_IFMT) == S_IFSOCK)
  151. #else /* ! defined (S_IFSOCK) */
  152. #define S_ISSOCK(i) 0
  153. #endif /* ! defined (S_IFSOCK) */
  154. #endif /* ! defined (S_ISSOCK) */
  155. #ifndef S_ISLNK
  156. #ifdef S_IFLNK
  157. #define S_ISLNK(i) (((i) & S_IFMT) == S_IFLNK)
  158. #else /* ! defined (S_IFLNK) */
  159. #define S_ISLNK(i) 0
  160. #endif /* ! defined (S_IFLNK) */
  161. #endif /* ! defined (S_ISLNK) */
  162. static char
  163. ftypelet (bits)
  164. unsigned long bits;
  165. {
  166. if (S_ISDIR (bits))
  167. return 'd';
  168. if (S_ISLNK (bits))
  169. return 'l';
  170. if (S_ISBLK (bits))
  171. return 'b';
  172. if (S_ISCHR (bits))
  173. return 'c';
  174. if (S_ISSOCK (bits))
  175. return 's';
  176. if (S_ISFIFO (bits))
  177. return 'p';
  178. #ifdef S_IFMT
  179. #ifdef S_IFMPC
  180. if ((bits & S_IFMT) == S_IFMPC
  181. || (bits & S_IFMT) == S_IFMPB)
  182. return 'm';
  183. #endif
  184. #ifdef S_IFNWK
  185. if ((bits & S_IFMT) == S_IFNWK)
  186. return 'n';
  187. #endif
  188. #endif
  189. return '-';
  190. }
  191. /* Set the 's' and 't' flags in file attributes string CHARS,
  192. according to the file mode BITS. */
  193. static void
  194. setst (bits, chars)
  195. unsigned long bits;
  196. char *chars;
  197. {
  198. #ifdef S_ISUID
  199. if (bits & S_ISUID)
  200. {
  201. if (chars[3] != 'x')
  202. /* Set-uid, but not executable by owner. */
  203. chars[3] = 'S';
  204. else
  205. chars[3] = 's';
  206. }
  207. #endif
  208. #ifdef S_ISGID
  209. if (bits & S_ISGID)
  210. {
  211. if (chars[6] != 'x')
  212. /* Set-gid, but not executable by group. */
  213. chars[6] = 'S';
  214. else
  215. chars[6] = 's';
  216. }
  217. #endif
  218. #ifdef S_ISVTX
  219. if (bits & S_ISVTX)
  220. {
  221. if (chars[9] != 'x')
  222. /* Sticky, but not executable by others. */
  223. chars[9] = 'T';
  224. else
  225. chars[9] = 't';
  226. }
  227. #endif
  228. }