stat.c
上传用户:tsgydb
上传日期:2007-04-14
资源大小:10674k
文件大小:3k
源码类别:

MySQL数据库

开发平台:

Visual C++

  1. /* ==== stat.c ============================================================
  2.  * Copyright (c) 1995 by Chris Provenzano, proven@mit.edu
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice, this list of conditions and the following disclaimer in the
  12.  *    documentation and/or other materials provided with the distribution.
  13.  * 3. All advertising materials mentioning features or use of this software
  14.  *    must display the following acknowledgement:
  15.  *  This product includes software developed by Chris Provenzano.
  16.  * 4. The name of Chris Provenzano may not be used to endorse or promote 
  17.  *   products derived from this software without specific prior written
  18.  *   permission.
  19.  *
  20.  * THIS SOFTWARE IS PROVIDED BY CHRIS PROVENZANO ``AS IS'' AND
  21.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  23.  * ARE DISCLAIMED.  IN NO EVENT SHALL CHRIS PROVENZANO BE LIABLE FOR ANY 
  24.  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  25.  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
  26.  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  27.  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
  28.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  29.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
  30.  * SUCH DAMAGE.
  31.  *
  32.  * Description : All the syscalls dealing with fds.
  33.  *
  34.  *  1.00 93/05/27 proven
  35.  *      -Started coding this file.
  36.  */
  37. #ifndef lint
  38. static const char rcsid[] = "$Id$";
  39. #endif
  40. #include <pthread.h>
  41. #include <errno.h>
  42. struct stat;
  43. struct statfs;
  44. /* ==========================================================================
  45.  * fstat()
  46.  *
  47.  * Might want to indirect this.
  48.  */
  49. int fstat(int fd, struct stat *buf)
  50. {
  51. int ret;
  52. if ((ret = fd_lock(fd, FD_READ, NULL)) == OK) {
  53. if ((ret = machdep_sys_fstat(fd_table[fd]->fd.i, buf)) < OK) {
  54. SET_ERRNO(-ret);
  55. ret = NOTOK;
  56. }
  57. fd_unlock(fd, FD_READ);
  58. }
  59. return(ret);
  60. }
  61. /* ==========================================================================
  62.  * stat()
  63.  */
  64. int stat(const char * path, struct stat * buf)
  65. {
  66. int ret;
  67. if ((ret = machdep_sys_stat(path, buf)) < OK) {
  68. SET_ERRNO(-ret);
  69. ret = NOTOK;
  70. }
  71. return(ret);
  72. }
  73. /* ==========================================================================
  74.  * lstat()
  75.  */
  76. int lstat(const char * path, struct stat * buf)
  77. {
  78. int ret;
  79. if ((ret = machdep_sys_lstat(path, buf)) < OK) {
  80. SET_ERRNO(-ret);
  81. ret = NOTOK;
  82. }
  83. return(ret);
  84. }
  85. #ifdef HAVE_SYSCALL_FSTATFS
  86. /* ==========================================================================
  87.  * fstatfs()
  88.  *
  89.  * Might want to indirect this.
  90.  */
  91. int fstatfs(int fd, struct statfs *buf)
  92. {
  93. int ret;
  94. if ((ret = fd_lock(fd, FD_READ, NULL)) == OK) {
  95. if ((ret = machdep_sys_fstatfs(fd_table[fd]->fd.i, buf)) < OK) {
  96. SET_ERRNO(-ret);
  97. ret = NOTOK;
  98. }
  99. fd_unlock(fd, FD_READ);
  100. }
  101. return(ret);
  102. }
  103. #endif