fuse_internal.h (18b18078f267ba10cf14348bc333f2f81818f472) fuse_internal.h (7e4844f7d9546ba65202fbe834d1c06aa72a37b8)
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 2007-2009 Google Inc. and Amit Singh
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are

--- 179 unchanged lines hidden (view full) ---

188
189 return (EPERM);
190}
191
192int fuse_internal_access(struct vnode *vp, mode_t mode,
193 struct fuse_access_param *facp, struct thread *td, struct ucred *cred);
194
195/* attributes */
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 2007-2009 Google Inc. and Amit Singh
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are

--- 179 unchanged lines hidden (view full) ---

188
189 return (EPERM);
190}
191
192int fuse_internal_access(struct vnode *vp, mode_t mode,
193 struct fuse_access_param *facp, struct thread *td, struct ucred *cred);
194
195/* attributes */
196void fuse_internal_cache_attrs(struct vnode *vp, struct fuse_attr *attr,
197 uint64_t attr_valid, uint32_t attr_valid_nsec, struct vattr *vap);
196
198
197/*
198 * Cache FUSE attributes 'fat', with nominal expiration
199 * 'attr_valid'.'attr_valid_nsec', in attr cache associated with vnode 'vp'.
200 * Optionally, if argument 'vap' is not NULL, store a copy of the converted
201 * attributes there as well.
202 *
203 * If the nominal attribute cache TTL is zero, do not cache on the 'vp' (but do
204 * return the result to the caller).
205 */
206static inline void
207fuse_internal_attr_fat2vat(struct vnode *vp, struct fuse_attr *fat,
208 uint64_t attr_valid, uint32_t attr_valid_nsec, struct vattr *vap)
209{
210 struct mount *mp;
211 struct fuse_vnode_data *fvdat;
212 struct vattr *vp_cache_at;
213
214 mp = vnode_mount(vp);
215 fvdat = VTOFUD(vp);
216
217 DEBUGX(FUSE_DEBUG_INTERNAL, "node #%ju, mode 0%o\n",
218 (uintmax_t)fat->ino, fat->mode);
219
220 /* Honor explicit do-not-cache requests from user filesystems. */
221 if (attr_valid == 0 && attr_valid_nsec == 0)
222 fvdat->valid_attr_cache = false;
223 else
224 fvdat->valid_attr_cache = true;
225
226 vp_cache_at = VTOVA(vp);
227
228 if (vap == NULL && vp_cache_at == NULL)
229 return;
230
231 if (vap == NULL)
232 vap = vp_cache_at;
233
234 vattr_null(vap);
235
236 vap->va_fsid = mp->mnt_stat.f_fsid.val[0];
237 vap->va_fileid = fat->ino;
238 vap->va_mode = fat->mode & ~S_IFMT;
239 vap->va_nlink = fat->nlink;
240 vap->va_uid = fat->uid;
241 vap->va_gid = fat->gid;
242 vap->va_rdev = fat->rdev;
243 vap->va_size = fat->size;
244 /* XXX on i386, seconds are truncated to 32 bits */
245 vap->va_atime.tv_sec = fat->atime;
246 vap->va_atime.tv_nsec = fat->atimensec;
247 vap->va_mtime.tv_sec = fat->mtime;
248 vap->va_mtime.tv_nsec = fat->mtimensec;
249 vap->va_ctime.tv_sec = fat->ctime;
250 vap->va_ctime.tv_nsec = fat->ctimensec;
251 vap->va_blocksize = PAGE_SIZE;
252 vap->va_type = IFTOVT(fat->mode);
253 vap->va_bytes = fat->blocks * S_BLKSIZE;
254 vap->va_flags = 0;
255
256 if (vap != vp_cache_at && vp_cache_at != NULL)
257 memcpy(vp_cache_at, vap, sizeof(*vap));
258}
259
260
261#define cache_attrs(vp, fuse_out, vap_out) \
262 fuse_internal_attr_fat2vat((vp), &(fuse_out)->attr, \
263 (fuse_out)->attr_valid, (fuse_out)->attr_valid_nsec, (vap_out))
264
265/* fsync */
266
267int fuse_internal_fsync(struct vnode *vp, struct thread *td,
268 struct ucred *cred, struct fuse_filehandle *fufh);
269int fuse_internal_fsync_callback(struct fuse_ticket *tick, struct uio *uio);
270
271/* readdir */
272

--- 22 unchanged lines hidden (view full) ---

295
296/* strategy */
297
298/* entity creation */
299
300static inline int
301fuse_internal_checkentry(struct fuse_entry_out *feo, enum vtype vtyp)
302{
199/* fsync */
200
201int fuse_internal_fsync(struct vnode *vp, struct thread *td,
202 struct ucred *cred, struct fuse_filehandle *fufh);
203int fuse_internal_fsync_callback(struct fuse_ticket *tick, struct uio *uio);
204
205/* readdir */
206

--- 22 unchanged lines hidden (view full) ---

229
230/* strategy */
231
232/* entity creation */
233
234static inline int
235fuse_internal_checkentry(struct fuse_entry_out *feo, enum vtype vtyp)
236{
303 DEBUGX(FUSE_DEBUG_INTERNAL,
304 "feo=%p, vtype=%d\n", feo, vtyp);
305
306 if (vtyp != IFTOVT(feo->attr.mode)) {
237 if (vtyp != IFTOVT(feo->attr.mode)) {
307 DEBUGX(FUSE_DEBUG_INTERNAL,
308 "EINVAL -- %x != %x\n", vtyp, IFTOVT(feo->attr.mode));
309 return (EINVAL);
310 }
311
312 if (feo->nodeid == FUSE_NULL_ID) {
238 return (EINVAL);
239 }
240
241 if (feo->nodeid == FUSE_NULL_ID) {
313 DEBUGX(FUSE_DEBUG_INTERNAL,
314 "EINVAL -- feo->nodeid is NULL\n");
315 return (EINVAL);
316 }
317
318 if (feo->nodeid == FUSE_ROOT_ID) {
242 return (EINVAL);
243 }
244
245 if (feo->nodeid == FUSE_ROOT_ID) {
319 DEBUGX(FUSE_DEBUG_INTERNAL,
320 "EINVAL -- feo->nodeid is FUSE_ROOT_ID\n");
321 return (EINVAL);
322 }
323
324 return (0);
325}
326
327int fuse_internal_newentry(struct vnode *dvp, struct vnode **vpp,
328 struct componentname *cnp, enum fuse_opcode op, void *buf, size_t bufsize,

--- 21 unchanged lines hidden ---
246 return (EINVAL);
247 }
248
249 return (0);
250}
251
252int fuse_internal_newentry(struct vnode *dvp, struct vnode **vpp,
253 struct componentname *cnp, enum fuse_opcode op, void *buf, size_t bufsize,

--- 21 unchanged lines hidden ---