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