2 * Copyright (c) 1995 - 2002 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the Institute nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 #include "arla_local.h"
38 * come up with a good inode number for `name', `fid' in `parent'
42 dentry2ino (const char *name
, const VenusFid
*fid
, const FCacheEntry
*parent
)
44 if (strcmp (name
, ".") == 0
45 && (parent
->flags
.vol_root
46 || (fid
->fid
.Vnode
== 1 && fid
->fid
.Unique
== 1))
47 && parent
->volume
!= NULL
) {
49 long voltype
= getvoltype(fid
->fid
.Volume
, parent
->volume
);
50 return afsfid2inode (&parent
->volume
->parent
[voltype
].mp_fid
);
52 } else if (strcmp (name
, "..") == 0
53 && (parent
->flags
.vol_root
54 || (parent
->fid
.fid
.Vnode
== 1
55 && parent
->fid
.fid
.Unique
== 1))
56 && parent
->volume
!= NULL
) {
58 long voltype
= getvoltype(fid
->fid
.Volume
, parent
->volume
);
59 return afsfid2inode (&parent
->volume
->parent
[voltype
].fid
);
61 } else if (strcmp (name
, "..") == 0
62 && fid
->fid
.Vnode
== 1 && fid
->fid
.Unique
== 1
63 && parent
->volume
!= NULL
) {
65 long voltype
= getvoltype(fid
->fid
.Volume
, parent
->volume
);
66 return afsfid2inode (&parent
->volume
->parent
[voltype
].mp_fid
);
69 return afsfid2inode (fid
);
74 * Assume `e' has valid data.
78 conv_dir_sub (FCacheEntry
*e
, CredCacheEntry
*ce
, u_int tokens
,
79 fcache_cache_handle
*cache_handle
,
80 char *cache_name
, size_t cache_name_sz
,
81 fdir_readdir_func func
,
82 void (*flush_func
)(void *),
85 struct write_dirent_args args
;
90 e
->flags
.extradirp
= TRUE
;
91 fcache_extra_file_name (e
, cache_name
, cache_name_sz
);
92 e
->tokens
|= NNPFS_DATA_R
| NNPFS_OPEN_NR
;
94 args
.fd
= open (cache_name
, O_WRONLY
| O_CREAT
| O_TRUNC
| O_BINARY
, 0666);
97 arla_warn (ADEBWARN
, ret
, "open %s", cache_name
);
100 ret
= fcache_fhget (cache_name
, cache_handle
);
103 args
.buf
= (char *)malloc (blocksize
);
104 if (args
.buf
== NULL
) {
106 arla_warn (ADEBWARN
, ret
, "malloc %u", (unsigned)blocksize
);
110 memset(args
.buf
, 0, blocksize
);
112 ret
= fcache_get_fbuf (e
, &fd
, &the_fbuf
,
113 O_RDONLY
, FBUF_READ
|FBUF_PRIVATE
);
125 /* translate to local dir format, write in args.fd */
126 fdir_readdir (&the_fbuf
, func
, (void *)&args
, e
->fid
, NULL
);
128 fbuf_end (&the_fbuf
);
132 (*flush_func
) (&args
);
134 ret
= close (args
.fd
);