github.com/apptainer/singularity@v3.1.1+incompatible/internal/pkg/runtime/engines/oci/rpc/server/server.go (about) 1 // Copyright (c) 2018, Sylabs Inc. All rights reserved. 2 // This software is licensed under a 3-clause BSD license. Please consult the 3 // LICENSE.md file distributed with the sources of this project regarding your 4 // rights to use or distribute this software. 5 6 package server 7 8 import ( 9 "os" 10 "syscall" 11 12 "github.com/sylabs/singularity/internal/pkg/util/fs" 13 14 ociargs "github.com/sylabs/singularity/internal/pkg/runtime/engines/oci/rpc" 15 args "github.com/sylabs/singularity/internal/pkg/runtime/engines/singularity/rpc" 16 server "github.com/sylabs/singularity/internal/pkg/runtime/engines/singularity/rpc/server" 17 "github.com/sylabs/singularity/internal/pkg/util/mainthread" 18 ) 19 20 // Methods is a receiver type. 21 type Methods struct { 22 *server.Methods 23 } 24 25 // MkdirAll performs a mkdir with the specified arguments. 26 func (t *Methods) MkdirAll(arguments *args.MkdirArgs, reply *int) (err error) { 27 mainthread.Execute(func() { 28 oldmask := syscall.Umask(0) 29 err = os.MkdirAll(arguments.Path, arguments.Perm) 30 syscall.Umask(oldmask) 31 }) 32 return err 33 } 34 35 // Symlink performs a symlink with the specified arguments. 36 func (t *Methods) Symlink(arguments *ociargs.SymlinkArgs, reply *int) (err error) { 37 return os.Symlink(arguments.Old, arguments.New) 38 } 39 40 // Touch performs a touch with the specified arguments. 41 func (t *Methods) Touch(arguments *ociargs.TouchArgs, reply *int) (err error) { 42 return fs.Touch(arguments.Path) 43 }