forked from fuse4x/kext
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fuse_internal.h
896 lines (732 loc) · 22.7 KB
/
fuse_internal.h
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
/*
* 'rebel' branch modifications:
* Copyright (C) 2010 Tuxera. All Rights Reserved.
*/
/*
* Copyright (C) 2006-2008 Google. All Rights Reserved.
* Amit Singh <singh@>
*/
#ifndef _FUSE_INTERNAL_H_
#define _FUSE_INTERNAL_H_
#include <kern/clock.h>
#include <sys/types.h>
#include <sys/kauth.h>
#include <sys/kernel_types.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/ubc.h>
#include <sys/uio.h>
#include <sys/vnode.h>
#include <sys/xattr.h>
#include <stdbool.h>
#include <AvailabilityMacros.h>
#include "fuse_ipc.h"
#include "fuse_kludges.h"
#include "fuse_locking.h"
#include "fuse_node.h"
#include "fuse_kernel.h"
struct fuse_attr;
struct fuse_data;
struct fuse_dispatcher;
struct fuse_filehandle;
struct fuse_iov;
struct fuse_ticket;
/* time */
#define fuse_timespec_add(vvp, uvp) \
do { \
(vvp)->tv_sec += (uvp)->tv_sec; \
(vvp)->tv_nsec += (uvp)->tv_nsec; \
if ((vvp)->tv_nsec >= 1000000000) { \
(vvp)->tv_sec++; \
(vvp)->tv_nsec -= 1000000000; \
} \
} while (0)
#define fuse_timespec_cmp(tvp, uvp, cmp) \
(((tvp)->tv_sec == (uvp)->tv_sec) ? \
((tvp)->tv_nsec cmp (uvp)->tv_nsec) : \
((tvp)->tv_sec cmp (uvp)->tv_sec))
/* miscellaneous */
#if M_FUSE4X_ENABLE_UNSUPPORTED
extern const char *vnode_getname(vnode_t vp);
extern void vnode_putname(const char *name);
#endif /* M_FUSE4X_ENABLE_UNSUPPORTED */
static __inline__
int
fuse_match_cred(kauth_cred_t daemoncred, kauth_cred_t requestcred)
{
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
posix_cred_t daemonpcred = &(daemoncred->cr_posix);
posix_cred_t requestpcred = &(requestcred->cr_posix);
#else
kauth_cred_t daemonpcred = daemoncred;
kauth_cred_t requestpcred = requestcred;
#endif
if ((daemonpcred->cr_uid == requestpcred->cr_uid) &&
(daemonpcred->cr_groups[0] == requestpcred->cr_groups[0])) {
// macfuse/fuse4x used to check following conditions as well.
// but on Lion appeared a new service used for drag'n'drop (Locum?)
// that works on behalf of user but has "real user" equals to root
// (ruid==cr_rgid==0), if we reject Locum then drag'n'drop does not work in Finder.
// (daemonpcred->cr_uid == requestpcred->cr_ruid) &&
// (daemonpcred->cr_groups[0] == requestpcred->cr_rgid) &&
// (daemonpcred->cr_groups[0] == requestpcred->cr_svgid)
return 0;
}
return EPERM;
}
static __inline__
int
fuse_vfs_context_issuser(vfs_context_t context)
{
return (kauth_cred_getuid(vfs_context_ucred(context)) == 0);
}
static __inline__
int
fuse_isautocache_mp(mount_t mp)
{
return (fuse_get_mpdata(mp)->dataflags & FSESS_AUTO_CACHE);
}
static __inline__
bool
fuse_isdeadfs_mp(mount_t mp)
{
return fdata_dead_get(fuse_get_mpdata(mp));
}
static __inline__
bool
fuse_isdeadfs(vnode_t vp)
{
if (VTOFUD(vp)->flag & FN_REVOKED) {
return true;
}
return fuse_isdeadfs_mp(vnode_mount(vp));
}
static __inline__
bool
fuse_isdeadfs_fs(vnode_t vp)
{
return fuse_isdeadfs_mp(vnode_mount(vp));
}
static __inline__
int
fuse_isdirectio(vnode_t vp)
{
/* Try global first. */
if (fuse_get_mpdata(vnode_mount(vp))->dataflags & FSESS_DIRECT_IO) {
return 1;
}
return (VTOFUD(vp)->flag & FN_DIRECT_IO);
}
static __inline__
int
fuse_isdirectio_mp(mount_t mp)
{
return (fuse_get_mpdata(mp)->dataflags & FSESS_DIRECT_IO);
}
static __inline__
int
fuse_isnoattrcache(vnode_t vp)
{
/* Try global first. */
if (fuse_get_mpdata(vnode_mount(vp))->dataflags & FSESS_NO_ATTRCACHE) {
return 1;
}
return 0;
}
static __inline__
int
fuse_isnoattrcache_mp(mount_t mp)
{
return (fuse_get_mpdata(mp)->dataflags & FSESS_NO_ATTRCACHE);
}
static __inline__
int
fuse_isnoreadahead(vnode_t vp)
{
/* Try global first. */
if (fuse_get_mpdata(vnode_mount(vp))->dataflags & FSESS_NO_READAHEAD) {
return 1;
}
/* In our model, direct_io implies no readahead. */
return fuse_isdirectio(vp);
}
static __inline__
int
fuse_isnosynconclose(vnode_t vp)
{
if (fuse_isdirectio(vp)) {
return 0;
}
return (fuse_get_mpdata(vnode_mount(vp))->dataflags & FSESS_NO_SYNCONCLOSE);
}
static __inline__
int
fuse_isnosyncwrites_mp(mount_t mp)
{
/* direct_io implies we won't have nosyncwrites. */
if (fuse_isdirectio_mp(mp)) {
return 0;
}
return (fuse_get_mpdata(mp)->dataflags & FSESS_NO_SYNCWRITES);
}
static __inline__
void
fuse_setnosyncwrites_mp(mount_t mp)
{
vfs_clearflags(mp, MNT_SYNCHRONOUS);
vfs_setflags(mp, MNT_ASYNC);
fuse_get_mpdata(mp)->dataflags |= FSESS_NO_SYNCWRITES;
}
static __inline__
void
fuse_clearnosyncwrites_mp(mount_t mp)
{
if (!vfs_issynchronous(mp)) {
vfs_clearflags(mp, MNT_ASYNC);
vfs_setflags(mp, MNT_SYNCHRONOUS);
fuse_get_mpdata(mp)->dataflags &= ~FSESS_NO_SYNCWRITES;
}
}
static __inline__
int
fuse_isnoubc(vnode_t vp)
{
/* Try global first. */
if (fuse_get_mpdata(vnode_mount(vp))->dataflags & FSESS_NO_UBC) {
return 1;
}
/* In our model, direct_io implies no UBC. */
return fuse_isdirectio(vp);
}
static __inline__
int
fuse_isnoubc_mp(mount_t mp)
{
return (fuse_get_mpdata(mp)->dataflags & FSESS_NO_UBC);
}
static __inline__
int
fuse_isnegativevncache_mp(mount_t mp)
{
return (fuse_get_mpdata(mp)->dataflags & FSESS_NEGATIVE_VNCACHE);
}
static __inline__
int
fuse_isnovncache(vnode_t vp)
{
/* Try global first. */
if (fuse_get_mpdata(vnode_mount(vp))->dataflags & FSESS_NO_VNCACHE) {
return 1;
}
/* In our model, direct_io implies no vncache for this vnode. */
return fuse_isdirectio(vp);
}
static __inline__
int
fuse_isnovncache_mp(mount_t mp)
{
return (fuse_get_mpdata(mp)->dataflags & FSESS_NO_VNCACHE);
}
static __inline__
int
fuse_isextendedsecurity(vnode_t vp)
{
return (fuse_get_mpdata(vnode_mount(vp))->dataflags & \
FSESS_EXTENDED_SECURITY);
}
static __inline__
int
fuse_isextendedsecurity_mp(mount_t mp)
{
return (fuse_get_mpdata(mp)->dataflags & FSESS_EXTENDED_SECURITY);
}
static __inline__
int
fuse_isdefaultpermissions(vnode_t vp)
{
return (fuse_get_mpdata(vnode_mount(vp))->dataflags & \
FSESS_DEFAULT_PERMISSIONS);
}
static __inline__
int
fuse_isdefaultpermissions_mp(mount_t mp)
{
return (fuse_get_mpdata(mp)->dataflags & FSESS_DEFAULT_PERMISSIONS);
}
static __inline__
int
fuse_isdeferpermissions(vnode_t vp)
{
return (fuse_get_mpdata(vnode_mount(vp))->dataflags & \
FSESS_DEFER_PERMISSIONS);
}
static __inline__
int
fuse_isdeferpermissions_mp(mount_t mp)
{
return (fuse_get_mpdata(mp)->dataflags & FSESS_DEFER_PERMISSIONS);
}
static __inline__
int
fuse_isxtimes(vnode_t vp)
{
return (fuse_get_mpdata(vnode_mount(vp))->dataflags & FSESS_XTIMES);
}
static __inline__
int
fuse_isxtimes_mp(mount_t mp)
{
return (fuse_get_mpdata(mp)->dataflags & FSESS_XTIMES);
}
static __inline__
int
fuse_issparse_mp(mount_t mp)
{
return (fuse_get_mpdata(mp)->dataflags & FSESS_SPARSE);
}
static __inline__
uint32_t
fuse_round_powerof2(uint32_t size)
{
uint32_t result = 512;
size = size & 0x7FFFFFFFU; /* clip at 2G */
while (result < size) {
result <<= 1;
}
return result;
}
static __inline__
uint32_t
fuse_round_size(uint32_t size, uint32_t b_min, uint32_t b_max)
{
uint32_t candidate = fuse_round_powerof2(size);
/* We assume that b_min and b_max will already be powers of 2. */
if (candidate < b_min) {
candidate = b_min;
}
if (candidate > b_max) {
candidate = b_max;
}
return candidate;
}
static __inline__
int
fuse_skip_apple_double_mp(mount_t mp, char *nameptr, long namelen)
{
#define DS_STORE ".DS_Store"
int ismpoption = fuse_get_mpdata(mp)->dataflags & FSESS_NO_APPLEDOUBLE;
if (ismpoption && nameptr) {
/* This _will_ allow just "._", that is, a namelen of 2. */
if (namelen > 2) {
if ((namelen == ((sizeof(DS_STORE)/sizeof(char)) - 1)) &&
(bcmp(nameptr, DS_STORE, sizeof(DS_STORE)) == 0)) {
return 1;
} else if (nameptr[0] == '.' && nameptr[1] == '_') {
return 1;
}
}
}
#undef DS_STORE
return 0;
}
static __inline__
int
fuse_blanket_deny(vnode_t vp, vfs_context_t context)
{
mount_t mp = vnode_mount(vp);
struct fuse_data *data = fuse_get_mpdata(mp);
int issuser = fuse_vfs_context_issuser(context);
int isvroot = vnode_isvroot(vp);
/* if allow_other is set */
if (data->dataflags & FSESS_ALLOW_OTHER) {
return 0;
}
/* if allow_root is set */
if (issuser && (data->dataflags & FSESS_ALLOW_ROOT)) {
return 0;
}
/* if this is the user who mounted the fs */
if (fuse_match_cred(data->daemoncred, vfs_context_ucred(context)) == 0) {
return 0;
}
if (!(data->dataflags & FSESS_INITED) && isvroot && issuser) {
return 0;
}
if (fuse_isdeadfs(vp) && isvroot) {
return 0;
}
/* If kernel itself, allow. */
if (vfs_context_pid(context) == 0) {
return 0;
}
return 1;
}
#define CHECK_BLANKET_DENIAL(vp, context, err) \
{ \
if (fuse_blanket_deny(vp, context)) { \
return err; \
} \
}
/* access */
/* FN_ACCESS_NOOP is in fuse_node.h */
#define FACCESS_VA_VALID 0x00000001
#define FACCESS_DO_ACCESS 0x00000002
#define FACCESS_NOCHECKSPY 0x00000004
#define FACCESS_FROM_VNOP 0x00000008
struct fuse_access_param {
uid_t xuid;
gid_t xgid;
uint32_t facc_flags;
};
int
fuse_internal_access(vnode_t vp,
int action,
vfs_context_t context,
struct fuse_access_param *facp);
/* attributes */
int
fuse_internal_loadxtimes(vnode_t vp, struct vnode_attr *out_vap,
vfs_context_t context);
int
fuse_internal_attr_vat2fsai(mount_t mp,
vnode_t vp,
struct vnode_attr *vap,
struct fuse_setattr_in *fsai,
uint64_t *newsize);
static __inline__
void
fuse_internal_attr_fat2vat(vnode_t vp,
struct fuse_attr *fat,
struct vnode_attr *vap)
{
struct timespec t;
mount_t mp = vnode_mount(vp);
struct fuse_data *data = fuse_get_mpdata(mp);
struct fuse_vnode_data *fvdat = VTOFUD(vp);
VATTR_INIT(vap);
VATTR_RETURN(vap, va_fsid, vfs_statfs(mp)->f_fsid.val[0]);
VATTR_RETURN(vap, va_fileid, fat->ino);
VATTR_RETURN(vap, va_linkid, fat->ino);
/*
* If we have asynchronous writes enabled, our local in-kernel size
* takes precedence over what the daemon thinks.
*/
/* ATTR_FUDGE_CASE */
if (!vfs_issynchronous(mp)) {
fat->size = fvdat->filesize;
}
VATTR_RETURN(vap, va_data_size, fat->size);
/*
* The kernel will compute the following for us if we leave them
* untouched (and have sane values in statvfs):
*
* va_total_size
* va_data_alloc
* va_total_alloc
*/
if (fuse_issparse_mp(mp)) {
VATTR_RETURN(vap, va_data_alloc, fat->blocks);
}
t.tv_sec = (typeof(t.tv_sec))fat->atime; /* XXX: truncation */
t.tv_nsec = fat->atimensec;
VATTR_RETURN(vap, va_access_time, t);
t.tv_sec = (typeof(t.tv_sec))fat->ctime; /* XXX: truncation */
t.tv_nsec = fat->ctimensec;
VATTR_RETURN(vap, va_change_time, t);
t.tv_sec = (typeof(t.tv_sec))fat->mtime; /* XXX: truncation */
t.tv_nsec = fat->mtimensec;
VATTR_RETURN(vap, va_modify_time, t);
t.tv_sec = (typeof(t.tv_sec))fat->crtime; /* XXX: truncation */
t.tv_nsec = fat->crtimensec;
VATTR_RETURN(vap, va_create_time, t);
VATTR_RETURN(vap, va_mode, fat->mode & ~S_IFMT);
VATTR_RETURN(vap, va_nlink, fat->nlink);
VATTR_RETURN(vap, va_uid, fat->uid);
VATTR_RETURN(vap, va_gid, fat->gid);
VATTR_RETURN(vap, va_rdev, fat->rdev);
/*
* If the file in question has ACLs, we record that knowledge here:
*
* VTOFUD(vp)->flag |= FN_HAS_ACL;
*/
VATTR_RETURN(vap, va_type, IFTOVT(fat->mode));
VATTR_RETURN(vap, va_iosize, data->iosize);
VATTR_RETURN(vap, va_flags, fat->flags);
}
static __inline__
void
fuse_internal_attr_loadvap(vnode_t vp, struct vnode_attr *out_vap,
vfs_context_t context)
{
mount_t mp = vnode_mount(vp);
struct vnode_attr *in_vap = VTOVA(vp);
struct fuse_vnode_data *fvdat = VTOFUD(vp);
int purged = 0;
long hint = 0;
if (in_vap == out_vap) {
return;
}
VATTR_RETURN(out_vap, va_fsid, in_vap->va_fsid);
VATTR_RETURN(out_vap, va_fileid, in_vap->va_fileid);
VATTR_RETURN(out_vap, va_linkid, in_vap->va_linkid);
VATTR_RETURN(out_vap, va_gen,
(typeof(out_vap->va_gen))fvdat->generation); /* XXX: truncation */
if (!vnode_isvroot(vp)) {
/*
* If we do return va_parentid for our root vnode, things get
* a bit too interesting for the Finder.
*/
VATTR_RETURN(out_vap, va_parentid, fvdat->parent_nodeid);
}
/*
* If we have asynchronous writes enabled, our local in-kernel size
* takes precedence over what the daemon thinks.
*/
/* ATTR_FUDGE_CASE */
if (!vfs_issynchronous(mp)) {
/* Bring in_vap up to date if need be. */
VATTR_RETURN(in_vap, va_data_size, fvdat->filesize);
} else {
/* The size might have changed remotely. */
if (fvdat->filesize != (off_t)in_vap->va_data_size) {
hint |= NOTE_WRITE;
/* Remote size overrides what we have. */
(void)ubc_msync(vp, (off_t)0, fvdat->filesize, (off_t*)0,
UBC_PUSHALL | UBC_INVALIDATE | UBC_SYNC);
purged = 1;
if (fvdat->filesize > (off_t)in_vap->va_data_size) {
hint |= NOTE_EXTEND;
}
fvdat->filesize = in_vap->va_data_size;
ubc_setsize(vp, fvdat->filesize);
}
}
VATTR_RETURN(out_vap, va_data_size, in_vap->va_data_size);
if (fuse_issparse_mp(mp)) {
VATTR_RETURN(out_vap, va_data_alloc, in_vap->va_data_alloc);
}
VATTR_RETURN(out_vap, va_mode, in_vap->va_mode);
VATTR_RETURN(out_vap, va_nlink, in_vap->va_nlink);
VATTR_RETURN(out_vap, va_uid, in_vap->va_uid);
VATTR_RETURN(out_vap, va_gid, in_vap->va_gid);
VATTR_RETURN(out_vap, va_rdev, in_vap->va_rdev);
VATTR_RETURN(out_vap, va_type, in_vap->va_type);
VATTR_RETURN(out_vap, va_iosize, in_vap->va_iosize);
VATTR_RETURN(out_vap, va_flags, in_vap->va_flags);
VATTR_RETURN(out_vap, va_access_time, in_vap->va_access_time);
VATTR_RETURN(out_vap, va_change_time, in_vap->va_change_time);
VATTR_RETURN(out_vap, va_modify_time, in_vap->va_modify_time);
/*
* When __DARWIN_64_BIT_INO_T is not enabled, the User library
* will set va_create_time to -1. In that case, we will have
* to ask for it separately, if necessary.
*/
if (in_vap->va_create_time.tv_sec != (int64_t)-1) {
VATTR_RETURN(out_vap, va_create_time, in_vap->va_create_time);
}
if ((fvdat->modify_time.tv_sec != in_vap->va_modify_time.tv_sec) ||
(fvdat->modify_time.tv_nsec != in_vap->va_modify_time.tv_nsec)) {
fvdat->modify_time.tv_sec = in_vap->va_modify_time.tv_sec;
fvdat->modify_time.tv_nsec = in_vap->va_modify_time.tv_nsec;
hint |= NOTE_ATTRIB;
if (fuse_isautocache_mp(mp) && !purged) {
(void)ubc_msync(vp, (off_t)0, fvdat->filesize, (off_t*)0,
UBC_PUSHALL | UBC_INVALIDATE | UBC_SYNC);
}
}
if (VATTR_IS_ACTIVE(out_vap, va_backup_time) ||
(VATTR_IS_ACTIVE(out_vap, va_create_time) &&
!VATTR_IS_SUPPORTED(out_vap, va_create_time))) {
(void)fuse_internal_loadxtimes(vp, out_vap, context);
}
if (hint) {
FUSE_KNOTE(vp, hint);
}
}
#define cache_attrs(vp, fuse_out) do { \
struct timespec uptsp_ ## __func__; \
\
/* XXX: truncation; user space sends us a 64-bit tv_sec */ \
VTOFUD(vp)->attr_valid.tv_sec = (time_t)(fuse_out)->attr_valid; \
VTOFUD(vp)->attr_valid.tv_nsec = (fuse_out)->attr_valid_nsec; \
nanouptime(&uptsp_ ## __func__); \
\
fuse_timespec_add(&VTOFUD(vp)->attr_valid, &uptsp_ ## __func__); \
\
fuse_internal_attr_fat2vat(vp, &(fuse_out)->attr, VTOVA(vp)); \
} while (0)
#if M_FUSE4X_ENABLE_EXCHANGE
/* exchange */
int
fuse_internal_exchange(vnode_t fvp,
const char *fname,
size_t flen,
vnode_t tvp,
const char *tname,
size_t tlen,
int options,
vfs_context_t context);
#endif /* M_FUSE4X_ENABLE_EXCHANGE */
/* fsync */
int
fuse_internal_fsync(vnode_t vp,
vfs_context_t context,
struct fuse_filehandle *fufh,
void *param);
int
fuse_internal_fsync_callback(struct fuse_ticket *ftick, uio_t uio);
/* readdir */
struct pseudo_dirent {
uint32_t d_namlen;
};
int
fuse_internal_readdir(vnode_t vp,
uio_t uio,
vfs_context_t context,
struct fuse_filehandle *fufh,
struct fuse_iov *cookediov,
int *numdirent);
int
fuse_internal_readdir_processdata(vnode_t vp,
uio_t uio,
size_t reqsize,
void *buf,
size_t bufsize,
struct fuse_iov *cookediov,
int *numdirent);
/* remove */
int
fuse_internal_remove(vnode_t dvp,
vnode_t vp,
struct componentname *cnp,
enum fuse_opcode op,
vfs_context_t context);
/* rename */
int
fuse_internal_rename(vnode_t fdvp,
vnode_t fvp,
struct componentname *fcnp,
vnode_t tdvp,
vnode_t tvp,
struct componentname *tcnp,
vfs_context_t context);
/* revoke */
int
fuse_internal_revoke(vnode_t vp, int flags, vfs_context_t context, int how);
void
fuse_internal_vnode_disappear(vnode_t vp, vfs_context_t context, int how);
/* strategy */
int
fuse_internal_strategy(vnode_t vp, buf_t bp);
errno_t
fuse_internal_strategy_buf(struct vnop_strategy_args *ap);
/* xattr */
static __inline__
int
fuse_skip_apple_xattr_mp(mount_t mp, const char *name)
{
int ismpoption = fuse_get_mpdata(mp)->dataflags & FSESS_NO_APPLEXATTR;
if (ismpoption && name) {
#define COM_APPLE_ "com.apple."
if (bcmp(name, COM_APPLE_, sizeof(COM_APPLE_) - 1) == 0) {
return 1;
}
}
return 0;
}
/* entity creation */
static __inline__
int
fuse_internal_checkentry(struct fuse_entry_out *feo, enum vtype vtype)
{
if (vtype != IFTOVT(feo->attr.mode)) {
return EINVAL;
}
if (feo->nodeid == FUSE_NULL_ID) {
return EINVAL;
}
if (feo->nodeid == FUSE_ROOT_ID) {
return EINVAL;
}
return 0;
}
int
fuse_internal_newentry(vnode_t dvp,
vnode_t *vpp,
struct componentname *cnp,
enum fuse_opcode op,
void *buf,
size_t bufsize,
enum vtype vtype,
vfs_context_t context);
void
fuse_internal_newentry_makerequest(mount_t mp,
uint64_t dnid,
struct componentname *cnp,
enum fuse_opcode op,
void *buf,
size_t bufsize,
struct fuse_dispatcher *fdip,
vfs_context_t context);
int
fuse_internal_newentry_core(vnode_t dvp,
vnode_t *vpp,
struct componentname *cnp,
enum vtype vtyp,
struct fuse_dispatcher *fdip,
vfs_context_t context);
/* entity destruction */
int
fuse_internal_forget_callback(struct fuse_ticket *ftick, uio_t uio);
void
fuse_internal_forget_send(mount_t mp,
vfs_context_t context,
uint64_t nodeid,
uint64_t nlookup,
struct fuse_dispatcher *fdip);
void
fuse_internal_interrupt_send(struct fuse_ticket *ftick);
enum {
REVOKE_NONE = 0,
REVOKE_SOFT = 1,
REVOKE_HARD = 2,
};
/* fuse start/stop */
int fuse_internal_init_handler(struct fuse_ticket *ftick, uio_t uio);
int fuse_send_init(struct fuse_data *data, vfs_context_t context);
/* other */
static __inline__
int
fuse_implemented(struct fuse_data *data, uint64_t which)
{
int result;
/* FUSE_DATA_LOCK_SHARED(data); */
result = (int)!(data->noimplflags & which);
/* FUSE_DATA_UNLOCK_SHARED(data); */
return result;
}
static __inline__
void
fuse_clear_implemented(struct fuse_data *data, uint64_t which)
{
/* FUSE_DATA_LOCK_EXCLUSIVE(data); */
data->noimplflags |= which;
/* FUSE_DATA_UNLOCK_EXCLUSIVE(data); */
}
static __inline__
int
fuse_set_implemented_custom(struct fuse_data *data, uint64_t flags)
{
if (!data) {
return EINVAL;
}
FUSE_DATA_LOCK_EXCLUSIVE(data);
data->noimplflags = flags;
FUSE_DATA_UNLOCK_EXCLUSIVE(data);
return 0;
}
void
fuse_internal_print_vnodes(mount_t mp);
void
fuse_preflight_log(vnode_t vp, fufh_type_t fufh_type, int err, char *message);
#endif /* _FUSE_INTERNAL_H_ */