diff --git a/backend/meta/none.go b/backend/meta/none.go new file mode 100644 index 0000000..f6e4844 --- /dev/null +++ b/backend/meta/none.go @@ -0,0 +1,54 @@ +// Copyright 2025 Versity Software +// This file is licensed under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package meta + +import ( + "os" +) + +// NoMeta is a metadata storer that does not store metadata. +// This can be useful for read only mounts where attempting to store metadata +// would fail. +type NoMeta struct{} + +// RetrieveAttribute retrieves the value of a specific attribute for an object or a bucket. +// always returns ErrNoSuchKey +func (NoMeta) RetrieveAttribute(_ *os.File, _, _, _ string) ([]byte, error) { + return nil, ErrNoSuchKey +} + +// StoreAttribute stores the value of a specific attribute for an object or a bucket. +// always returns nil without storing the attribute +func (NoMeta) StoreAttribute(_ *os.File, _, _, _ string, _ []byte) error { + return nil +} + +// DeleteAttribute removes the value of a specific attribute for an object or a bucket. +// always returns nil without deleting the attribute +func (NoMeta) DeleteAttribute(_, _, _ string) error { + return nil +} + +// ListAttributes lists all attributes for an object or a bucket. +// always returns an empty list of attributes +func (NoMeta) ListAttributes(_, _ string) ([]string, error) { + return []string{}, nil +} + +// DeleteAttributes removes all attributes for an object or a bucket. +// always returns nil without deleting any attributes +func (NoMeta) DeleteAttributes(bucket, object string) error { + return nil +} diff --git a/backend/meta/sidecar.go b/backend/meta/sidecar.go index cf19665..253d52c 100644 --- a/backend/meta/sidecar.go +++ b/backend/meta/sidecar.go @@ -1,3 +1,17 @@ +// Copyright 2025 Versity Software +// This file is licensed under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package meta import ( diff --git a/cmd/versitygw/posix.go b/cmd/versitygw/posix.go index 9ff8177..79d8fc0 100644 --- a/cmd/versitygw/posix.go +++ b/cmd/versitygw/posix.go @@ -30,6 +30,7 @@ var ( versioningDir string dirPerms uint sidecar string + nometa bool ) func posixCommand() *cli.Command { @@ -86,6 +87,12 @@ will be translated into the file /mnt/fs/gwroot/mybucket/a/b/c/myobject`, EnvVars: []string{"VGW_META_SIDECAR"}, Destination: &sidecar, }, + &cli.BoolFlag{ + Name: "nometa", + Usage: "disable metadata storage", + EnvVars: []string{"VGW_META_NONE"}, + Destination: &nometa, + }, }, } } @@ -101,6 +108,10 @@ func runPosix(ctx *cli.Context) error { return fmt.Errorf("invalid directory permissions: %d", dirPerms) } + if nometa && sidecar != "" { + return fmt.Errorf("cannot use both nometa and sidecar metadata") + } + opts := posix.PosixOpts{ ChownUID: chownuid, ChownGID: chowngid, @@ -118,6 +129,8 @@ func runPosix(ctx *cli.Context) error { } ms = sc opts.SideCarDir = sidecar + case nometa: + ms = meta.NoMeta{} default: ms = meta.XattrMeta{} err := meta.XattrMeta{}.Test(gwroot)