From 73de4ca319710c1d3f8101571a136b2d33ac472d Mon Sep 17 00:00:00 2001 From: Myzel394 <50424412+Myzel394@users.noreply.github.com> Date: Mon, 5 Aug 2024 23:01:28 +0200 Subject: [PATCH] Add more mount options to common-documentation Related to #1 Add documentation for adfs, affs, and debugfs filesystem mount options. * **common-documentation/filesystems/mountoptions/adfs.go** - Add documentation for adfs filesystem options including uid, gid, ownmask, and othmask. * **common-documentation/filesystems/mountoptions/affs.go** - Add documentation for affs filesystem options including uid, gid, setuid, setgid, mode, and other options. * **common-documentation/filesystems/mountoptions/debugfs.go** - Add documentation for debugfs filesystem options including uid, gid, and mode. * **handlers/fstab/documentation/documentation-mountoptions.go** - Update to include the new mount options for adfs, affs, and debugfs filesystems. - Add entries for adfs, affs, and debugfs in the `MountOptionsMapField`. * **common.go** - Add common constants like "zero" to common-documentation/filesystems/mountoptions/common.go. --- .../filesystems/mountoptions/adfs.go | 22 +++++ .../filesystems/mountoptions/affs.go | 82 +++++++++++++++++++ .../filesystems/mountoptions/debugfs.go | 18 ++++ common.go | 3 + .../documentation-mountoptions.go | 31 +++---- 5 files changed, 137 insertions(+), 19 deletions(-) create mode 100644 common-documentation/filesystems/mountoptions/adfs.go create mode 100644 common-documentation/filesystems/mountoptions/affs.go create mode 100644 common-documentation/filesystems/mountoptions/debugfs.go create mode 100644 common.go diff --git a/common-documentation/filesystems/mountoptions/adfs.go b/common-documentation/filesystems/mountoptions/adfs.go new file mode 100644 index 0000000..7b4a489 --- /dev/null +++ b/common-documentation/filesystems/mountoptions/adfs.go @@ -0,0 +1,22 @@ +package commondocumentation + +import docvalues "config-lsp/doc-values" + +var AdfsDocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ + docvalues.CreateEnumStringWithDoc( + "uid", + "Set the owner of the files in the filesystem (default: uid=0).", + ): docvalues.PositiveNumbeValue(), + docvalues.CreateEnumStringWithDoc( + "gid", + "Set the group of the files in the filesystem (default: gid=0).", + ): docvalues.PositiveNumbeValue(), + docvalues.CreateEnumStringWithDoc( + "ownmask", + "Set the permission mask for ADFS 'owner' permissions (default: 0700).", + ): docvalues.StringValue{}, + docvalues.CreateEnumStringWithDoc( + "othmask", + "Set the permission mask for ADFS 'other' permissions (default: 0077).", + ): docvalues.StringValue{}, +} diff --git a/common-documentation/filesystems/mountoptions/affs.go b/common-documentation/filesystems/mountoptions/affs.go new file mode 100644 index 0000000..5731a12 --- /dev/null +++ b/common-documentation/filesystems/mountoptions/affs.go @@ -0,0 +1,82 @@ +package commondocumentation + +import docvalues "config-lsp/doc-values" + +var AffsDocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ + docvalues.CreateEnumStringWithDoc( + "uid", + "Set the owner and group of the root of the filesystem (default: uid=gid=0, but with option uid or gid without specified value, the UID and GID of the current process are taken).", + ): docvalues.NumberValue{Min: &zero}, + docvalues.CreateEnumStringWithDoc( + "gid", + "Set the owner and group of the root of the filesystem (default: uid=gid=0, but with option uid or gid without specified value, the UID and GID of the current process are taken).", + ): docvalues.NumberValue{Min: &zero}, + docvalues.CreateEnumStringWithDoc( + "setuid", + "Set the owner of all files.", + ): docvalues.NumberValue{Min: &zero}, + docvalues.CreateEnumStringWithDoc( + "setgid", + "Set the group of all files.", + ): docvalues.NumberValue{Min: &zero}, + docvalues.CreateEnumStringWithDoc( + "mode", + "Set the mode of all files to value & 0777 disregarding the original permissions. Add search permission to directories that have read permission. The value is given in octal.", + ): docvalues.StringValue{}, + docvalues.CreateEnumStringWithDoc( + "protect", + "Do not allow any changes to the protection bits on the filesystem.", + ): docvalues.StringValue{}, + docvalues.CreateEnumStringWithDoc( + "usemp", + "Set UID and GID of the root of the filesystem to the UID and GID of the mount point upon the first sync or umount, and then clear this option. Strange...", + ): docvalues.StringValue{}, + docvalues.CreateEnumStringWithDoc( + "verbose", + "Print an informational message for each successful mount.", + ): docvalues.StringValue{}, + docvalues.CreateEnumStringWithDoc( + "prefix", + "Prefix used before volume name, when following a link.", + ): docvalues.StringValue{}, + docvalues.CreateEnumStringWithDoc( + "volume", + "Prefix (of length at most 30) used before '/' when following a symbolic link.", + ): docvalues.StringValue{}, + docvalues.CreateEnumStringWithDoc( + "reserved", + "(Default: 2.) Number of unused blocks at the start of the device.", + ): docvalues.NumberValue{Min: &zero}, + docvalues.CreateEnumStringWithDoc( + "root", + "Give explicitly the location of the root block.", + ): docvalues.NumberValue{Min: &zero}, + docvalues.CreateEnumStringWithDoc( + "bs", + "Give blocksize. Allowed values are 512, 1024, 2048, 4096.", + ): docvalues.EnumValue{ + EnforceValues: true, + Values: []docvalues.EnumString{ + docvalues.CreateEnumString("512"), + docvalues.CreateEnumString("1024"), + docvalues.CreateEnumString("2048"), + docvalues.CreateEnumString("4096"), + }, + }, + docvalues.CreateEnumStringWithDoc( + "grpquota", + "These options are accepted but ignored. (However, quota utilities may react to such strings in /etc/fstab.)", + ): docvalues.StringValue{}, + docvalues.CreateEnumStringWithDoc( + "noquota", + "These options are accepted but ignored. (However, quota utilities may react to such strings in /etc/fstab.)", + ): docvalues.StringValue{}, + docvalues.CreateEnumStringWithDoc( + "quota", + "These options are accepted but ignored. (However, quota utilities may react to such strings in /etc/fstab.)", + ): docvalues.StringValue{}, + docvalues.CreateEnumStringWithDoc( + "usrquota", + "These options are accepted but ignored. (However, quota utilities may react to such strings in /etc/fstab.)", + ): docvalues.StringValue{}, +} diff --git a/common-documentation/filesystems/mountoptions/debugfs.go b/common-documentation/filesystems/mountoptions/debugfs.go new file mode 100644 index 0000000..b698fc6 --- /dev/null +++ b/common-documentation/filesystems/mountoptions/debugfs.go @@ -0,0 +1,18 @@ +package commondocumentation + +import docvalues "config-lsp/doc-values" + +var DebugfsDocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ + docvalues.CreateEnumStringWithDoc( + "uid", + "Set the owner of the mountpoint.", + ): docvalues.NumberValue{Min: &zero}, + docvalues.CreateEnumStringWithDoc( + "gid", + "Set the group of the mountpoint.", + ): docvalues.NumberValue{Min: &zero}, + docvalues.CreateEnumStringWithDoc( + "mode", + "Sets the mode of the mountpoint.", + ): docvalues.StringValue{}, +} diff --git a/common.go b/common.go new file mode 100644 index 0000000..63b4710 --- /dev/null +++ b/common.go @@ -0,0 +1,3 @@ +package commondocumentation + +var zero = 0 diff --git a/handlers/fstab/documentation/documentation-mountoptions.go b/handlers/fstab/documentation/documentation-mountoptions.go index fe3018a..40d0a6e 100644 --- a/handlers/fstab/documentation/documentation-mountoptions.go +++ b/handlers/fstab/documentation/documentation-mountoptions.go @@ -245,25 +245,18 @@ func createMountOptionField( var DefaultMountOptionsField = createMountOptionField([]docvalues.EnumString{}, map[docvalues.EnumString]docvalues.Value{}) var MountOptionsMapField = map[string]docvalues.Value{ - // "adfs": createMountOptionField( - // []docvalues.EnumString{}, - // map[string]commondocumentation.AssignableOption{ - // "uid": { - // Documentation: "Set the owner of the files in the filesystem", - // Handler: func(context docvalues.KeyValueAssignmentContext) docvalues.Value { - // min := 0 - // return docvalues.NumberValue{Min: &min} - // }, - // }, - // "gid": { - // Documentation: "Set the group of the files in the filesystem", - // Handler: func(context docvalues.KeyValueAssignmentContext) docvalues.Value { - // min := 0 - // return docvalues.NumberValue{Min: &min} - // }, - // }, - // }, - // ), + "adfs": createMountOptionField( + []docvalues.EnumString{}, + commondocumentation.AdfsDocumentationAssignable, + ), + "affs": createMountOptionField( + []docvalues.EnumString{}, + commondocumentation.AffsDocumentationAssignable, + ), + "debugfs": createMountOptionField( + []docvalues.EnumString{}, + commondocumentation.DebugfsDocumentationAssignable, + ), "ext2": createMountOptionField( commondocumentation.Ext2DocumentationEnums, commondocumentation.Ext2DocumentationAssignable,