File: closedir.c

package info (click to toggle)
lfc-postgres 1.7.4.7-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 13,676 kB
  • ctags: 10,779
  • sloc: ansic: 146,136; sh: 13,176; perl: 11,142; python: 5,529; cpp: 5,113; sql: 1,790; makefile: 861; fortran: 113
file content (110 lines) | stat: -rw-r--r-- 2,898 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
 * $Id: closedir.c,v 1.1 2005/03/31 13:13:00 baud Exp $
 */

/*
 * Copyright (C) 1990-2002 by CERN/IT/PDP/DM
 * All rights reserved
 */

#ifndef lint
static char sccsid[] = "@(#)$RCSfile: closedir.c,v $ $Revision: 1.1 $ $Date: 2005/03/31 13:13:00 $ CERN/IT/PDP/DM Olof Barring";
#endif /* not lint */

/* closedir.c      Remote File I/O - close a directory                     */

#define RFIO_KERNEL     1 
#include "rfio.h"        
#include "rfio_rdirfdt.h"

/*
 * remote directory close
 */

int DLL_DECL rfio_closedir(dirp)
RDIR *dirp;
{
   char     rfio_buf[BUFSIZ];
   WORD    req ; 
   LONG  rcode ;
   LONG msgsiz ;
   int s;
   int status;
   char *p;
   extern RDIR *rdirfdt[MAXRFD];
   int s_index;

   /*
    * Search internal table for this directory pointer
    */
   s_index = rfio_rdirfdt_findptr(dirp,FINDRDIR_WITH_SCAN);

   INIT_TRACE("RFIO_TRACE");
   TRACE(1, "rfio", "rfio_closedir(0x%x)", dirp);

   /*
    * The directory is local
    */
   if (s_index == -1) {
      TRACE(2, "rfio", "rfio_closedir: check if HSM directory");
      if ( rfio_HsmIf_IsHsmDirEntry((DIR *)dirp) != -1 ) {
          status = rfio_HsmIf_closedir((DIR *)dirp);
      } else {
          TRACE(2, "rfio", "rfio_closedir: using local closedir(0x%x)",dirp) ; 
#if defined(_WIN32)
          status = -1;
          serrno = SEOPNOTSUP;
#else /* _WIN32 */
          status= closedir((DIR *)dirp) ; 
          if ( status < 0 ) serrno = 0;
#endif /* _WIN32 */
      }
      END_TRACE() ; 
      return status ;
   }
   /*
    * Checking magic number
    */
   s = rdirfdt[s_index]->s;
   if ( rdirfdt[s_index]->magic != RFIO_MAGIC ) {
      serrno = SEBADVERSION ;
      rfio_rdirfdt_freeentry(s_index);
      (void) close(s) ;
      END_TRACE();
      return(-1);
   }
   /*
    * Sending request.
    */
   p= rfio_buf ;
   marshall_WORD(p, RFIO_MAGIC);
   marshall_WORD(p, RQST_CLOSEDIR);
   TRACE(2, "rfio", "rfio_closedir: sending %d bytes",RQSTSIZE) ;
   if (netwrite_timeout(s, rfio_buf,RQSTSIZE,RFIO_CTRL_TIMEOUT) != RQSTSIZE) {
      TRACE(2, "rfio", "rfio_closedir: write(): ERROR occured (errno=%d)", errno);
      (void) rfio_dircleanup(s) ;
      END_TRACE() ;
      return -1 ;
   }
   /*
    * Getting data from the network.
    */

   TRACE(2, "rfio", "rfio_closedir: reading %d bytes",WORDSIZE+3*LONGSIZE) ; 
   if (netread_timeout(s,rfio_buf,WORDSIZE+3*LONGSIZE,RFIO_CTRL_TIMEOUT) != (WORDSIZE+3*LONGSIZE)) {
      TRACE(2, "rfio", "rfio_closedir: read(): ERROR occured (errno=%d)", errno);
      (void)rfio_dircleanup(s) ; 
      END_TRACE() ;
      return -1 ; 
   }
   p = rfio_buf ;
   unmarshall_WORD(p,req) ;
   unmarshall_LONG(p,status) ;
   unmarshall_LONG(p, rcode) ;
   unmarshall_LONG(p,msgsiz) ;
   rfio_errno = rcode ;
   (void) rfio_dircleanup(s) ; 
   TRACE(1, "rfio", "rfio_closedir: return status=%d, rcode=%d",status,rcode) ;
   END_TRACE() ; 
   return status ;
}