Skip to content

Commit bb30ac4

Browse files
committed
fusefs: Upgrade FUSE protocol to version 7.36.
This commit upgrades the FUSE API to protocol 7.36, it doesn't implement any of protocol 7.36's new features
1 parent a837d1f commit bb30ac4

File tree

3 files changed

+55
-6
lines changed

3 files changed

+55
-6
lines changed

sys/fs/fuse/fuse_internal.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,8 @@ fuse_internal_send_init(struct fuse_data *data, struct thread *td)
11181118
fiii->flags = FUSE_ASYNC_READ | FUSE_POSIX_LOCKS | FUSE_EXPORT_SUPPORT
11191119
| FUSE_BIG_WRITES | FUSE_WRITEBACK_CACHE
11201120
| FUSE_NO_OPEN_SUPPORT | FUSE_NO_OPENDIR_SUPPORT
1121-
| FUSE_SETXATTR_EXT;
1121+
| FUSE_SETXATTR_EXT | FUSE_INIT_EXT;
1122+
fiii->flags2 = 0;
11221123

11231124
fuse_insert_callback(fdi.tick, fuse_internal_init_callback);
11241125
fuse_insert_message(fdi.tick, false);

sys/fs/fuse/fuse_kernel.h

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,13 @@
188188
*
189189
* 7.35
190190
* - add FOPEN_NOFLUSH
191+
*
192+
* 7.36
193+
* - extend fuse_init_in with reserved fields, add FUSE_INIT_EXT init flag
194+
* - add flags2 to fuse_init_in and fuse_init_out
195+
* - add FUSE_SECURITY_CTX init flag
196+
* - add security context to create, mkdir, symlink, and mknod requests
197+
* - add FUSE_HAS_INODE_DAX, FUSE_ATTR_DAX
191198
*/
192199

193200
#ifndef _FUSE_FUSE_KERNEL_H
@@ -223,7 +230,7 @@
223230
#define FUSE_KERNEL_VERSION 7
224231

225232
/** Minor version number of this interface */
226-
#define FUSE_KERNEL_MINOR_VERSION 35
233+
#define FUSE_KERNEL_MINOR_VERSION 36
227234

228235
/** The node ID of the root inode */
229236
#define FUSE_ROOT_ID 1
@@ -284,7 +291,7 @@ struct fuse_file_lock {
284291
#define FATTR_MTIME_NOW (1 << 8)
285292
#define FATTR_LOCKOWNER (1 << 9)
286293
#define FATTR_CTIME (1 << 10)
287-
#define FATTR_KILL_SUIDGID (1 << 11)
294+
#define FATTR_KILL_SUIDGID (1 << 11)
288295

289296
/**
290297
* Flags returned by the OPEN request
@@ -342,6 +349,11 @@ struct fuse_file_lock {
342349
* write/truncate sgid is killed only if file has group
343350
* execute permission. (Same as Linux VFS behavior).
344351
* FUSE_SETXATTR_EXT: Server supports extended struct fuse_setxattr_in
352+
* FUSE_INIT_EXT: extended fuse_init_in request
353+
* FUSE_INIT_RESERVED: reserved, do not use
354+
* FUSE_SECURITY_CTX: add security context to create, mkdir, symlink, and
355+
* mknod
356+
* FUSE_HAS_INODE_DAX: use per inode DAX
345357
*/
346358
#define FUSE_ASYNC_READ (1 << 0)
347359
#define FUSE_POSIX_LOCKS (1 << 1)
@@ -373,6 +385,11 @@ struct fuse_file_lock {
373385
#define FUSE_SUBMOUNTS (1 << 27)
374386
#define FUSE_HANDLE_KILLPRIV_V2 (1 << 28)
375387
#define FUSE_SETXATTR_EXT (1 << 29)
388+
#define FUSE_INIT_EXT (1 << 30)
389+
#define FUSE_INIT_RESERVED (1 << 31)
390+
/* bits 32..63 get shifted down 32 bits into the flags2 field */
391+
#define FUSE_SECURITY_CTX (1ULL << 32)
392+
#define FUSE_HAS_INODE_DAX (1ULL << 33)
376393

377394
#ifdef linux
378395
/**
@@ -463,8 +480,10 @@ struct fuse_file_lock {
463480
* fuse_attr flags
464481
*
465482
* FUSE_ATTR_SUBMOUNT: Object is a submount root
483+
* FUSE_ATTR_DAX: Enable DAX for this file in per inode DAX mode
466484
*/
467485
#define FUSE_ATTR_SUBMOUNT (1 << 0)
486+
#define FUSE_ATTR_DAX (1 << 1)
468487

469488
/**
470489
* Open flags
@@ -761,6 +780,8 @@ struct fuse_init_in {
761780
uint32_t minor;
762781
uint32_t max_readahead;
763782
uint32_t flags;
783+
uint32_t flags2;
784+
uint32_t unused[11];
764785
};
765786

766787
#define FUSE_COMPAT_INIT_OUT_SIZE 8
@@ -777,7 +798,8 @@ struct fuse_init_out {
777798
uint32_t time_gran;
778799
uint16_t max_pages;
779800
uint16_t map_alignment;
780-
uint32_t unused[8];
801+
uint32_t flags2;
802+
uint32_t unused[7];
781803
};
782804

783805
#ifdef linux
@@ -887,9 +909,12 @@ struct fuse_dirent {
887909
char name[];
888910
};
889911

890-
#define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name)
891-
#define FUSE_DIRENT_ALIGN(x) \
912+
/* Align variable length records to 64bit boundary */
913+
#define FUSE_REC_ALIGN(x) \
892914
(((x) + sizeof(uint64_t) - 1) & ~(sizeof(uint64_t) - 1))
915+
916+
#define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name)
917+
#define FUSE_DIRENT_ALIGN(x) FUSE_REC_ALIGN(x)
893918
#define FUSE_DIRENT_SIZE(d) \
894919
FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)
895920

@@ -1006,4 +1031,26 @@ struct fuse_syncfs_in {
10061031
uint64_t padding;
10071032
};
10081033

1034+
/*
1035+
* For each security context, send fuse_secctx with size of security context
1036+
* fuse_secctx will be followed by security context name and this in turn
1037+
* will be followed by actual context label.
1038+
* fuse_secctx, name, context
1039+
*/
1040+
struct fuse_secctx {
1041+
uint32_t size;
1042+
uint32_t padding;
1043+
};
1044+
1045+
/*
1046+
* Contains the information about how many fuse_secctx structures are being
1047+
* sent and what's the total size of all security contexts (including
1048+
* size of fuse_secctx_header).
1049+
*
1050+
*/
1051+
struct fuse_secctx_header {
1052+
uint32_t size;
1053+
uint32_t nr_secctx;
1054+
};
1055+
10091056
#endif /* _FUSE_FUSE_KERNEL_H */

tests/sys/fs/fusefs/mockfs.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,7 @@ void MockFS::init(uint32_t flags) {
763763
out->body.init.major = FUSE_KERNEL_VERSION;
764764
out->body.init.minor = m_kernel_minor_version;;
765765
out->body.init.flags = in->body.init.flags & flags;
766+
out->body.init.flags2 = 0;
766767
out->body.init.max_write = m_maxwrite;
767768
out->body.init.max_readahead = m_maxreadahead;
768769

0 commit comments

Comments
 (0)