← Documents Documentation/filesystems/mount_api.rst GitHub 원문 ↗

Linux 6.18.37 · Filesystems

Filesystem Mount API

fs_context 수명주기, LSM hook, superblock 선택, typed mount parameter parser의 전문 번역입니다.

Source pathDocumentation/filesystems/mount_api.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

mount_api.rst:1-811

새 mount API는 모든 작업을 `fs_context`에 축적한 뒤 parse, 전체 검증, superblock 선택, mount object 생성 순서로 진행합니다. Context의 pointer나 resource를 superblock으로 이전할 때는 원래 pointer를 반드시 NULL로 지워 파괴 경로의 이중 해제를 막아야 합니다.

Filesystem과 LSM은 parameter를 단계적으로 소비하며, typed parser description은 등록 시 검증과 userspace 조회를 가능하게 합니다. Reconfigure 적용처럼 실패할 수 없는 단계 전에 모든 오류 검사와 resource 할당을 끝내는 것이 핵심 설계 원칙입니다.

Mount API 전체 수명주기
`fs_context_for_*()` 생성VFS·LSM·filesystem parameter parsecollection validate`sget_fc()`와 `get_tree()`security data·resource ownership 이전`vfs_create_mount()``put_fs_context()` 정리

사용자 parameter가 detached mount가 되기까지의 주요 단계입니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2
3 ====================
4 Filesystem Mount API
5 ====================
6
7 .. CONTENTS
8
9 (1) Overview.
10
11 (2) The filesystem context.
12
13 (3) The filesystem context operations.
14
15 (4) Filesystem context security.
16
17 (5) VFS filesystem context API.
18
19 (6) Superblock creation helpers.
20
21 (7) Parameter description.
22
23 (8) Parameter helper functions.
24
25
26 Overview
27 ========
28
29 The creation of new mounts is now to be done in a multistep process:
30
31 (1) Create a filesystem context.
32
33 (2) Parse the parameters and attach them to the context. Parameters are
34 expected to be passed individually from userspace, though legacy binary
35 parameters can also be handled.
36
37 (3) Validate and pre-process the context.
38
39 (4) Get or create a superblock and mountable root.
40
41 (5) Perform the mount.
42
43 (6) Return an error message attached to the context.
44
45 (7) Destroy the context.
46
47 To support this, the file_system_type struct gains two new fields::
48
49 int (*init_fs_context)(struct fs_context *fc);
50 const struct fs_parameter_description *parameters;
51
52 The first is invoked to set up the filesystem-specific parts of a filesystem
53 context, including the additional space, and the second points to the
54 parameter description for validation at registration time and querying by a
55 future system call.
56
57 Note that security initialisation is done *after* the filesystem is called so
58 that the namespaces may be adjusted first.
59
60
61 The Filesystem context
62 ======================
63
64 The creation and reconfiguration of a superblock is governed by a filesystem
65 context. This is represented by the fs_context structure::
66
67 struct fs_context {
68 const struct fs_context_operations *ops;
69 struct file_system_type *fs_type;
70 void *fs_private;
71 struct dentry *root;
72 struct user_namespace *user_ns;
73 struct net *net_ns;
74 const struct cred *cred;
75 char *source;
76 char *subtype;
77 void *security;
78 void *s_fs_info;
79 unsigned int sb_flags;
80 unsigned int sb_flags_mask;
81 unsigned int s_iflags;
82 enum fs_context_purpose purpose:8;
83 ...
84 };
85
86 The fs_context fields are as follows:
87
88 * ::
89
90 const struct fs_context_operations *ops
91
92 These are operations that can be done on a filesystem context (see
93 below). This must be set by the ->init_fs_context() file_system_type
94 operation.
95
96 * ::
97
98 struct file_system_type *fs_type
99
100 A pointer to the file_system_type of the filesystem that is being
101 constructed or reconfigured. This retains a reference on the type owner.
102
103 * ::
104
105 void *fs_private
106
107 A pointer to the file system's private data. This is where the filesystem
108 will need to store any options it parses.
109
110 * ::
111
112 struct dentry *root
113
114 A pointer to the root of the mountable tree (and indirectly, the
115 superblock thereof). This is filled in by the ->get_tree() op. If this
116 is set, an active reference on root->d_sb must also be held.
117
118 * ::
119
120 struct user_namespace *user_ns
121 struct net *net_ns
122
123 There are a subset of the namespaces in use by the invoking process. They
124 retain references on each namespace. The subscribed namespaces may be
125 replaced by the filesystem to reflect other sources, such as the parent
126 mount superblock on an automount.
127
128 * ::
129
130 const struct cred *cred
131
132 The mounter's credentials. This retains a reference on the credentials.
133
134 * ::
135
136 char *source
137
138 This specifies the source. It may be a block device (e.g. /dev/sda1) or
139 something more exotic, such as the "host:/path" that NFS desires.
140
141 * ::
142
143 char *subtype
144
145 This is a string to be added to the type displayed in /proc/mounts to
146 qualify it (used by FUSE). This is available for the filesystem to set if
147 desired.
148
149 * ::
150
151 void *security
152
153 A place for the LSMs to hang their security data for the superblock. The
154 relevant security operations are described below.
155
156 * ::
157
158 void *s_fs_info
159
160 The proposed s_fs_info for a new superblock, set in the superblock by
161 sget_fc(). This can be used to distinguish superblocks.
162
163 * ::
164
165 unsigned int sb_flags
166 unsigned int sb_flags_mask
167
168 Which bits SB_* flags are to be set/cleared in super_block::s_flags.
169
170 * ::
171
172 unsigned int s_iflags
173
174 These will be bitwise-OR'd with s->s_iflags when a superblock is created.
175
176 * ::
177
178 enum fs_context_purpose
179
180 This indicates the purpose for which the context is intended. The
181 available values are:
182
183 ========================== ======================================
184 FS_CONTEXT_FOR_MOUNT, New superblock for explicit mount
185 FS_CONTEXT_FOR_SUBMOUNT New automatic submount of extant mount
186 FS_CONTEXT_FOR_RECONFIGURE Change an existing mount
187 ========================== ======================================
188
189 The mount context is created by calling vfs_new_fs_context() or
190 vfs_dup_fs_context() and is destroyed with put_fs_context(). Note that the
191 structure is not refcounted.
192
193 VFS, security and filesystem mount options are set individually with
194 vfs_parse_mount_option(). Options provided by the old mount(2) system call as
195 a page of data can be parsed with generic_parse_monolithic().
196
197 When mounting, the filesystem is allowed to take data from any of the pointers
198 and attach it to the superblock (or whatever), provided it clears the pointer
199 in the mount context.
200
201 The filesystem is also allowed to allocate resources and pin them with the
202 mount context. For instance, NFS might pin the appropriate protocol version
203 module.
204
205
206 The Filesystem Context Operations
207 =================================
208
209 The filesystem context points to a table of operations::
210
211 struct fs_context_operations {
212 void (*free)(struct fs_context *fc);
213 int (*dup)(struct fs_context *fc, struct fs_context *src_fc);
214 int (*parse_param)(struct fs_context *fc,
215 struct fs_parameter *param);
216 int (*parse_monolithic)(struct fs_context *fc, void *data);
217 int (*get_tree)(struct fs_context *fc);
218 int (*reconfigure)(struct fs_context *fc);
219 };
220
221 These operations are invoked by the various stages of the mount procedure to
222 manage the filesystem context. They are as follows:
223
224 * ::
225
226 void (*free)(struct fs_context *fc);
227
228 Called to clean up the filesystem-specific part of the filesystem context
229 when the context is destroyed. It should be aware that parts of the
230 context may have been removed and NULL'd out by ->get_tree().
231
232 * ::
233
234 int (*dup)(struct fs_context *fc, struct fs_context *src_fc);
235
236 Called when a filesystem context has been duplicated to duplicate the
237 filesystem-private data. An error may be returned to indicate failure to
238 do this.
239
240 .. Warning::
241
242 Note that even if this fails, put_fs_context() will be called
243 immediately thereafter, so ->dup() *must* make the
244 filesystem-private data safe for ->free().
245
246 * ::
247
248 int (*parse_param)(struct fs_context *fc,
249 struct fs_parameter *param);
250
251 Called when a parameter is being added to the filesystem context. param
252 points to the key name and maybe a value object. VFS-specific options
253 will have been weeded out and fc->sb_flags updated in the context.
254 Security options will also have been weeded out and fc->security updated.
255
256 The parameter can be parsed with fs_parse() and fs_lookup_param(). Note
257 that the source(s) are presented as parameters named "source".
258
259 If successful, 0 should be returned or a negative error code otherwise.
260
261 * ::
262
263 int (*parse_monolithic)(struct fs_context *fc, void *data);
264
265 Called when the mount(2) system call is invoked to pass the entire data
266 page in one go. If this is expected to be just a list of "key[=val]"
267 items separated by commas, then this may be set to NULL.
268
269 The return value is as for ->parse_param().
270
271 If the filesystem (e.g. NFS) needs to examine the data first and then
272 finds it's the standard key-val list then it may pass it off to
273 generic_parse_monolithic().
274
275 * ::
276
277 int (*get_tree)(struct fs_context *fc);
278
279 Called to get or create the mountable root and superblock, using the
280 information stored in the filesystem context (reconfiguration goes via a
281 different vector). It may detach any resources it desires from the
282 filesystem context and transfer them to the superblock it creates.
283
284 On success it should set fc->root to the mountable root and return 0. In
285 the case of an error, it should return a negative error code.
286
287 The phase on a userspace-driven context will be set to only allow this to
288 be called once on any particular context.
289
290 * ::
291
292 int (*reconfigure)(struct fs_context *fc);
293
294 Called to effect reconfiguration of a superblock using information stored
295 in the filesystem context. It may detach any resources it desires from
296 the filesystem context and transfer them to the superblock. The
297 superblock can be found from fc->root->d_sb.
298
299 On success it should return 0. In the case of an error, it should return
300 a negative error code.
301
302 .. Note:: reconfigure is intended as a replacement for remount_fs.
303
304
305 Filesystem context Security
306 ===========================
307
308 The filesystem context contains a security pointer that the LSMs can use for
309 building up a security context for the superblock to be mounted. There are a
310 number of operations used by the new mount code for this purpose:
311
312 * ::
313
314 int security_fs_context_alloc(struct fs_context *fc,
315 struct dentry *reference);
316
317 Called to initialise fc->security (which is preset to NULL) and allocate
318 any resources needed. It should return 0 on success or a negative error
319 code on failure.
320
321 reference will be non-NULL if the context is being created for superblock
322 reconfiguration (FS_CONTEXT_FOR_RECONFIGURE) in which case it indicates
323 the root dentry of the superblock to be reconfigured. It will also be
324 non-NULL in the case of a submount (FS_CONTEXT_FOR_SUBMOUNT) in which case
325 it indicates the automount point.
326
327 * ::
328
329 int security_fs_context_dup(struct fs_context *fc,
330 struct fs_context *src_fc);
331
332 Called to initialise fc->security (which is preset to NULL) and allocate
333 any resources needed. The original filesystem context is pointed to by
334 src_fc and may be used for reference. It should return 0 on success or a
335 negative error code on failure.
336
337 * ::
338
339 void security_fs_context_free(struct fs_context *fc);
340
341 Called to clean up anything attached to fc->security. Note that the
342 contents may have been transferred to a superblock and the pointer cleared
343 during get_tree.
344
345 * ::
346
347 int security_fs_context_parse_param(struct fs_context *fc,
348 struct fs_parameter *param);
349
350 Called for each mount parameter, including the source. The arguments are
351 as for the ->parse_param() method. It should return 0 to indicate that
352 the parameter should be passed on to the filesystem, 1 to indicate that
353 the parameter should be discarded or an error to indicate that the
354 parameter should be rejected.
355
356 The value pointed to by param may be modified (if a string) or stolen
357 (provided the value pointer is NULL'd out). If it is stolen, 1 must be
358 returned to prevent it being passed to the filesystem.
359
360 * ::
361
362 int security_fs_context_validate(struct fs_context *fc);
363
364 Called after all the options have been parsed to validate the collection
365 as a whole and to do any necessary allocation so that
366 security_sb_get_tree() and security_sb_reconfigure() are less likely to
367 fail. It should return 0 or a negative error code.
368
369 In the case of reconfiguration, the target superblock will be accessible
370 via fc->root.
371
372 * ::
373
374 int security_sb_get_tree(struct fs_context *fc);
375
376 Called during the mount procedure to verify that the specified superblock
377 is allowed to be mounted and to transfer the security data there. It
378 should return 0 or a negative error code.
379
380 * ::
381
382 void security_sb_reconfigure(struct fs_context *fc);
383
384 Called to apply any reconfiguration to an LSM's context. It must not
385 fail. Error checking and resource allocation must be done in advance by
386 the parameter parsing and validation hooks.
387
388 * ::
389
390 int security_sb_mountpoint(struct fs_context *fc,
391 struct path *mountpoint,
392 unsigned int mnt_flags);
393
394 Called during the mount procedure to verify that the root dentry attached
395 to the context is permitted to be attached to the specified mountpoint.
396 It should return 0 on success or a negative error code on failure.
397
398
399 VFS Filesystem context API
400 ==========================
401
402 There are four operations for creating a filesystem context and one for
403 destroying a context:
404
405 * ::
406
407 struct fs_context *fs_context_for_mount(struct file_system_type *fs_type,
408 unsigned int sb_flags);
409
410 Allocate a filesystem context for the purpose of setting up a new mount,
411 whether that be with a new superblock or sharing an existing one. This
412 sets the superblock flags, initialises the security and calls
413 fs_type->init_fs_context() to initialise the filesystem private data.
414
415 fs_type specifies the filesystem type that will manage the context and
416 sb_flags presets the superblock flags stored therein.
417
418 * ::
419
420 struct fs_context *fs_context_for_reconfigure(
421 struct dentry *dentry,
422 unsigned int sb_flags,
423 unsigned int sb_flags_mask);
424
425 Allocate a filesystem context for the purpose of reconfiguring an
426 existing superblock. dentry provides a reference to the superblock to be
427 configured. sb_flags and sb_flags_mask indicate which superblock flags
428 need changing and to what.
429
430 * ::
431
432 struct fs_context *fs_context_for_submount(
433 struct file_system_type *fs_type,
434 struct dentry *reference);
435
436 Allocate a filesystem context for the purpose of creating a new mount for
437 an automount point or other derived superblock. fs_type specifies the
438 filesystem type that will manage the context and the reference dentry
439 supplies the parameters. Namespaces are propagated from the reference
440 dentry's superblock also.
441
442 Note that it's not a requirement that the reference dentry be of the same
443 filesystem type as fs_type.
444
445 * ::
446
447 struct fs_context *vfs_dup_fs_context(struct fs_context *src_fc);
448
449 Duplicate a filesystem context, copying any options noted and duplicating
450 or additionally referencing any resources held therein. This is available
451 for use where a filesystem has to get a mount within a mount, such as NFS4
452 does by internally mounting the root of the target server and then doing a
453 private pathwalk to the target directory.
454
455 The purpose in the new context is inherited from the old one.
456
457 * ::
458
459 void put_fs_context(struct fs_context *fc);
460
461 Destroy a filesystem context, releasing any resources it holds. This
462 calls the ->free() operation. This is intended to be called by anyone who
463 created a filesystem context.
464
465 .. Warning::
466
467 filesystem contexts are not refcounted, so this causes unconditional
468 destruction.
469
470 In all the above operations, apart from the put op, the return is a mount
471 context pointer or a negative error code.
472
473 For the remaining operations, if an error occurs, a negative error code will be
474 returned.
475
476 * ::
477
478 int vfs_parse_fs_param(struct fs_context *fc,
479 struct fs_parameter *param);
480
481 Supply a single mount parameter to the filesystem context. This includes
482 the specification of the source/device which is specified as the "source"
483 parameter (which may be specified multiple times if the filesystem
484 supports that).
485
486 param specifies the parameter key name and the value. The parameter is
487 first checked to see if it corresponds to a standard mount flag (in which
488 case it is used to set an SB_xxx flag and consumed) or a security option
489 (in which case the LSM consumes it) before it is passed on to the
490 filesystem.
491
492 The parameter value is typed and can be one of:
493
494 ==================== =============================
495 fs_value_is_flag Parameter not given a value
496 fs_value_is_string Value is a string
497 fs_value_is_blob Value is a binary blob
498 fs_value_is_filename Value is a filename* + dirfd
499 fs_value_is_file Value is an open file (file*)
500 ==================== =============================
501
502 If there is a value, that value is stored in a union in the struct in one
503 of param->{string,blob,name,file}. Note that the function may steal and
504 clear the pointer, but then becomes responsible for disposing of the
505 object.
506
507 * ::
508
509 int vfs_parse_fs_qstr(struct fs_context *fc, const char *key,
510 const struct qstr *value);
511
512 A wrapper around vfs_parse_fs_param() that copies the value string it is
513 passed.
514
515 * ::
516
517 int vfs_parse_fs_string(struct fs_context *fc, const char *key,
518 const char *value);
519
520 A wrapper around vfs_parse_fs_param() that copies the value string it is
521 passed.
522
523 * ::
524
525 int generic_parse_monolithic(struct fs_context *fc, void *data);
526
527 Parse a sys_mount() data page, assuming the form to be a text list
528 consisting of key[=val] options separated by commas. Each item in the
529 list is passed to vfs_mount_option(). This is the default when the
530 ->parse_monolithic() method is NULL.
531
532 * ::
533
534 int vfs_get_tree(struct fs_context *fc);
535
536 Get or create the mountable root and superblock, using the parameters in
537 the filesystem context to select/configure the superblock. This invokes
538 the ->get_tree() method.
539
540 * ::
541
542 struct vfsmount *vfs_create_mount(struct fs_context *fc);
543
544 Create a mount given the parameters in the specified filesystem context.
545 Note that this does not attach the mount to anything.
546
547
548 Superblock Creation Helpers
549 ===========================
550
551 A number of VFS helpers are available for use by filesystems for the creation
552 or looking up of superblocks.
553
554 * ::
555
556 struct super_block *
557 sget_fc(struct fs_context *fc,
558 int (*test)(struct super_block *sb, struct fs_context *fc),
559 int (*set)(struct super_block *sb, struct fs_context *fc));
560
561 This is the core routine. If test is non-NULL, it searches for an
562 existing superblock matching the criteria held in the fs_context, using
563 the test function to match them. If no match is found, a new superblock
564 is created and the set function is called to set it up.
565
566 Prior to the set function being called, fc->s_fs_info will be transferred
567 to sb->s_fs_info - and fc->s_fs_info will be cleared if set returns
568 success (ie. 0).
569
570 The following helpers all wrap sget_fc():
571
572 (1) vfs_get_single_super
573
574 Only one such superblock may exist in the system. Any further
575 attempt to get a new superblock gets this one (and any parameter
576 differences are ignored).
577
578 (2) vfs_get_keyed_super
579
580 Multiple superblocks of this type may exist and they're keyed on
581 their s_fs_info pointer (for example this may refer to a
582 namespace).
583
584 (3) vfs_get_independent_super
585
586 Multiple independent superblocks of this type may exist. This
587 function never matches an existing one and always creates a new
588 one.
589
590
591 Parameter Description
592 =====================
593
594 Parameters are described using structures defined in linux/fs_parser.h.
595 There's a core description struct that links everything together::
596
597 struct fs_parameter_description {
598 const struct fs_parameter_spec *specs;
599 const struct fs_parameter_enum *enums;
600 };
601
602 For example::
603
604 enum {
605 Opt_autocell,
606 Opt_bar,
607 Opt_dyn,
608 Opt_foo,
609 Opt_source,
610 };
611
612 static const struct fs_parameter_description afs_fs_parameters = {
613 .specs = afs_param_specs,
614 .enums = afs_param_enums,
615 };
616
617 The members are as follows:
618
619 (1) ::
620
621 const struct fs_parameter_specification *specs;
622
623 Table of parameter specifications, terminated with a null entry, where the
624 entries are of type::
625
626 struct fs_parameter_spec {
627 const char *name;
628 u8 opt;
629 enum fs_parameter_type type:8;
630 unsigned short flags;
631 };
632
633 The 'name' field is a string to match exactly to the parameter key (no
634 wildcards, patterns and no case-independence) and 'opt' is the value that
635 will be returned by the fs_parser() function in the case of a successful
636 match.
637
638 The 'type' field indicates the desired value type and must be one of:
639
640 ======================= ======================= =====================
641 TYPE NAME EXPECTED VALUE RESULT IN
642 ======================= ======================= =====================
643 fs_param_is_flag No value n/a
644 fs_param_is_bool Boolean value result->boolean
645 fs_param_is_u32 32-bit unsigned int result->uint_32
646 fs_param_is_u32_octal 32-bit octal int result->uint_32
647 fs_param_is_u32_hex 32-bit hex int result->uint_32
648 fs_param_is_s32 32-bit signed int result->int_32
649 fs_param_is_u64 64-bit unsigned int result->uint_64
650 fs_param_is_enum Enum value name result->uint_32
651 fs_param_is_string Arbitrary string param->string
652 fs_param_is_blob Binary blob param->blob
653 fs_param_is_blockdev Blockdev path * Needs lookup
654 fs_param_is_path Path * Needs lookup
655 fs_param_is_fd File descriptor result->int_32
656 fs_param_is_uid User ID (u32) result->uid
657 fs_param_is_gid Group ID (u32) result->gid
658 ======================= ======================= =====================
659
660 Note that if the value is of fs_param_is_bool type, fs_parse() will try
661 to match any string value against "0", "1", "no", "yes", "false", "true".
662
663 Each parameter can also be qualified with 'flags':
664
665 ======================= ================================================
666 fs_param_v_optional The value is optional
667 fs_param_neg_with_no result->negated set if key is prefixed with "no"
668 fs_param_neg_with_empty result->negated set if value is ""
669 fs_param_deprecated The parameter is deprecated.
670 ======================= ================================================
671
672 These are wrapped with a number of convenience wrappers:
673
674 ======================= ===============================================
675 MACRO SPECIFIES
676 ======================= ===============================================
677 fsparam_flag() fs_param_is_flag
678 fsparam_flag_no() fs_param_is_flag, fs_param_neg_with_no
679 fsparam_bool() fs_param_is_bool
680 fsparam_u32() fs_param_is_u32
681 fsparam_u32oct() fs_param_is_u32_octal
682 fsparam_s32() fs_param_is_s32
683 fsparam_u64() fs_param_is_u64
684 fsparam_enum() fs_param_is_enum
685 fsparam_string() fs_param_is_string
686 fsparam_blob() fs_param_is_blob
687 fsparam_bdev() fs_param_is_blockdev
688 fsparam_path() fs_param_is_path
689 fsparam_fd() fs_param_is_fd
690 fsparam_uid() fs_param_is_uid
691 fsparam_gid() fs_param_is_gid
692 ======================= ===============================================
693
694 all of which take two arguments, name string and option number - for
695 example::
696
697 static const struct fs_parameter_spec afs_param_specs[] = {
698 fsparam_flag ("autocell", Opt_autocell),
699 fsparam_flag ("dyn", Opt_dyn),
700 fsparam_string ("source", Opt_source),
701 fsparam_flag_no ("foo", Opt_foo),
702 {}
703 };
704
705 An addition macro, __fsparam() is provided that takes an additional pair
706 of arguments to specify the type and the flags for anything that doesn't
707 match one of the above macros.
708
709 (2) ::
710
711 const struct fs_parameter_enum *enums;
712
713 Table of enum value names to integer mappings, terminated with a null
714 entry. This is of type::
715
716 struct fs_parameter_enum {
717 u8 opt;
718 char name[14];
719 u8 value;
720 };
721
722 Where the array is an unsorted list of { parameter ID, name }-keyed
723 elements that indicate the value to map to, e.g.::
724
725 static const struct fs_parameter_enum afs_param_enums[] = {
726 { Opt_bar, "x", 1},
727 { Opt_bar, "y", 23},
728 { Opt_bar, "z", 42},
729 };
730
731 If a parameter of type fs_param_is_enum is encountered, fs_parse() will
732 try to look the value up in the enum table and the result will be stored
733 in the parse result.
734
735 The parser should be pointed to by the parser pointer in the file_system_type
736 struct as this will provide validation on registration (if
737 CONFIG_VALIDATE_FS_PARSER=y) and will allow the description to be queried from
738 userspace using the fsinfo() syscall.
739
740
741 Parameter Helper Functions
742 ==========================
743
744 A number of helper functions are provided to help a filesystem or an LSM
745 process the parameters it is given.
746
747 * ::
748
749 int lookup_constant(const struct constant_table tbl[],
750 const char *name, int not_found);
751
752 Look up a constant by name in a table of name -> integer mappings. The
753 table is an array of elements of the following type::
754
755 struct constant_table {
756 const char *name;
757 int value;
758 };
759
760 If a match is found, the corresponding value is returned. If a match
761 isn't found, the not_found value is returned instead.
762
763 * ::
764
765 bool fs_validate_description(const char *name,
766 const struct fs_parameter_description *desc);
767
768 This performs some validation checks on a parameter description. It
769 returns true if the description is good and false if it is not. It will
770 log errors to the kernel log buffer if validation fails.
771
772 * ::
773
774 int fs_parse(struct fs_context *fc,
775 const struct fs_parameter_description *desc,
776 struct fs_parameter *param,
777 struct fs_parse_result *result);
778
779 This is the main interpreter of parameters. It uses the parameter
780 description to look up a parameter by key name and to convert that to an
781 option number (which it returns).
782
783 If successful, and if the parameter type indicates the result is a
784 boolean, integer, enum, uid, or gid type, the value is converted by this
785 function and the result stored in
786 result->{boolean,int_32,uint_32,uint_64,uid,gid}.
787
788 If a match isn't initially made, the key is prefixed with "no" and no
789 value is present then an attempt will be made to look up the key with the
790 prefix removed. If this matches a parameter for which the type has flag
791 fs_param_neg_with_no set, then a match will be made and result->negated
792 will be set to true.
793
794 If the parameter isn't matched, -ENOPARAM will be returned; if the
795 parameter is matched, but the value is erroneous, -EINVAL will be
796 returned; otherwise the parameter's option number will be returned.
797
798 * ::
799
800 int fs_lookup_param(struct fs_context *fc,
801 struct fs_parameter *value,
802 bool want_bdev,
803 unsigned int flags,
804 struct path *_path);
805
806 This takes a parameter that carries a string or filename type and attempts
807 to do a path lookup on it. If the parameter expects a blockdev, a check
808 is made that the inode actually represents one.
809
810 Returns 0 if successful and ``*_path`` will be set; returns a negative
811 error code if not.
812

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

다단계 mount 절차 개요

1-61

이 GPL-2.0 문서는 Filesystem Mount API를 여덟 부분으로 설명합니다. Overview, filesystem context, context operation, security, VFS context API, superblock helper, parameter description, parameter helper function 순서입니다.

새 mount 생성은 다단계 과정입니다. 먼저 filesystem context를 만들고, userspace에서 보통 개별적으로 전달되는 parameter를 parse해 context에 붙입니다. Legacy binary parameter도 처리할 수 있습니다. 그다음 context 전체를 검증·전처리하고, superblock과 mount 가능한 root를 얻거나 생성한 뒤 실제 mount를 수행합니다.

오류가 있으면 context에 연결된 error message를 반환하고 마지막에 context를 파괴합니다. 이 모델은 option parsing, 보안 검증, superblock 선택, mount object 생성을 서로 다른 단계로 분리합니다.

이를 지원하려고 `struct file_system_type`에는 `init_fs_context(struct fs_context *fc)`와 `parameters`가 추가됩니다. 첫 필드는 추가 공간을 포함한 filesystem-specific context 부분을 설정하고, 둘째는 등록 시 검증 및 향후 system call의 조회에 쓸 parameter description을 가리킵니다.

Security 초기화는 filesystem callback 뒤에 수행됩니다. Filesystem이 먼저 namespace를 조정할 수 있어야 하기 때문입니다.

새 mount의 일곱 단계
filesystem context 생성parameter 개별 parse·attachvalidate·pre-processsuperblock과 root 획득·생성mount 수행context에 error message 연결context destroy

Context 생성부터 오류 전달과 정리까지의 수명주기입니다.

.. SPDX-License-Identifier: GPL-2.0

====================
Filesystem Mount API
====================

.. CONTENTS

 (1) Overview.

 (2) The filesystem context.

 (3) The filesystem context operations.

 (4) Filesystem context security.

 (5) VFS filesystem context API.

 (6) Superblock creation helpers.

 (7) Parameter description.

 (8) Parameter helper functions.


Overview
========

The creation of new mounts is now to be done in a multistep process:

 (1) Create a filesystem context.

 (2) Parse the parameters and attach them to the context.  Parameters are
     expected to be passed individually from userspace, though legacy binary
     parameters can also be handled.

 (3) Validate and pre-process the context.

 (4) Get or create a superblock and mountable root.

 (5) Perform the mount.

 (6) Return an error message attached to the context.

 (7) Destroy the context.

To support this, the file_system_type struct gains two new fields::

        int (*init_fs_context)(struct fs_context *fc);
        const struct fs_parameter_description *parameters;

The first is invoked to set up the filesystem-specific parts of a filesystem
context, including the additional space, and the second points to the
parameter description for validation at registration time and querying by a
future system call.

Note that security initialisation is done *after* the filesystem is called so
that the namespaces may be adjusted first.


The Filesystem context

fs_context 핵심 포인터와 namespace

62-127

Superblock 생성과 reconfiguration은 `struct fs_context`가 관장합니다. `ops`는 context에서 수행할 operation table이며 `file_system_type::init_fs_context()`가 반드시 설정해야 합니다. `fs_type`은 생성 또는 재구성 중인 filesystem의 `file_system_type`을 가리키고 type owner reference를 유지합니다.

`fs_private`는 파일시스템 전용 데이터 포인터로, 파일시스템이 parse한 option을 저장하는 곳입니다. `root`는 mount 가능한 tree의 root와 간접적으로 그 superblock을 가리키며 `->get_tree()`가 채웁니다. `root`가 설정되면 `root->d_sb`의 active reference도 보유해야 합니다.

`user_ns`와 `net_ns`는 호출 process가 사용하는 namespace의 일부이며 각각 reference를 유지합니다. Automount에서 parent mount의 superblock을 따르는 경우처럼 다른 source를 반영하기 위해 filesystem이 구독 namespace를 교체할 수 있습니다.

`cred`는 mounter의 credential이며 reference가 유지됩니다. 이 구간의 구조체 원문에는 이후 설명할 `source`, `subtype`, `security`, `s_fs_info`, flag, `purpose` 필드도 함께 선언되어 있습니다.

`fs_context`의 소유 관계
필드역할·소유권
`ops``init_fs_context()`가 설정하는 operation table
`fs_type`type owner reference 유지
`fs_private`parse된 filesystem option 저장
`root`mountable root, `root->d_sb` active ref 필요
`user_ns`·`net_ns`namespace reference 유지, 교체 가능
`cred`mounter credential reference 유지

핵심 포인터가 무엇을 가리키고 어떤 reference를 유지하는지 정리합니다.

======================

The creation and reconfiguration of a superblock is governed by a filesystem
context.  This is represented by the fs_context structure::

        struct fs_context {
                const struct fs_context_operations *ops;
                struct file_system_type *fs_type;
                void                        *fs_private;
                struct dentry                *root;
                struct user_namespace        *user_ns;
                struct net                *net_ns;
                const struct cred        *cred;
                char                        *source;
                char                        *subtype;
                void                        *security;
                void                        *s_fs_info;
                unsigned int                sb_flags;
                unsigned int                sb_flags_mask;
                unsigned int                s_iflags;
                enum fs_context_purpose        purpose:8;
                ...
        };

The fs_context fields are as follows:

   * ::

       const struct fs_context_operations *ops

     These are operations that can be done on a filesystem context (see
     below).  This must be set by the ->init_fs_context() file_system_type
     operation.

   * ::

       struct file_system_type *fs_type

     A pointer to the file_system_type of the filesystem that is being
     constructed or reconfigured.  This retains a reference on the type owner.

   * ::

       void *fs_private

     A pointer to the file system's private data.  This is where the filesystem
     will need to store any options it parses.

   * ::

       struct dentry *root

     A pointer to the root of the mountable tree (and indirectly, the
     superblock thereof).  This is filled in by the ->get_tree() op.  If this
     is set, an active reference on root->d_sb must also be held.

   * ::

       struct user_namespace *user_ns
       struct net *net_ns

     There are a subset of the namespaces in use by the invoking process.  They
     retain references on each namespace.  The subscribed namespaces may be
     replaced by the filesystem to reflect other sources, such as the parent
     mount superblock on an automount.

source·security·flag·purpose와 context 수명주기

128-206

`source`는 mount source를 지정합니다. `/dev/sda1` 같은 block device일 수도 있고 NFS가 사용하는 `host:/path` 같은 값일 수도 있습니다. `subtype`은 `/proc/mounts`에 표시되는 type을 한정하기 위해 덧붙이는 문자열이며 FUSE가 사용합니다.

`security`는 LSM이 mount할 superblock의 security data를 쌓는 위치입니다. `s_fs_info`는 새 superblock에 제안할 `s_fs_info`이고 `sget_fc()`가 superblock으로 옮깁니다. Superblock을 서로 구별하는 key로 사용할 수 있습니다.

`sb_flags`와 `sb_flags_mask`는 `super_block::s_flags`에서 설정하거나 지울 `SB_*` bit를 나타냅니다. `s_iflags`는 superblock 생성 시 `s->s_iflags`에 bitwise OR 됩니다.

`purpose`는 context 목적을 표시합니다. `FS_CONTEXT_FOR_MOUNT`는 명시적 mount용 새 superblock, `FS_CONTEXT_FOR_SUBMOUNT`는 기존 mount의 새 automatic submount, `FS_CONTEXT_FOR_RECONFIGURE`는 기존 mount 변경입니다.

Mount context는 `vfs_new_fs_context()` 또는 `vfs_dup_fs_context()`로 만들고 `put_fs_context()`로 파괴합니다. 구조체 자체는 refcounted가 아닙니다. VFS·security·filesystem option은 `vfs_parse_mount_option()`으로 하나씩 설정하며 old `mount(2)`의 data page는 `generic_parse_monolithic()`으로 parse할 수 있습니다.

Mount 중 파일시스템은 context의 pointer가 가리키는 데이터를 superblock 등으로 가져갈 수 있지만 반드시 context의 해당 pointer를 clear해야 합니다. Context에 resource를 할당하고 pin할 수도 있습니다. 예를 들어 NFS는 적절한 protocol version module을 pin할 수 있습니다.

`fs_context::purpose`
의미
`FS_CONTEXT_FOR_MOUNT`명시적 mount용 새 superblock
`FS_CONTEXT_FOR_SUBMOUNT`기존 mount에서 파생된 automount
`FS_CONTEXT_FOR_RECONFIGURE`기존 mount 설정 변경

같은 context 구조체가 수행하는 세 종류 작업입니다.

Context resource 이전 규칙
context가 pointer·resource 보유`get_tree` 또는 reconfigure에서 대상에 이전이전한 context pointer를 NULL로 clear`put_fs_context()`가 남은 resource만 정리

Context에서 superblock으로 ownership을 옮길 때의 불변식입니다.

   * ::

       const struct cred *cred

     The mounter's credentials.  This retains a reference on the credentials.

   * ::

       char *source

     This specifies the source.  It may be a block device (e.g. /dev/sda1) or
     something more exotic, such as the "host:/path" that NFS desires.

   * ::

       char *subtype

     This is a string to be added to the type displayed in /proc/mounts to
     qualify it (used by FUSE).  This is available for the filesystem to set if
     desired.

   * ::

       void *security

     A place for the LSMs to hang their security data for the superblock.  The
     relevant security operations are described below.

   * ::

       void *s_fs_info

     The proposed s_fs_info for a new superblock, set in the superblock by
     sget_fc().  This can be used to distinguish superblocks.

   * ::

       unsigned int sb_flags
       unsigned int sb_flags_mask

     Which bits SB_* flags are to be set/cleared in super_block::s_flags.

   * ::

       unsigned int s_iflags

     These will be bitwise-OR'd with s->s_iflags when a superblock is created.

   * ::

       enum fs_context_purpose

     This indicates the purpose for which the context is intended.  The
     available values are:

        ==========================        ======================================
        FS_CONTEXT_FOR_MOUNT,                New superblock for explicit mount
        FS_CONTEXT_FOR_SUBMOUNT                New automatic submount of extant mount
        FS_CONTEXT_FOR_RECONFIGURE        Change an existing mount
        ==========================        ======================================

The mount context is created by calling vfs_new_fs_context() or
vfs_dup_fs_context() and is destroyed with put_fs_context().  Note that the
structure is not refcounted.

VFS, security and filesystem mount options are set individually with
vfs_parse_mount_option().  Options provided by the old mount(2) system call as
a page of data can be parsed with generic_parse_monolithic().

When mounting, the filesystem is allowed to take data from any of the pointers
and attach it to the superblock (or whatever), provided it clears the pointer
in the mount context.

The filesystem is also allowed to allocate resources and pin them with the
mount context.  For instance, NFS might pin the appropriate protocol version
module.


The Filesystem Context Operations

fs_context_operations의 free·dup·parse_param

207-260

`struct fs_context_operations`는 `free`, `dup`, `parse_param`, `parse_monolithic`, `get_tree`, `reconfigure` callback을 제공합니다. Mount procedure의 각 단계가 이 table을 호출하여 filesystem context를 관리합니다.

`free(fc)`는 context 파괴 시 filesystem-specific 부분을 정리합니다. `->get_tree()`가 일부 데이터를 떼어내고 pointer를 NULL로 만들었을 수 있으므로 부분적으로 비어 있는 context를 안전하게 처리해야 합니다.

`dup(fc, src_fc)`는 context 복제 시 filesystem-private data를 복제하며 실패하면 error를 반환할 수 있습니다. 실패 직후에도 `put_fs_context()`가 호출되므로 `->dup()`은 실패 경로에서도 새 context의 private data가 `->free()`에 안전한 상태가 되도록 만들어야 합니다.

`parse_param(fc, param)`은 parameter 하나를 context에 추가할 때 호출됩니다. `param`은 key name과 선택적 value object를 가리킵니다. VFS option과 security option은 미리 걸러져 각각 `fc->sb_flags`, `fc->security`가 갱신된 상태입니다.

Parameter는 `fs_parse()`와 `fs_lookup_param()`으로 parse할 수 있습니다. Source도 이름이 `source`인 parameter로 전달됩니다. 성공 시 0, 실패 시 negative error code를 반환합니다.

Context callback 정리
callback핵심 계약
`free`이전되어 NULL이 된 필드도 안전하게 정리
`dup`실패해도 즉시 `free` 가능한 상태 보장
`parse_param`VFS·LSM 처리 뒤 남은 parameter 소비

초기 세 callback의 책임과 실패 조건입니다.

=================================

The filesystem context points to a table of operations::

        struct fs_context_operations {
                void (*free)(struct fs_context *fc);
                int (*dup)(struct fs_context *fc, struct fs_context *src_fc);
                int (*parse_param)(struct fs_context *fc,
                                   struct fs_parameter *param);
                int (*parse_monolithic)(struct fs_context *fc, void *data);
                int (*get_tree)(struct fs_context *fc);
                int (*reconfigure)(struct fs_context *fc);
        };

These operations are invoked by the various stages of the mount procedure to
manage the filesystem context.  They are as follows:

   * ::

        void (*free)(struct fs_context *fc);

     Called to clean up the filesystem-specific part of the filesystem context
     when the context is destroyed.  It should be aware that parts of the
     context may have been removed and NULL'd out by ->get_tree().

   * ::

        int (*dup)(struct fs_context *fc, struct fs_context *src_fc);

     Called when a filesystem context has been duplicated to duplicate the
     filesystem-private data.  An error may be returned to indicate failure to
     do this.

     .. Warning::

         Note that even if this fails, put_fs_context() will be called
         immediately thereafter, so ->dup() *must* make the
         filesystem-private data safe for ->free().

   * ::

        int (*parse_param)(struct fs_context *fc,
                           struct fs_parameter *param);

     Called when a parameter is being added to the filesystem context.  param
     points to the key name and maybe a value object.  VFS-specific options
     will have been weeded out and fc->sb_flags updated in the context.
     Security options will also have been weeded out and fc->security updated.

     The parameter can be parsed with fs_parse() and fs_lookup_param().  Note
     that the source(s) are presented as parameters named "source".

     If successful, 0 should be returned or a negative error code otherwise.

monolithic parsing, get_tree, reconfigure

261-304

`parse_monolithic(fc, data)`는 `mount(2)`가 data page 전체를 한 번에 전달할 때 호출됩니다. 내용이 comma로 구분된 `key[=val]` 목록이라면 callback을 NULL로 둘 수 있습니다. 반환 규칙은 `->parse_param()`과 같습니다.

NFS처럼 먼저 data를 검사해야 하는 파일시스템도 결과가 표준 key-value 목록이면 `generic_parse_monolithic()`으로 넘길 수 있습니다.

`get_tree(fc)`는 context 정보를 사용해 mount 가능한 root와 superblock을 얻거나 생성합니다. 원하는 resource를 context에서 분리해 생성한 superblock으로 이전할 수 있습니다. 성공 시 `fc->root`를 mountable root로 설정하고 0을 반환하며 실패 시 negative error를 반환합니다. Userspace-driven context의 phase는 특정 context에서 한 번만 호출되도록 제한됩니다.

`reconfigure(fc)`는 context에 저장된 정보로 기존 superblock 설정을 변경합니다. Resource를 context에서 superblock으로 이전할 수 있고 대상 superblock은 `fc->root->d_sb`에서 찾습니다. 성공 시 0, 실패 시 negative error를 반환합니다. 이 callback은 `remount_fs`를 대체하기 위한 것입니다.

Tree 획득과 재설정 분기
parameter parsing 완료새 mount: `get_tree()``fc->root` 설정·resource 이전기존 mount: `reconfigure()``fc->root->d_sb`에 변경 적용

새 mount와 기존 superblock 변경은 서로 다른 callback을 사용합니다.

   * ::

        int (*parse_monolithic)(struct fs_context *fc, void *data);

     Called when the mount(2) system call is invoked to pass the entire data
     page in one go.  If this is expected to be just a list of "key[=val]"
     items separated by commas, then this may be set to NULL.

     The return value is as for ->parse_param().

     If the filesystem (e.g. NFS) needs to examine the data first and then
     finds it's the standard key-val list then it may pass it off to
     generic_parse_monolithic().

   * ::

        int (*get_tree)(struct fs_context *fc);

     Called to get or create the mountable root and superblock, using the
     information stored in the filesystem context (reconfiguration goes via a
     different vector).  It may detach any resources it desires from the
     filesystem context and transfer them to the superblock it creates.

     On success it should set fc->root to the mountable root and return 0.  In
     the case of an error, it should return a negative error code.

     The phase on a userspace-driven context will be set to only allow this to
     be called once on any particular context.

   * ::

        int (*reconfigure)(struct fs_context *fc);

     Called to effect reconfiguration of a superblock using information stored
     in the filesystem context.  It may detach any resources it desires from
     the filesystem context and transfer them to the superblock.  The
     superblock can be found from fc->root->d_sb.

     On success it should return 0.  In the case of an error, it should return
     a negative error code.

     .. Note:: reconfigure is intended as a replacement for remount_fs.

LSM context 생성·복제·parameter 처리

305-359

Filesystem context의 `security` pointer는 LSM이 mount할 superblock의 security context를 구성하는 데 사용합니다.

`security_fs_context_alloc(fc, reference)`는 NULL로 미리 설정된 `fc->security`를 초기화하고 필요한 resource를 할당합니다. 성공 시 0, 실패 시 negative error를 반환합니다. Reconfigure이면 `reference`는 대상 superblock의 root dentry이고, submount이면 automount point이므로 둘 다 non-NULL입니다.

`security_fs_context_dup(fc, src_fc)`도 새 context의 NULL security field를 초기화하고 resource를 할당하되 원본 `src_fc`를 참고할 수 있습니다. 성공 시 0, 실패 시 negative error입니다.

`security_fs_context_free(fc)`는 `fc->security`에 연결된 것을 정리합니다. `get_tree` 중 내용이 superblock으로 이전되고 pointer가 clear되었을 수 있음을 고려해야 합니다.

`security_fs_context_parse_param(fc, param)`은 source를 포함한 각 mount parameter마다 호출됩니다. 0은 parameter를 filesystem에 넘기라는 뜻이고, 1은 버리라는 뜻이며, error는 거부를 뜻합니다.

문자열 value는 수정할 수 있고 value pointer를 NULL로 만들면 훔쳐갈 수 있습니다. 훔쳤다면 filesystem에 전달되지 않도록 반드시 1을 반환해야 합니다.

Security parameter hook 반환값
반환동작
0filesystem `parse_param`에 전달
1LSM이 소비했으므로 폐기
negative errorparameter 거부
value 훔침pointer NULL + 반드시 1 반환

LSM이 parameter를 검사한 뒤 VFS에 지시하는 동작입니다.

Filesystem context Security
===========================

The filesystem context contains a security pointer that the LSMs can use for
building up a security context for the superblock to be mounted.  There are a
number of operations used by the new mount code for this purpose:

   * ::

        int security_fs_context_alloc(struct fs_context *fc,
                                      struct dentry *reference);

     Called to initialise fc->security (which is preset to NULL) and allocate
     any resources needed.  It should return 0 on success or a negative error
     code on failure.

     reference will be non-NULL if the context is being created for superblock
     reconfiguration (FS_CONTEXT_FOR_RECONFIGURE) in which case it indicates
     the root dentry of the superblock to be reconfigured.  It will also be
     non-NULL in the case of a submount (FS_CONTEXT_FOR_SUBMOUNT) in which case
     it indicates the automount point.

   * ::

        int security_fs_context_dup(struct fs_context *fc,
                                    struct fs_context *src_fc);

     Called to initialise fc->security (which is preset to NULL) and allocate
     any resources needed.  The original filesystem context is pointed to by
     src_fc and may be used for reference.  It should return 0 on success or a
     negative error code on failure.

   * ::

        void security_fs_context_free(struct fs_context *fc);

     Called to clean up anything attached to fc->security.  Note that the
     contents may have been transferred to a superblock and the pointer cleared
     during get_tree.

   * ::

        int security_fs_context_parse_param(struct fs_context *fc,
                                            struct fs_parameter *param);

     Called for each mount parameter, including the source.  The arguments are
     as for the ->parse_param() method.  It should return 0 to indicate that
     the parameter should be passed on to the filesystem, 1 to indicate that
     the parameter should be discarded or an error to indicate that the
     parameter should be rejected.

     The value pointed to by param may be modified (if a string) or stolen
     (provided the value pointer is NULL'd out).  If it is stolen, 1 must be
     returned to prevent it being passed to the filesystem.

Security validation과 superblock hook

360-398

`security_fs_context_validate(fc)`는 모든 option을 parse한 뒤 collection 전체를 검증하고 필요한 resource를 미리 할당합니다. 그러면 `security_sb_get_tree()`와 `security_sb_reconfigure()`가 실패할 가능성을 줄일 수 있습니다. 성공 시 0, 실패 시 negative error를 반환합니다. Reconfigure 대상은 `fc->root`로 접근할 수 있습니다.

`security_sb_get_tree(fc)`는 mount procedure에서 지정 superblock의 mount가 허용되는지 확인하고 security data를 그곳으로 이전합니다. 성공 시 0 또는 negative error를 반환합니다.

`security_sb_reconfigure(fc)`는 LSM context에 reconfiguration을 적용하며 실패해서는 안 됩니다. Error checking과 resource allocation은 parameter parsing·validation hook에서 미리 끝내야 합니다.

`security_sb_mountpoint(fc, mountpoint, mnt_flags)`는 context의 root dentry를 지정 mountpoint에 붙여도 되는지 검증합니다. 성공 시 0, 실패 시 negative error를 반환합니다.

LSM 검증 시점
parameter별 security parse전체 collection validate·resource 할당`security_sb_get_tree()`에서 mount 허가·이전reconfigure 적용은 실패 불가mountpoint attach 권한 검증

실패 가능한 준비를 먼저 끝내고 적용 단계는 실패하지 않게 만듭니다.

   * ::

        int security_fs_context_validate(struct fs_context *fc);

     Called after all the options have been parsed to validate the collection
     as a whole and to do any necessary allocation so that
     security_sb_get_tree() and security_sb_reconfigure() are less likely to
     fail.  It should return 0 or a negative error code.

     In the case of reconfiguration, the target superblock will be accessible
     via fc->root.

   * ::

        int security_sb_get_tree(struct fs_context *fc);

     Called during the mount procedure to verify that the specified superblock
     is allowed to be mounted and to transfer the security data there.  It
     should return 0 or a negative error code.

   * ::

        void security_sb_reconfigure(struct fs_context *fc);

     Called to apply any reconfiguration to an LSM's context.  It must not
     fail.  Error checking and resource allocation must be done in advance by
     the parameter parsing and validation hooks.

   * ::

        int security_sb_mountpoint(struct fs_context *fc,
                                   struct path *mountpoint,
                                   unsigned int mnt_flags);

     Called during the mount procedure to verify that the root dentry attached
     to the context is permitted to be attached to the specified mountpoint.
     It should return 0 on success or a negative error code on failure.

VFS context 생성·복제·파괴 API

399-475

VFS는 filesystem context 생성 operation 네 개와 파괴 operation 하나를 제공합니다.

`fs_context_for_mount(fs_type, sb_flags)`는 새 superblock을 만들거나 기존 것을 공유하는 새 mount context를 할당합니다. Superblock flag를 설정하고 security를 초기화하며 `fs_type->init_fs_context()`로 filesystem private data를 초기화합니다.

`fs_context_for_reconfigure(dentry, sb_flags, sb_flags_mask)`는 기존 superblock 재설정 context를 할당합니다. `dentry`가 대상 superblock reference이고 두 flag 인수가 어떤 superblock flag를 어떤 값으로 바꿀지 나타냅니다.

`fs_context_for_submount(fs_type, reference)`는 automount point 또는 다른 파생 superblock의 새 mount context를 할당합니다. Reference dentry가 parameter를 제공하고 그 superblock에서 namespace도 전달됩니다. Reference dentry의 filesystem type이 `fs_type`과 같을 필요는 없습니다.

`vfs_dup_fs_context(src_fc)`는 기록된 option을 복사하고 보유 resource를 복제하거나 reference를 추가합니다. NFS4가 target server root를 내부 mount한 뒤 target directory로 private pathwalk하는 것처럼 mount 안에서 mount가 필요한 경우에 사용합니다. 새 context의 purpose는 원본에서 상속됩니다.

`put_fs_context(fc)`는 resource를 해제하고 `->free()`를 호출하여 context를 파괴합니다. Context를 만든 모든 호출자가 사용해야 합니다. Filesystem context는 refcounted가 아니므로 이 호출은 조건 없이 파괴합니다.

`put`을 제외한 생성 API는 context pointer 또는 negative error code를 반환합니다. 이후 나오는 나머지 operation은 오류 시 negative error code를 반환합니다.

Filesystem context 생성 API
API목적·입력
`fs_context_for_mount`새 mount, `fs_type`·`sb_flags`
`fs_context_for_reconfigure`기존 superblock, reference dentry
`fs_context_for_submount`automount·derived superblock
`vfs_dup_fs_context`기존 option·resource 복제
`put_fs_context`무조건 파괴, refcount 없음

목적에 따라 선택할 생성 함수와 기준 객체입니다.

VFS Filesystem context API
==========================

There are four operations for creating a filesystem context and one for
destroying a context:

   * ::

       struct fs_context *fs_context_for_mount(struct file_system_type *fs_type,
                                               unsigned int sb_flags);

     Allocate a filesystem context for the purpose of setting up a new mount,
     whether that be with a new superblock or sharing an existing one.  This
     sets the superblock flags, initialises the security and calls
     fs_type->init_fs_context() to initialise the filesystem private data.

     fs_type specifies the filesystem type that will manage the context and
     sb_flags presets the superblock flags stored therein.

   * ::

       struct fs_context *fs_context_for_reconfigure(
                struct dentry *dentry,
                unsigned int sb_flags,
                unsigned int sb_flags_mask);

     Allocate a filesystem context for the purpose of reconfiguring an
     existing superblock.  dentry provides a reference to the superblock to be
     configured.  sb_flags and sb_flags_mask indicate which superblock flags
     need changing and to what.

   * ::

       struct fs_context *fs_context_for_submount(
                struct file_system_type *fs_type,
                struct dentry *reference);

     Allocate a filesystem context for the purpose of creating a new mount for
     an automount point or other derived superblock.  fs_type specifies the
     filesystem type that will manage the context and the reference dentry
     supplies the parameters.  Namespaces are propagated from the reference
     dentry's superblock also.

     Note that it's not a requirement that the reference dentry be of the same
     filesystem type as fs_type.

   * ::

        struct fs_context *vfs_dup_fs_context(struct fs_context *src_fc);

     Duplicate a filesystem context, copying any options noted and duplicating
     or additionally referencing any resources held therein.  This is available
     for use where a filesystem has to get a mount within a mount, such as NFS4
     does by internally mounting the root of the target server and then doing a
     private pathwalk to the target directory.

     The purpose in the new context is inherited from the old one.

   * ::

       void put_fs_context(struct fs_context *fc);

     Destroy a filesystem context, releasing any resources it holds.  This
     calls the ->free() operation.  This is intended to be called by anyone who
     created a filesystem context.

     .. Warning::

        filesystem contexts are not refcounted, so this causes unconditional
        destruction.

In all the above operations, apart from the put op, the return is a mount
context pointer or a negative error code.

For the remaining operations, if an error occurs, a negative error code will be
returned.

VFS parameter 전달과 mount object 생성

476-547

`vfs_parse_fs_param(fc, param)`은 mount parameter 하나를 context에 제공합니다. Device/source도 이름이 `source`인 parameter이며 파일시스템이 지원하면 여러 번 지정할 수 있습니다.

Parameter는 먼저 표준 mount flag인지 검사되어 해당하면 `SB_xxx` flag를 설정하고 소비됩니다. 다음으로 security option이면 LSM이 소비합니다. 두 경우가 아니면 filesystem으로 전달됩니다.

Value type은 값 없는 `fs_value_is_flag`, string, binary blob, filename과 dirfd, open `file *`로 구분됩니다. Value가 있으면 `param->{string,blob,name,file}` union에 저장됩니다. 함수가 pointer를 가져가고 clear할 수 있지만 그때부터 object 처분 책임도 넘겨받습니다.

`vfs_parse_fs_qstr()`과 `vfs_parse_fs_string()`은 전달받은 value string을 복사한 뒤 `vfs_parse_fs_param()`을 호출하는 wrapper입니다.

`generic_parse_monolithic(fc, data)`은 `sys_mount()` data page를 comma로 구분된 `key[=val]` text list로 가정해 parse하고 각 항목을 `vfs_mount_option()`에 넘깁니다. `->parse_monolithic()`이 NULL일 때 기본 동작입니다. 원문의 함수명 표기는 그대로 보존합니다.

`vfs_get_tree(fc)`는 context parameter로 superblock을 선택·설정하고 mountable root와 superblock을 얻거나 생성하며 `->get_tree()`를 호출합니다. `vfs_create_mount(fc)`는 context parameter로 mount를 만들지만 어디에도 attach하지는 않습니다.

Parameter 처리 우선순위
typed `fs_parameter` 입력표준 mount flag이면 VFS가 소비security option이면 LSM이 소비나머지를 filesystem callback에 전달`vfs_get_tree()` 후 detached mount 생성

하나의 parameter가 filesystem에 도달하기 전 거치는 필터입니다.

`fs_parameter` value type
typevalue
`fs_value_is_flag`값 없음
`fs_value_is_string``param->string`
`fs_value_is_blob``param->blob`
`fs_value_is_filename`filename + dirfd
`fs_value_is_file`open `file *`

Union에서 사용되는 필드와 외부 object 유형입니다.

   * ::

        int vfs_parse_fs_param(struct fs_context *fc,
                               struct fs_parameter *param);

     Supply a single mount parameter to the filesystem context.  This includes
     the specification of the source/device which is specified as the "source"
     parameter (which may be specified multiple times if the filesystem
     supports that).

     param specifies the parameter key name and the value.  The parameter is
     first checked to see if it corresponds to a standard mount flag (in which
     case it is used to set an SB_xxx flag and consumed) or a security option
     (in which case the LSM consumes it) before it is passed on to the
     filesystem.

     The parameter value is typed and can be one of:

        ====================                =============================
        fs_value_is_flag                Parameter not given a value
        fs_value_is_string                Value is a string
        fs_value_is_blob                Value is a binary blob
        fs_value_is_filename                Value is a filename* + dirfd
        fs_value_is_file                Value is an open file (file*)
        ====================                =============================

     If there is a value, that value is stored in a union in the struct in one
     of param->{string,blob,name,file}.  Note that the function may steal and
     clear the pointer, but then becomes responsible for disposing of the
     object.

   * ::

       int vfs_parse_fs_qstr(struct fs_context *fc, const char *key,
                               const struct qstr *value);

     A wrapper around vfs_parse_fs_param() that copies the value string it is
     passed.

   * ::

       int vfs_parse_fs_string(struct fs_context *fc, const char *key,
                               const char *value);

     A wrapper around vfs_parse_fs_param() that copies the value string it is
     passed.

   * ::

       int generic_parse_monolithic(struct fs_context *fc, void *data);

     Parse a sys_mount() data page, assuming the form to be a text list
     consisting of key[=val] options separated by commas.  Each item in the
     list is passed to vfs_mount_option().  This is the default when the
     ->parse_monolithic() method is NULL.

   * ::

       int vfs_get_tree(struct fs_context *fc);

     Get or create the mountable root and superblock, using the parameters in
     the filesystem context to select/configure the superblock.  This invokes
     the ->get_tree() method.

   * ::

       struct vfsmount *vfs_create_mount(struct fs_context *fc);

     Create a mount given the parameters in the specified filesystem context.
     Note that this does not attach the mount to anything.

sget_fc와 superblock 선택 helper

548-590

VFS는 파일시스템이 superblock을 생성하거나 검색할 때 쓸 helper를 제공합니다. Core routine인 `sget_fc(fc, test, set)`는 `test`가 non-NULL이면 context 조건과 맞는 기존 superblock을 `test` callback으로 검색합니다. Match가 없으면 새 superblock을 만들고 `set` callback으로 설정합니다.

`set` 호출 전에 `fc->s_fs_info`가 `sb->s_fs_info`로 이전됩니다. `set`이 성공, 즉 0을 반환하면 `fc->s_fs_info`가 clear됩니다.

`vfs_get_single_super`는 시스템에 해당 superblock이 하나만 존재하도록 하며 이후 요청은 parameter 차이를 무시하고 기존 것을 받습니다.

`vfs_get_keyed_super`는 같은 type의 superblock을 여러 개 허용하고 `s_fs_info` pointer를 key로 사용합니다. 예를 들어 namespace를 가리킬 수 있습니다. `vfs_get_independent_super`도 여러 개를 허용하지만 기존 항목과 절대 match하지 않고 항상 새 superblock을 만듭니다.

`sget_fc()` wrapper 선택
helper기존 항목 match 정책
`vfs_get_single_super`항상 유일한 기존 superblock 재사용
`vfs_get_keyed_super``s_fs_info` key가 같은 항목 재사용
`vfs_get_independent_super`match하지 않고 항상 새로 생성

Superblock identity 정책에 따라 helper를 고릅니다.

Superblock Creation Helpers
===========================

A number of VFS helpers are available for use by filesystems for the creation
or looking up of superblocks.

   * ::

       struct super_block *
       sget_fc(struct fs_context *fc,
               int (*test)(struct super_block *sb, struct fs_context *fc),
               int (*set)(struct super_block *sb, struct fs_context *fc));

     This is the core routine.  If test is non-NULL, it searches for an
     existing superblock matching the criteria held in the fs_context, using
     the test function to match them.  If no match is found, a new superblock
     is created and the set function is called to set it up.

     Prior to the set function being called, fc->s_fs_info will be transferred
     to sb->s_fs_info - and fc->s_fs_info will be cleared if set returns
     success (ie. 0).

The following helpers all wrap sget_fc():

        (1) vfs_get_single_super

            Only one such superblock may exist in the system.  Any further
            attempt to get a new superblock gets this one (and any parameter
            differences are ignored).

        (2) vfs_get_keyed_super

            Multiple superblocks of this type may exist and they're keyed on
            their s_fs_info pointer (for example this may refer to a
            namespace).

        (3) vfs_get_independent_super

            Multiple independent superblocks of this type may exist.  This
            function never matches an existing one and always creates a new
            one.

fs_parameter_description과 specification

591-639

Parameter는 `linux/fs_parser.h`에 정의된 구조체로 설명합니다. Core `struct fs_parameter_description`은 parameter specification table `specs`와 enum mapping table `enums`를 연결합니다. 원문은 AFS의 `Opt_autocell`, `Opt_bar`, `Opt_dyn`, `Opt_foo`, `Opt_source` 예를 보여줍니다.

NULL entry로 끝나는 `specs` table의 각 `struct fs_parameter_spec`에는 `name`, `opt`, `type`, `flags`가 있습니다.

`name`은 parameter key와 정확히 비교하는 문자열입니다. Wildcard·pattern·case-insensitive matching은 없습니다. `opt`는 match 성공 시 `fs_parser()`가 반환할 값입니다. `type`은 요구하는 value type을 나타내며 다음 구간 표의 상수 중 하나여야 합니다.

Parameter specification 필드
필드의미
`name`대소문자까지 정확히 일치할 key
`opt`성공 시 parser가 반환할 option ID
`type`기대 value type과 변환 방식
`flags`optional·negation·deprecated 한정자

Key matching에서 parse 결과 선택까지의 역할입니다.

Parameter Description
=====================

Parameters are described using structures defined in linux/fs_parser.h.
There's a core description struct that links everything together::

        struct fs_parameter_description {
                const struct fs_parameter_spec *specs;
                const struct fs_parameter_enum *enums;
        };

For example::

        enum {
                Opt_autocell,
                Opt_bar,
                Opt_dyn,
                Opt_foo,
                Opt_source,
        };

        static const struct fs_parameter_description afs_fs_parameters = {
                .specs                = afs_param_specs,
                .enums                = afs_param_enums,
        };

The members are as follows:

 (1) ::

       const struct fs_parameter_specification *specs;

     Table of parameter specifications, terminated with a null entry, where the
     entries are of type::

        struct fs_parameter_spec {
                const char                *name;
                u8                        opt;
                enum fs_parameter_type        type:8;
                unsigned short                flags;
        };

     The 'name' field is a string to match exactly to the parameter key (no
     wildcards, patterns and no case-independence) and 'opt' is the value that
     will be returned by the fs_parser() function in the case of a successful
     match.

     The 'type' field indicates the desired value type and must be one of:

Parameter type·flag·wrapper macro

640-708

`fs_param_is_flag`는 값이 없고 별도 결과도 없습니다. Boolean은 `result->boolean`, unsigned 32-bit·octal·hex는 `result->uint_32`, signed 32-bit는 `result->int_32`, unsigned 64-bit는 `result->uint_64`에 저장됩니다.

`fs_param_is_enum`은 enum 이름을 `result->uint_32`로 바꿉니다. Arbitrary string과 binary blob은 각각 `param->string`, `param->blob`에 남습니다. Block device path와 일반 path는 lookup이 필요합니다. File descriptor는 `result->int_32`, user ID와 group ID는 각각 `result->uid`, `result->gid`에 저장됩니다.

Boolean type이면 `fs_parse()`가 string value를 `0`, `1`, `no`, `yes`, `false`, `true`와 비교합니다.

Parameter flag로 `fs_param_v_optional`은 value가 선택 사항임을 나타냅니다. `fs_param_neg_with_no`는 key 앞에 `no`가 붙으면 `result->negated`를 설정하고, `fs_param_neg_with_empty`는 value가 빈 문자열이면 설정합니다. `fs_param_deprecated`는 폐기 예정 parameter입니다.

Convenience macro는 type과 flag 조합을 만듭니다. `fsparam_flag`, `fsparam_flag_no`, `fsparam_bool`, `fsparam_u32`, `fsparam_u32oct`, `fsparam_s32`, `fsparam_u64`, `fsparam_enum`, `fsparam_string`, `fsparam_blob`, `fsparam_bdev`, `fsparam_path`, `fsparam_fd`, `fsparam_uid`, `fsparam_gid`가 있습니다.

각 macro는 name string과 option number 두 인수를 받습니다. AFS 예에서는 `autocell`, `dyn`, `source`, negation을 허용하는 `foo`를 등록하고 빈 entry로 table을 끝냅니다. 표준 macro에 맞지 않는 경우 type과 flag 인수 한 쌍을 추가로 받는 `__fsparam()`을 사용합니다.

주요 parameter 변환 결과
type결과
bool`result->boolean`
u32·octal·hex`result->uint_32`
s32·fd`result->int_32`
u64`result->uint_64`
uid·gid`result->uid`·`result->gid`
string·blob`param->string`·`param->blob`

입력 type별 결과 저장 위치입니다.

        =======================        =======================        =====================
        TYPE NAME                EXPECTED VALUE                RESULT IN
        =======================        =======================        =====================
        fs_param_is_flag        No value                n/a
        fs_param_is_bool        Boolean value                result->boolean
        fs_param_is_u32                32-bit unsigned int        result->uint_32
        fs_param_is_u32_octal        32-bit octal int        result->uint_32
        fs_param_is_u32_hex        32-bit hex int                result->uint_32
        fs_param_is_s32                32-bit signed int        result->int_32
        fs_param_is_u64                64-bit unsigned int        result->uint_64
        fs_param_is_enum        Enum value name         result->uint_32
        fs_param_is_string        Arbitrary string        param->string
        fs_param_is_blob        Binary blob                param->blob
        fs_param_is_blockdev        Blockdev path                * Needs lookup
        fs_param_is_path        Path                        * Needs lookup
        fs_param_is_fd                File descriptor                result->int_32
        fs_param_is_uid                User ID (u32)           result->uid
        fs_param_is_gid                Group ID (u32)          result->gid
        =======================        =======================        =====================

     Note that if the value is of fs_param_is_bool type, fs_parse() will try
     to match any string value against "0", "1", "no", "yes", "false", "true".

     Each parameter can also be qualified with 'flags':

        =======================        ================================================
        fs_param_v_optional        The value is optional
        fs_param_neg_with_no        result->negated set if key is prefixed with "no"
        fs_param_neg_with_empty        result->negated set if value is ""
        fs_param_deprecated        The parameter is deprecated.
        =======================        ================================================

     These are wrapped with a number of convenience wrappers:

        =======================        ===============================================
        MACRO                        SPECIFIES
        =======================        ===============================================
        fsparam_flag()                fs_param_is_flag
        fsparam_flag_no()        fs_param_is_flag, fs_param_neg_with_no
        fsparam_bool()                fs_param_is_bool
        fsparam_u32()                fs_param_is_u32
        fsparam_u32oct()        fs_param_is_u32_octal
        fsparam_s32()                fs_param_is_s32
        fsparam_u64()                fs_param_is_u64
        fsparam_enum()                fs_param_is_enum
        fsparam_string()        fs_param_is_string
        fsparam_blob()                fs_param_is_blob
        fsparam_bdev()                fs_param_is_blockdev
        fsparam_path()                fs_param_is_path
        fsparam_fd()                fs_param_is_fd
        fsparam_uid()                fs_param_is_uid
        fsparam_gid()                fs_param_is_gid
        =======================        ===============================================

     all of which take two arguments, name string and option number - for
     example::

        static const struct fs_parameter_spec afs_param_specs[] = {
                fsparam_flag        ("autocell",        Opt_autocell),
                fsparam_flag        ("dyn",                Opt_dyn),
                fsparam_string        ("source",        Opt_source),
                fsparam_flag_no        ("foo",                Opt_foo),
                {}
        };

     An addition macro, __fsparam() is provided that takes an additional pair
     of arguments to specify the type and the flags for anything that doesn't
     match one of the above macros.

Enum mapping과 parser 등록 검증

709-740

`enums`는 enum value name을 integer로 mapping하며 NULL entry로 끝납니다. `struct fs_parameter_enum`은 option ID `opt`, 최대 길이가 구조체에 반영된 `name[14]`, mapping 결과 `value`를 가집니다.

Array는 `{ parameter ID, name }`을 key로 하는 정렬되지 않은 element 목록입니다. 원문 예는 `Opt_bar`의 `x`, `y`, `z`를 각각 1, 23, 42로 mapping합니다.

`fs_param_is_enum` parameter를 만나면 `fs_parse()`가 enum table에서 value를 찾고 parse result에 저장합니다.

Parameter description은 `file_system_type` 구조체의 parser pointer가 가리켜야 합니다. 그러면 `CONFIG_VALIDATE_FS_PARSER=y`일 때 등록 시 검증할 수 있고, userspace가 `fsinfo()` syscall로 description을 조회할 수 있습니다.

Enum parameter 해석
parameter ID와 문자열 value 입력정렬되지 않은 `fs_parameter_enum` table 탐색일치하는 `value` 선택parse result에 integer 저장등록 시 description 검증·userspace 조회

문자열 option 값을 정수 결과로 바꾸는 과정입니다.

 (2) ::

       const struct fs_parameter_enum *enums;

     Table of enum value names to integer mappings, terminated with a null
     entry.  This is of type::

        struct fs_parameter_enum {
                u8                opt;
                char                name[14];
                u8                value;
        };

     Where the array is an unsorted list of { parameter ID, name }-keyed
     elements that indicate the value to map to, e.g.::

        static const struct fs_parameter_enum afs_param_enums[] = {
                { Opt_bar,   "x",      1},
                { Opt_bar,   "y",      23},
                { Opt_bar,   "z",      42},
        };

     If a parameter of type fs_param_is_enum is encountered, fs_parse() will
     try to look the value up in the enum table and the result will be stored
     in the parse result.

The parser should be pointed to by the parser pointer in the file_system_type
struct as this will provide validation on registration (if
CONFIG_VALIDATE_FS_PARSER=y) and will allow the description to be queried from
userspace using the fsinfo() syscall.

Parameter lookup·검증·parse helper

741-811

Filesystem 또는 LSM이 전달받은 parameter를 처리하도록 여러 helper가 제공됩니다.

`lookup_constant(tbl, name, not_found)`는 name-to-integer mapping인 `struct constant_table` array에서 이름을 찾습니다. Match되면 해당 value, 아니면 `not_found` 값을 반환합니다.

`fs_validate_description(name, desc)`는 parameter description을 검증합니다. 유효하면 true, 아니면 false를 반환하고 실패 오류를 kernel log buffer에 기록합니다.

`fs_parse(fc, desc, param, result)`는 주 parameter interpreter입니다. Description에서 key name으로 parameter를 찾아 option number로 변환해 반환합니다. Type이 boolean, integer, enum, uid, gid이면 value도 변환하여 `result->{boolean,int_32,uint_32,uint_64,uid,gid}`에 저장합니다.

처음 match되지 않았고 key가 `no`로 시작하며 value가 없으면 prefix를 제거해 다시 찾습니다. Match한 parameter에 `fs_param_neg_with_no`가 설정되어 있으면 성공으로 처리하고 `result->negated`를 true로 만듭니다.

Parameter가 match되지 않으면 `-ENOPARAM`, match했지만 value가 잘못되면 `-EINVAL`, 그 밖에는 parameter option number를 반환합니다.

`fs_lookup_param(fc, value, want_bdev, flags, _path)`는 string 또는 filename parameter에 path lookup을 시도합니다. Block device를 요구하면 inode가 실제 blockdev인지 확인합니다. 성공하면 0과 설정된 `*_path`, 실패하면 negative error code를 반환합니다.

`fs_parse()` 반환 규칙
결과반환
key 불일치`-ENOPARAM`
key 일치, value 오류`-EINVAL`
정상 parseparameter option number
`no` prefix negationoption number + `result->negated=true`

Key match와 value 변환 결과를 구분합니다.

`fs_lookup_param()`
string 또는 filename valuepath lookup`want_bdev`이면 inode type 검사성공: `*_path` 설정과 0실패: negative error

문자열 parameter를 kernel path로 바꾸는 검증 흐름입니다.

Parameter Helper Functions
==========================

A number of helper functions are provided to help a filesystem or an LSM
process the parameters it is given.

   * ::

       int lookup_constant(const struct constant_table tbl[],
                           const char *name, int not_found);

     Look up a constant by name in a table of name -> integer mappings.  The
     table is an array of elements of the following type::

        struct constant_table {
                const char        *name;
                int                value;
        };

     If a match is found, the corresponding value is returned.  If a match
     isn't found, the not_found value is returned instead.

   * ::

       bool fs_validate_description(const char *name,
                                    const struct fs_parameter_description *desc);

     This performs some validation checks on a parameter description.  It
     returns true if the description is good and false if it is not.  It will
     log errors to the kernel log buffer if validation fails.

   * ::

        int fs_parse(struct fs_context *fc,
                     const struct fs_parameter_description *desc,
                     struct fs_parameter *param,
                     struct fs_parse_result *result);

     This is the main interpreter of parameters.  It uses the parameter
     description to look up a parameter by key name and to convert that to an
     option number (which it returns).

     If successful, and if the parameter type indicates the result is a
     boolean, integer, enum, uid, or gid type, the value is converted by this
     function and the result stored in
     result->{boolean,int_32,uint_32,uint_64,uid,gid}.

     If a match isn't initially made, the key is prefixed with "no" and no
     value is present then an attempt will be made to look up the key with the
     prefix removed.  If this matches a parameter for which the type has flag
     fs_param_neg_with_no set, then a match will be made and result->negated
     will be set to true.

     If the parameter isn't matched, -ENOPARAM will be returned; if the
     parameter is matched, but the value is erroneous, -EINVAL will be
     returned; otherwise the parameter's option number will be returned.

   * ::

       int fs_lookup_param(struct fs_context *fc,
                           struct fs_parameter *value,
                           bool want_bdev,
                           unsigned int flags,
                           struct path *_path);

     This takes a parameter that carries a string or filename type and attempts
     to do a path lookup on it.  If the parameter expects a blockdev, a check
     is made that the inode actually represents one.

     Returns 0 if successful and ``*_path`` will be set; returns a negative
     error code if not.