From 131f80fe4c8cd0b6a6b4247f8a29001591a2f3f3 Mon Sep 17 00:00:00 2001 From: Myzel394 <50424412+Myzel394@users.noreply.github.com> Date: Wed, 7 Aug 2024 22:56:48 +0200 Subject: [PATCH 1/3] Add more mount options to common-documentation/filesystems/mountoptions Related to #3 Add mount options for `devpts`, `fat`, `hfs`, and `hpfs` filesystems. * **common-documentation/filesystems/mountoptions/devpts.go** - Implement mount options for `devpts` filesystem. - Export `DevptsDocumentationAssignable` and `DevptsDocumentationEnums` variables. * **common-documentation/filesystems/mountoptions/fat.go** - Implement mount options for `fat` filesystem. - Export `FatDocumentationAssignable` and `FatDocumentationEnums` variables. * **common-documentation/filesystems/mountoptions/hfs.go** - Implement mount options for `hfs` filesystem. - Export `HfsDocumentationAssignable` and `HfsDocumentationEnums` variables. * **common-documentation/filesystems/mountoptions/hpfs.go** - Implement mount options for `hpfs` filesystem. - Export `HpfsDocumentationAssignable` and `HpfsDocumentationEnums` variables. * **handlers/fstab/documentation/documentation-mountoptions.go** - Add entries for `devpts`, `fat`, `hfs`, and `hpfs` filesystems in `MountOptionsMapField`. --- .../filesystems/mountoptions/devpts.go | 33 ++++ .../filesystems/mountoptions/fat.go | 150 ++++++++++++++++++ .../filesystems/mountoptions/hfs.go | 54 +++++++ .../filesystems/mountoptions/hpfs.go | 38 +++++ .../documentation-mountoptions.go | 16 ++ 5 files changed, 291 insertions(+) create mode 100644 common-documentation/filesystems/mountoptions/devpts.go create mode 100644 common-documentation/filesystems/mountoptions/fat.go create mode 100644 common-documentation/filesystems/mountoptions/hfs.go create mode 100644 common-documentation/filesystems/mountoptions/hpfs.go diff --git a/common-documentation/filesystems/mountoptions/devpts.go b/common-documentation/filesystems/mountoptions/devpts.go new file mode 100644 index 0000000..fb47dce --- /dev/null +++ b/common-documentation/filesystems/mountoptions/devpts.go @@ -0,0 +1,33 @@ +package commondocumentation + +import docvalues "config-lsp/doc-values" + +var DevptsDocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ + docvalues.CreateEnumStringWithDoc( + "uid", + "This sets the owner or the group of newly created pseudo terminals to the specified values. When nothing is specified, they will be set to the UID and GID of the creating process. For example, if there is a tty group with GID 5, then gid=5 will cause newly created pseudo terminals to belong to the tty group.", + ): docvalues.UIDValue{ + EnforceUsingExisting: true, + }, + docvalues.CreateEnumStringWithDoc( + "gid", + "This sets the owner or the group of newly created pseudo terminals to the specified values. When nothing is specified, they will be set to the UID and GID of the creating process. For example, if there is a tty group with GID 5, then gid=5 will cause newly created pseudo terminals to belong to the tty group.", + ): docvalues.GIDValue{ + EnforceUsingExisting: true, + }, + docvalues.CreateEnumStringWithDoc( + "mode", + "Set the mode of newly created pseudo terminals to the specified value. The default is 0600. A value of mode=620 and gid=5 makes \"mesg y\" the default on newly created pseudo terminals.", + ): docvalues.StringValue{}, + docvalues.CreateEnumStringWithDoc( + "ptmxmode", + "Set the mode for the new ptmx device node in the devpts filesystem. With the support for multiple instances of devpts (see newinstance option above), each instance has a private ptmx node in the root of the devpts filesystem (typically /dev/pts/ptmx). For compatibility with older versions of the kernel, the default mode of the new ptmx node is 0000. ptmxmode=value specifies a more useful mode for the ptmx node and is highly recommended when the newinstance option is specified. This option is only implemented in Linux kernel versions starting with 2.6.29. Further, this option is valid only if CONFIG_DEVPTS_MULTIPLE_INSTANCES is enabled in the kernel configuration.", + ): docvalues.StringValue{}, +} + +var DevptsDocumentationEnums = []docvalues.EnumString{ + docvalues.CreateEnumStringWithDoc( + "newinstance", + "Create a private instance of the devpts filesystem, such that indices of pseudo terminals allocated in this new instance are independent of indices created in other instances of devpts. All mounts of devpts without this newinstance option share the same set of pseudo terminal indices (i.e., legacy mode). Each mount of devpts with the newinstance option has a private set of pseudo terminal indices. This option is mainly used to support containers in the Linux kernel. It is implemented in Linux kernel versions starting with 2.6.29. Further, this mount option is valid only if CONFIG_DEVPTS_MULTIPLE_INSTANCES is enabled in the kernel configuration. To use this option effectively, /dev/ptmx must be a symbolic link to pts/ptmx. See Documentation/filesystems/devpts.txt in the Linux kernel source tree for details.", + ), +} diff --git a/common-documentation/filesystems/mountoptions/fat.go b/common-documentation/filesystems/mountoptions/fat.go new file mode 100644 index 0000000..fca6041 --- /dev/null +++ b/common-documentation/filesystems/mountoptions/fat.go @@ -0,0 +1,150 @@ +package commondocumentation + +import docvalues "config-lsp/doc-values" + +var FatDocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ + docvalues.CreateEnumStringWithDoc( + "blocksize", + "Set blocksize (default 512). This option is obsolete.", + ): docvalues.EnumValue{ + EnforceValues: true, + Values: []docvalues.EnumString{ + // TODO: Check for other values too + docvalues.CreateEnumString("512"), + docvalues.CreateEnumString("1024"), + docvalues.CreateEnumString("2048"), + }, + }, + docvalues.CreateEnumStringWithDoc( + "uid", + "Set the owner and group of all files. (Default: the UID and GID of the current process.)", + ): docvalues.UIDValue{ + EnforceUsingExisting: true, + }, + docvalues.CreateEnumStringWithDoc( + "gid", + "Set the owner and group of all files. (Default: the UID and GID of the current process.)", + ): docvalues.GIDValue{ + EnforceUsingExisting: true, + }, + docvalues.CreateEnumStringWithDoc( + "umask", + "Set the umask (the bitmask of the permissions that are not present). The default is the umask of the current process. The value is given in octal.", + ): docvalues.StringValue{}, + docvalues.CreateEnumStringWithDoc( + "dmask", + "Set the umask applied to directories only. The default is the umask of the current process. The value is given in octal.", + // TODO: Add mask + ): docvalues.StringValue{}, + docvalues.CreateEnumStringWithDoc( + "fmask", + "Set the umask applied to regular files only. The default is the umask of the current process. The value is given in octal.", + ): docvalues.StringValue{}, + docvalues.CreateEnumStringWithDoc( + "allow_utime", + "This option controls the permission check of mtime/atime.", + ): docvalues.StringValue{}, + docvalues.CreateEnumStringWithDoc( + "check", + "Three different levels of pickiness can be chosen: relaxed, normal, strict.", + ): docvalues.EnumValue{ + EnforceValues: true, + Values: []docvalues.EnumString{ + docvalues.CreateEnumString("relaxed"), + docvalues.CreateEnumString("normal"), + docvalues.CreateEnumString("strict"), + }, + }, + docvalues.CreateEnumStringWithDoc( + "codepage", + "Sets the codepage for converting to shortname characters on FAT and VFAT filesystems. By default, codepage 437 is used.", + // TODO: Check if NumberValue fits here + ): docvalues.StringValue{}, + docvalues.CreateEnumStringWithDoc( + "iocharset", + "Character set to use for converting between 8 bit characters and 16 bit Unicode characters. The default is iso8859-1. Long filenames are stored on disk in Unicode format.", + // TODO: Use enum for charsets + ): docvalues.StringValue{}, + docvalues.CreateEnumStringWithDoc( + "time_offset", + "Set offset for conversion of timestamps from local time used by FAT to UTC. I.e., minutes will be subtracted from each timestamp to convert it to UTC used internally by Linux. This is useful when the time zone set in the kernel via settimeofday(2) is not the time zone used by the filesystem. Note that this option still does not provide correct time stamps in all cases in presence of DST - time stamps in a different DST setting will be off by one hour.", + // TODO: Probably NumberValeu + ): docvalues.NumberValue{}, +} + +var FatDocumentationEnums = []docvalues.EnumString{ + docvalues.CreateEnumStringWithDoc( + // TODO: Show warning in analyzevalue when used + "conv", + "This option is obsolete and may fail or be ignored.", + ), + docvalues.CreateEnumStringWithDoc( + "cvf_format", + "Forces the driver to use the CVF (Compressed Volume File) module cvf_module instead of auto-detection. If the kernel supports kmod, the cvf_format=xxx option also controls on-demand CVF module loading. This option is obsolete.", + ), + docvalues.CreateEnumStringWithDoc( + "cvf_option", + "Option passed to the CVF module. This option is obsolete.", + ), + docvalues.CreateEnumStringWithDoc( + "debug", + "Turn on the debug flag. A version string and a list of filesystem parameters will be printed (these data are also printed if the parameters appear to be inconsistent).", + ), + docvalues.CreateEnumStringWithDoc( + "discard", + "If set, causes discard/TRIM commands to be issued to the block device when blocks are freed. This is useful for SSD devices and sparse/thinly-provisioned LUNs.", + ), + docvalues.CreateEnumStringWithDoc( + "dos1xfloppy", + "If set, use a fallback default BIOS Parameter Block configuration, determined by backing device size. These static parameters match defaults assumed by DOS 1.x for 160 kiB, 180 kiB, 320 kiB, and 360 kiB floppies and floppy images.", + ), + // TODO: Should be in map + docvalues.CreateEnumStringWithDoc( + "errors", + "Specify FAT behavior on critical errors: panic, continue without doing anything, or remount the partition in read-only mode (default behavior).", + ), + docvalues.CreateEnumStringWithDoc( + "fat", + "Specify a 12, 16 or 32 bit fat. This overrides the automatic FAT type detection routine. Use with caution!", + ), + docvalues.CreateEnumStringWithDoc( + "nfs", + "Enable this only if you want to export the FAT filesystem over NFS.", + ), + docvalues.CreateEnumStringWithDoc( + "quiet", + "Turn on the quiet flag. Attempts to chown or chmod files do not return errors, although they fail. Use with caution!", + ), + docvalues.CreateEnumStringWithDoc( + "rodir", + "FAT has the ATTR_RO (read-only) attribute. On Windows, the ATTR_RO of the directory will just be ignored, and is used only by applications as a flag (e.g. it’s set for the customized folder). If you want to use ATTR_RO as read-only flag even for the directory, set this option.", + ), + docvalues.CreateEnumStringWithDoc( + "showexec", + "If set, the execute permission bits of the file will be allowed only if the extension part of the name is .EXE, .COM, or .BAT. Not set by default.", + ), + docvalues.CreateEnumStringWithDoc( + "sys_immutable", + "If set, ATTR_SYS attribute on FAT is handled as IMMUTABLE flag on Linux. Not set by default.", + ), + docvalues.CreateEnumStringWithDoc( + "flush", + "If set, the filesystem will try to flush to disk more early than normal. Not set by default.", + ), + docvalues.CreateEnumStringWithDoc( + "usefree", + "Use the \"free clusters\" value stored on FSINFO. It’ll be used to determine number of free clusters without scanning disk. But it’s not used by default, because recent Windows don’t update it correctly in some case. If you are sure the \"free clusters\" on FSINFO is correct, by this option you can avoid scanning disk.", + ), + docvalues.CreateEnumStringWithDoc( + "dots", + "Various misguided attempts to force Unix or DOS conventions onto a FAT filesystem.", + ), + docvalues.CreateEnumStringWithDoc( + "nodots", + "Various misguided attempts to force Unix or DOS conventions onto a FAT filesystem.", + ), + docvalues.CreateEnumStringWithDoc( + "dotsOK", + "Various misguided attempts to force Unix or DOS conventions onto a FAT filesystem.", + ), +} diff --git a/common-documentation/filesystems/mountoptions/hfs.go b/common-documentation/filesystems/mountoptions/hfs.go new file mode 100644 index 0000000..602d8dc --- /dev/null +++ b/common-documentation/filesystems/mountoptions/hfs.go @@ -0,0 +1,54 @@ +package commondocumentation + +import docvalues "config-lsp/doc-values" + +var HfsDocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ + docvalues.CreateEnumStringWithDoc( + "creator", + "Set the creator/type values as shown by the MacOS finder used for creating new files. Default values: '????'.", + ): docvalues.StringValue{}, + docvalues.CreateEnumStringWithDoc( + "type", + "Set the creator/type values as shown by the MacOS finder used for creating new files. Default values: '????'.", + ): docvalues.StringValue{}, + docvalues.CreateEnumStringWithDoc( + "uid", + "Set the owner and group of all files. (Default: the UID and GID of the current process.)", + ): docvalues.UIDValue{ + EnforceUsingExisting: true, + }, + docvalues.CreateEnumStringWithDoc( + "gid", + "Set the owner and group of all files. (Default: the UID and GID of the current process.)", + ): docvalues.GIDValue{ + EnforceUsingExisting: true, + }, + docvalues.CreateEnumStringWithDoc( + "dir_umask", + "Set the umask used for all directories. Defaults to the umask of the current process.", + ): docvalues.StringValue{}, + docvalues.CreateEnumStringWithDoc( + "file_umask", + "Set the umask used for all regular files. Defaults to the umask of the current process.", + ): docvalues.StringValue{}, + docvalues.CreateEnumStringWithDoc( + "umask", + "Set the umask used for all files and directories. Defaults to the umask of the current process.", + ): docvalues.StringValue{}, + docvalues.CreateEnumStringWithDoc( + "session", + "Select the CDROM session to mount. Defaults to leaving that decision to the CDROM driver. This option will fail with anything but a CDROM as underlying device.", + ): docvalues.StringValue{}, + docvalues.CreateEnumStringWithDoc( + "part", + "Select partition number n from the device. Only makes sense for CDROMs. Defaults to not parsing the partition table at all.", + // TODO: Probably NumberValue + ): docvalues.StringValue{}, +} + +var HfsDocumentationEnums = []docvalues.EnumString{ + docvalues.CreateEnumStringWithDoc( + "quiet", + "Don't complain about invalid mount options.", + ), +} diff --git a/common-documentation/filesystems/mountoptions/hpfs.go b/common-documentation/filesystems/mountoptions/hpfs.go new file mode 100644 index 0000000..21b77a0 --- /dev/null +++ b/common-documentation/filesystems/mountoptions/hpfs.go @@ -0,0 +1,38 @@ +package commondocumentation + +import docvalues "config-lsp/doc-values" + +var HpfsDocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ + docvalues.CreateEnumStringWithDoc( + "uid", + "Set the owner and group of all files. (Default: the UID and GID of the current process.)", + ): docvalues.UIDValue{ + EnforceUsingExisting: true, + }, + docvalues.CreateEnumStringWithDoc( + "gid", + "Set the owner and group of all files. (Default: the UID and GID of the current process.)", + ): docvalues.GIDValue{ + EnforceUsingExisting: true, + }, + docvalues.CreateEnumStringWithDoc( + "umask", + "Set the umask (the bitmask of the permissions that are not present). The default is the umask of the current process. The value is given in octal.", + ): docvalues.StringValue{}, +} + +var HpfsDocumentationEnums = []docvalues.EnumString{ + // Move up to map + docvalues.CreateEnumStringWithDoc( + "case", + "Convert all files names to lower case, or leave them. (Default: case=lower.)", + ), + docvalues.CreateEnumStringWithDoc( + "conv", + "This option is obsolete and may fail or being ignored.", + ), + docvalues.CreateEnumStringWithDoc( + "nocheck", + "Do not abort mounting when certain consistency checks fail.", + ), +} diff --git a/handlers/fstab/documentation/documentation-mountoptions.go b/handlers/fstab/documentation/documentation-mountoptions.go index cc17c9d..e40556b 100644 --- a/handlers/fstab/documentation/documentation-mountoptions.go +++ b/handlers/fstab/documentation/documentation-mountoptions.go @@ -269,4 +269,20 @@ var MountOptionsMapField = map[string]docvalues.Value{ append(append(commondocumentation.Ext2DocumentationEnums, commondocumentation.Ext3DocumentationEnums...), commondocumentation.Ext4DocumentationEnums...), docvalues.MergeKeyEnumAssignmentMaps(commondocumentation.Ext2DocumentationAssignable, docvalues.MergeKeyEnumAssignmentMaps(commondocumentation.Ext3DocumentationAssignable, commondocumentation.Ext4DocumentationAssignable)), ), + "devpts": createMountOptionField( + commondocumentation.DevptsDocumentationEnums, + commondocumentation.DevptsDocumentationAssignable, + ), + "fat": createMountOptionField( + commondocumentation.FatDocumentationEnums, + commondocumentation.FatDocumentationAssignable, + ), + "hfs": createMountOptionField( + commondocumentation.HfsDocumentationEnums, + commondocumentation.HfsDocumentationAssignable, + ), + "hpfs": createMountOptionField( + commondocumentation.HpfsDocumentationEnums, + commondocumentation.HpfsDocumentationAssignable, + ), } From fc97837af6c45f7d4e5a42c08b3fd8164c1a4f54 Mon Sep 17 00:00:00 2001 From: Myzel394 <50424412+Myzel394@users.noreply.github.com> Date: Thu, 8 Aug 2024 21:42:44 +0200 Subject: [PATCH 2/3] feat(docvalues): Add mask values --- doc-values/value-mask-mode.go | 123 ++++++++++++++++++++++++++++++++++ doc-values/value-umask.go | 112 +++++++++++++++++++++++++++++++ 2 files changed, 235 insertions(+) create mode 100644 doc-values/value-mask-mode.go create mode 100644 doc-values/value-umask.go diff --git a/doc-values/value-mask-mode.go b/doc-values/value-mask-mode.go new file mode 100644 index 0000000..945ffc8 --- /dev/null +++ b/doc-values/value-mask-mode.go @@ -0,0 +1,123 @@ +package docvalues + +import ( + protocol "github.com/tliron/glsp/protocol_3_16" + "regexp" +) + +type MaskModeInvalidError struct{} + +func (e MaskModeInvalidError) Error() string { + return "This mask is not valid. It must be a 4-digit octal number." +} + +type MaskModeValue struct{} + +func (v MaskModeValue) GetTypeDescription() []string { + return []string{ + "File mode mask", + "4-digit octal number", + "Example: 0000", + "1st digit: setuid, setgid, sticky", + "2nd digit: user permissions", + "3rd digit: group permissions", + "4th digit: other permissions", + } +} + +var maskModePattern = regexp.MustCompile("^[0-7]{4}$") + +func (v MaskModeValue) CheckIsValid(value string) []*InvalidValue { + if !maskModePattern.MatchString(value) { + return []*InvalidValue{{ + Err: MaskModeInvalidError{}, + Start: 0, + End: uint32(len(value)), + }} + } + + return []*InvalidValue{} +} + +func (v MaskModeValue) FetchCompletions(line string, cursor uint32) []protocol.CompletionItem { + kind := protocol.CompletionItemKindValue + + perm0644 := "0644" + perm0755 := "0755" + perm0777 := "0777" + perm0400 := "0400" + perm0600 := "0600" + perm0666 := "0666" + perm0700 := "0700" + perm0444 := "0444" + perm0111 := "0111" + perm0555 := "0555" + + return []protocol.CompletionItem{ + { + Label: "0000", + Documentation: "No permissions", + Kind: &kind, + }, + { + Label: "0644 (-rw-r--r--)", + InsertText: &perm0644, + Documentation: "Read/write for owner, read for others", + Kind: &kind, + }, + { + Label: "0755 (-rwxr-xr-x)", + InsertText: &perm0755, + Documentation: "Read/write/execute for owner, read/execute for others", + Kind: &kind, + }, + { + Label: "0777 (-rwxrwxrwx)", + InsertText: &perm0777, + Documentation: "Read/write/execute for all", + Kind: &kind, + }, + { + Label: "0400 (-r--------)", + InsertText: &perm0400, + Documentation: "Read for owner", + Kind: &kind, + }, + { + Label: "0600 (-rw-------)", + InsertText: &perm0600, + Documentation: "Read/write for owner", + Kind: &kind, + }, + { + Label: "0666 (-rw-rw-rw-)", + InsertText: &perm0666, + Documentation: "Read/write for all", + Kind: &kind, + }, + { + Label: "0700 (-rwx------)", + InsertText: &perm0700, + Documentation: "Read/write/execute for owner", + Kind: &kind, + }, + { + Label: "0444 (-r--r--r--)", + InsertText: &perm0444, + Documentation: "Read for all", + Kind: &kind, + }, + { + Label: "0111 (-x--x--x)", + InsertText: &perm0111, + Documentation: "Execute for all", + Kind: &kind, + }, + { + Label: "0555 (-r-xr-xr-x)", + InsertText: &perm0555, + Documentation: "Read/execute for all", + Kind: &kind, + }, + } +} diff --git a/doc-values/value-umask.go b/doc-values/value-umask.go new file mode 100644 index 0000000..ed4b54a --- /dev/null +++ b/doc-values/value-umask.go @@ -0,0 +1,112 @@ +package docvalues + +import ( + "regexp" + + protocol "github.com/tliron/glsp/protocol_3_16" +) + +type UmaskInvalidError struct{} + +func (e UmaskInvalidError) Error() string { + return "This mask is not valid. It must be a 4-digit octal number." +} + +type UmaskValue struct{} + +func (v UmaskValue) GetTypeDescription() []string { + return []string{ + "File mode mask", + "4-digit octal number", + "Example: 0000", + "1st digit: setuid, setgid, sticky", + "2nd digit: user permissions", + "3rd digit: group permissions", + "4th digit: other permissions", + } +} + +var umaskPattern = regexp.MustCompile("^[0-7]{4}$") + +func (v UmaskValue) CheckIsValid(value string) []*InvalidValue { + if !umaskPattern.MatchString(value) { + return []*InvalidValue{{ + Err: UmaskInvalidError{}, + Start: 0, + End: uint32(len(value)), + }} + } + + return []*InvalidValue{} +} + +func (v UmaskValue) FetchCompletions(line string, cursor uint32) []protocol.CompletionItem { + kind := protocol.CompletionItemKindValue + + return []protocol.CompletionItem{ + { + Label: "0000", + Documentation: "Files: rwxrwxrwx Directories: rwxrwxrwx", + Kind: &kind, + }, + { + Label: "0022", + Documentation: "Files: rwxr-xr-x Directories: rwxr-xr-x", + Kind: &kind, + }, + { + Label: "0077", + Documentation: "Files: rwx------ Directories: rwx------", + Kind: &kind, + }, + { + Label: "0177", + Documentation: "Files: rw------- Directories: rw-------", + Kind: &kind, + }, + { + Label: "0277", + Documentation: "Files: r-x------ Directories: r-x------", + }, + { + Label: "0027", + Documentation: "Files: rwxr-x--- Directories: rwxr-x---", + Kind: &kind, + }, + { + Label: "0070", + Documentation: "Files: rwx---rwx Directories: rwx---rwx", + Kind: &kind, + }, + { + Label: "0222", + Documentation: "Files: r--r--r-- Directories: r--r--r--", + Kind: &kind, + }, + { + Label: "0333", + Documentation: "Files: r--r--r-- Directories: r--r--r--", + Kind: &kind, + }, + { + Label: "0444", + Documentation: "Files: r--r--r-- Directories: r--r--r--", + Kind: &kind, + }, + { + Label: "0555", + Documentation: "Files: r-xr-xr-x Directories: r-xr-xr-x", + Kind: &kind, + }, + { + Label: "0666", + Documentation: "Files: rw-rw-rw- Directories: rw-rw-rw-", + Kind: &kind, + }, + { + Label: "0777", + Documentation: "Files: rwxrwxrwx Directories: rwxrwxrwx", + Kind: &kind, + }, + } +} From 83782a95ead0dc7225da1033f38708e5c4813008 Mon Sep 17 00:00:00 2001 From: Myzel394 <50424412+Myzel394@users.noreply.github.com> Date: Thu, 8 Aug 2024 21:42:56 +0200 Subject: [PATCH 3/3] chore(common-documentation): Add more documentation --- .../filesystems/mountoptions/debugfs.go | 2 +- .../filesystems/mountoptions/devpts.go | 4 +- .../filesystems/mountoptions/fat.go | 118 ++++++++++++------ .../filesystems/mountoptions/hfs.go | 9 +- .../filesystems/mountoptions/hpfs.go | 24 ++-- 5 files changed, 102 insertions(+), 55 deletions(-) diff --git a/common-documentation/filesystems/mountoptions/debugfs.go b/common-documentation/filesystems/mountoptions/debugfs.go index c425e8f..8d5ae63 100644 --- a/common-documentation/filesystems/mountoptions/debugfs.go +++ b/common-documentation/filesystems/mountoptions/debugfs.go @@ -18,7 +18,7 @@ var DebugfsDocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ docvalues.CreateEnumStringWithDoc( "mode", "Sets the mode of the mountpoint.", - ): docvalues.StringValue{}, + ): docvalues.MaskModeValue{}, } var DebugfsDocumentationEnums = []docvalues.EnumString{} diff --git a/common-documentation/filesystems/mountoptions/devpts.go b/common-documentation/filesystems/mountoptions/devpts.go index fb47dce..e2484b5 100644 --- a/common-documentation/filesystems/mountoptions/devpts.go +++ b/common-documentation/filesystems/mountoptions/devpts.go @@ -18,11 +18,11 @@ var DevptsDocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ docvalues.CreateEnumStringWithDoc( "mode", "Set the mode of newly created pseudo terminals to the specified value. The default is 0600. A value of mode=620 and gid=5 makes \"mesg y\" the default on newly created pseudo terminals.", - ): docvalues.StringValue{}, + ): docvalues.MaskModeValue{}, docvalues.CreateEnumStringWithDoc( "ptmxmode", "Set the mode for the new ptmx device node in the devpts filesystem. With the support for multiple instances of devpts (see newinstance option above), each instance has a private ptmx node in the root of the devpts filesystem (typically /dev/pts/ptmx). For compatibility with older versions of the kernel, the default mode of the new ptmx node is 0000. ptmxmode=value specifies a more useful mode for the ptmx node and is highly recommended when the newinstance option is specified. This option is only implemented in Linux kernel versions starting with 2.6.29. Further, this option is valid only if CONFIG_DEVPTS_MULTIPLE_INSTANCES is enabled in the kernel configuration.", - ): docvalues.StringValue{}, + ): docvalues.MaskModeValue{}, } var DevptsDocumentationEnums = []docvalues.EnumString{ diff --git a/common-documentation/filesystems/mountoptions/fat.go b/common-documentation/filesystems/mountoptions/fat.go index fca6041..19936c4 100644 --- a/common-documentation/filesystems/mountoptions/fat.go +++ b/common-documentation/filesystems/mountoptions/fat.go @@ -9,7 +9,6 @@ var FatDocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ ): docvalues.EnumValue{ EnforceValues: true, Values: []docvalues.EnumString{ - // TODO: Check for other values too docvalues.CreateEnumString("512"), docvalues.CreateEnumString("1024"), docvalues.CreateEnumString("2048"), @@ -30,20 +29,19 @@ var FatDocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ docvalues.CreateEnumStringWithDoc( "umask", "Set the umask (the bitmask of the permissions that are not present). The default is the umask of the current process. The value is given in octal.", - ): docvalues.StringValue{}, + ): docvalues.UmaskValue{}, docvalues.CreateEnumStringWithDoc( "dmask", "Set the umask applied to directories only. The default is the umask of the current process. The value is given in octal.", - // TODO: Add mask - ): docvalues.StringValue{}, + ): docvalues.UmaskValue{}, docvalues.CreateEnumStringWithDoc( "fmask", "Set the umask applied to regular files only. The default is the umask of the current process. The value is given in octal.", - ): docvalues.StringValue{}, + ): docvalues.UmaskValue{}, docvalues.CreateEnumStringWithDoc( "allow_utime", "This option controls the permission check of mtime/atime.", - ): docvalues.StringValue{}, + ): docvalues.UmaskValue{}, docvalues.CreateEnumStringWithDoc( "check", "Three different levels of pickiness can be chosen: relaxed, normal, strict.", @@ -58,34 +56,95 @@ var FatDocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ docvalues.CreateEnumStringWithDoc( "codepage", "Sets the codepage for converting to shortname characters on FAT and VFAT filesystems. By default, codepage 437 is used.", - // TODO: Check if NumberValue fits here + ): docvalues.NumberValue{Min: &zero}, + docvalues.CreateEnumStringWithDoc( + // TODO: Show warning in analyzevalue when used + "conv", + "This option is obsolete and may fail or be ignored.", ): docvalues.StringValue{}, + docvalues.CreateEnumStringWithDoc( + "cvf_format", + "Forces the driver to use the CVF (Compressed Volume File) module cvf_module instead of auto-detection. If the kernel supports kmod, the cvf_format=xxx option also controls on-demand CVF module loading. This option is obsolete.", + ): docvalues.StringValue{}, + docvalues.CreateEnumStringWithDoc( + "cvf_option", + "Option passed to the CVF module. This option is obsolete.", + ): docvalues.StringValue{}, + docvalues.CreateEnumStringWithDoc( + "errors", + "Specify FAT behavior on critical errors: panic, continue without doing anything, or remount the partition in read-only mode (default behavior).", + ): docvalues.EnumValue{ + EnforceValues: true, + Values: []docvalues.EnumString{ + docvalues.CreateEnumStringWithDoc( + "panic", + "Causes the kernel to panic on errors.", + ), + docvalues.CreateEnumStringWithDoc( + "continue", + "Continues without doing anything.", + ), + docvalues.CreateEnumStringWithDoc( + "remount", + "Remounts the partition in read-only mode.", + ), + }, + }, + docvalues.CreateEnumStringWithDoc( + "fat", + "Specify a 12, 16 or 32 bit fat. This overrides the automatic FAT type detection routine. Use with caution!", + ): docvalues.EnumValue{ + EnforceValues: true, + Values: []docvalues.EnumString{ + docvalues.CreateEnumString("12"), + docvalues.CreateEnumString("16"), + docvalues.CreateEnumString("32"), + }, + }, docvalues.CreateEnumStringWithDoc( "iocharset", "Character set to use for converting between 8 bit characters and 16 bit Unicode characters. The default is iso8859-1. Long filenames are stored on disk in Unicode format.", // TODO: Use enum for charsets ): docvalues.StringValue{}, + docvalues.CreateEnumStringWithDoc( + "nfs", + `Enable this only if you want to export the FAT filesystem over NFS. + To maintain backward compatibility, -o nfs is also accepted, defaulting to stale_rw`, + ): docvalues.EnumValue{ + EnforceValues: true, + Values: []docvalues.EnumString{ + docvalues.CreateEnumStringWithDoc( + "stale_rw", + "This option maintains an index (cache) of directory inodes which is used by the nfs-related code to improve look-ups. Full file operations (read/write) over NFS are supported but with cache eviction at NFS server, this could result in spurious ESTALE errors.", + ), + docvalues.CreateEnumStringWithDoc( + "nostale_ro", + "This option bases the inode number and file handle on the on-disk location of a file in the FAT directory entry. This ensures that ESTALE will not be returned after a file is evicted from the inode cache. However, it means that operations such as rename, create and unlink could cause file handles that previously pointed at one file to point at a different file, potentially causing data corruption. For this reason, this option also mounts the filesystem readonly.", + ), + }, + }, + docvalues.CreateEnumStringWithDoc( + "tz", + "This option disables the conversion of timestamps between local time (as used by Windows on FAT) and UTC (which Linux uses internally). This is particularly useful when mounting devices (like digital cameras) that are set to UTC in order to avoid the pitfalls of local time.", + // TODO: Add enum for timezones + ): docvalues.StringValue{}, docvalues.CreateEnumStringWithDoc( "time_offset", "Set offset for conversion of timestamps from local time used by FAT to UTC. I.e., minutes will be subtracted from each timestamp to convert it to UTC used internally by Linux. This is useful when the time zone set in the kernel via settimeofday(2) is not the time zone used by the filesystem. Note that this option still does not provide correct time stamps in all cases in presence of DST - time stamps in a different DST setting will be off by one hour.", - // TODO: Probably NumberValeu ): docvalues.NumberValue{}, + docvalues.CreateEnumStringWithDoc( + "dotsOK", + "Various misguided attempts to force Unix or DOS conventions onto a FAT filesystem.", + ): docvalues.EnumValue{ + EnforceValues: true, + Values: []docvalues.EnumString{ + docvalues.CreateEnumString("yes"), + docvalues.CreateEnumString("no"), + }, + }, } var FatDocumentationEnums = []docvalues.EnumString{ - docvalues.CreateEnumStringWithDoc( - // TODO: Show warning in analyzevalue when used - "conv", - "This option is obsolete and may fail or be ignored.", - ), - docvalues.CreateEnumStringWithDoc( - "cvf_format", - "Forces the driver to use the CVF (Compressed Volume File) module cvf_module instead of auto-detection. If the kernel supports kmod, the cvf_format=xxx option also controls on-demand CVF module loading. This option is obsolete.", - ), - docvalues.CreateEnumStringWithDoc( - "cvf_option", - "Option passed to the CVF module. This option is obsolete.", - ), docvalues.CreateEnumStringWithDoc( "debug", "Turn on the debug flag. A version string and a list of filesystem parameters will be printed (these data are also printed if the parameters appear to be inconsistent).", @@ -98,19 +157,6 @@ var FatDocumentationEnums = []docvalues.EnumString{ "dos1xfloppy", "If set, use a fallback default BIOS Parameter Block configuration, determined by backing device size. These static parameters match defaults assumed by DOS 1.x for 160 kiB, 180 kiB, 320 kiB, and 360 kiB floppies and floppy images.", ), - // TODO: Should be in map - docvalues.CreateEnumStringWithDoc( - "errors", - "Specify FAT behavior on critical errors: panic, continue without doing anything, or remount the partition in read-only mode (default behavior).", - ), - docvalues.CreateEnumStringWithDoc( - "fat", - "Specify a 12, 16 or 32 bit fat. This overrides the automatic FAT type detection routine. Use with caution!", - ), - docvalues.CreateEnumStringWithDoc( - "nfs", - "Enable this only if you want to export the FAT filesystem over NFS.", - ), docvalues.CreateEnumStringWithDoc( "quiet", "Turn on the quiet flag. Attempts to chown or chmod files do not return errors, although they fail. Use with caution!", @@ -143,8 +189,4 @@ var FatDocumentationEnums = []docvalues.EnumString{ "nodots", "Various misguided attempts to force Unix or DOS conventions onto a FAT filesystem.", ), - docvalues.CreateEnumStringWithDoc( - "dotsOK", - "Various misguided attempts to force Unix or DOS conventions onto a FAT filesystem.", - ), } diff --git a/common-documentation/filesystems/mountoptions/hfs.go b/common-documentation/filesystems/mountoptions/hfs.go index 602d8dc..c3d77e5 100644 --- a/common-documentation/filesystems/mountoptions/hfs.go +++ b/common-documentation/filesystems/mountoptions/hfs.go @@ -26,15 +26,15 @@ var HfsDocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ docvalues.CreateEnumStringWithDoc( "dir_umask", "Set the umask used for all directories. Defaults to the umask of the current process.", - ): docvalues.StringValue{}, + ): docvalues.UmaskValue{}, docvalues.CreateEnumStringWithDoc( "file_umask", "Set the umask used for all regular files. Defaults to the umask of the current process.", - ): docvalues.StringValue{}, + ): docvalues.UmaskValue{}, docvalues.CreateEnumStringWithDoc( "umask", "Set the umask used for all files and directories. Defaults to the umask of the current process.", - ): docvalues.StringValue{}, + ): docvalues.UmaskValue{}, docvalues.CreateEnumStringWithDoc( "session", "Select the CDROM session to mount. Defaults to leaving that decision to the CDROM driver. This option will fail with anything but a CDROM as underlying device.", @@ -42,8 +42,7 @@ var HfsDocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ docvalues.CreateEnumStringWithDoc( "part", "Select partition number n from the device. Only makes sense for CDROMs. Defaults to not parsing the partition table at all.", - // TODO: Probably NumberValue - ): docvalues.StringValue{}, + ): docvalues.NumberValue{Min: &zero}, } var HfsDocumentationEnums = []docvalues.EnumString{ diff --git a/common-documentation/filesystems/mountoptions/hpfs.go b/common-documentation/filesystems/mountoptions/hpfs.go index 21b77a0..0e94cac 100644 --- a/common-documentation/filesystems/mountoptions/hpfs.go +++ b/common-documentation/filesystems/mountoptions/hpfs.go @@ -18,19 +18,25 @@ var HpfsDocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ docvalues.CreateEnumStringWithDoc( "umask", "Set the umask (the bitmask of the permissions that are not present). The default is the umask of the current process. The value is given in octal.", + ): docvalues.UmaskValue{}, + docvalues.CreateEnumStringWithDoc( + "case", + "Convert all files names to lower case, or leave them. (Default: case=lower.)", + ): docvalues.EnumValue{ + EnforceValues: true, + Values: []docvalues.EnumString{ + docvalues.CreateEnumString("lower"), + docvalues.CreateEnumString("asis"), + }, + }, + // Todo: Show error in analyzer + docvalues.CreateEnumStringWithDoc( + "conv", + "This option is obsolete and may fail or being ignored.", ): docvalues.StringValue{}, } var HpfsDocumentationEnums = []docvalues.EnumString{ - // Move up to map - docvalues.CreateEnumStringWithDoc( - "case", - "Convert all files names to lower case, or leave them. (Default: case=lower.)", - ), - docvalues.CreateEnumStringWithDoc( - "conv", - "This option is obsolete and may fail or being ignored.", - ), docvalues.CreateEnumStringWithDoc( "nocheck", "Do not abort mounting when certain consistency checks fail.",