summaryrefslogtreecommitdiff
path: root/pkg/system
Commit message (Collapse)AuthorAgeFilesLines
* pkg/system: remove deprecated IsProcessAlive, IsProcessZombie, KillProcessSebastiaan van Stijn2023-05-061-27/+0
| | | | | | | These were deprecated in 9d5e754caad0af212545b352e19c3085d8df3281, which is part of the v24.0.0 release, so we can remove it from master. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* pkg/system: remove deprecated DefaultPathEnv()Sebastiaan van Stijn2023-05-061-18/+0
| | | | | | | This was deprecated in 9f3e5eead5accb9fb405398af700d97e830a3b5b, which is part of the v24.0.0 release, so we can remove it from master. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* pkg/system: remove deprecated MemInfo, ReadMemInfo()Sebastiaan van Stijn2023-05-061-16/+0
| | | | | | | These were deprecated in 2d490800565c410af8564844f52cd9fa34c7b1bf, which is part of the v24.0.0 release, so we can remove it from master. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* pkg/sysinfo: move MemInfo and ReadMemInfo to a separate packageSebastiaan van Stijn2023-03-151-6/+6
| | | | | | | | | | | | | | | | | | | | | | | Commit 6a516acb2e720b7a01d27c7df9cfe9857c013308 moved the MemInfo type and ReadMemInfo() function into the pkg/sysinfo package. In an attempt to assist consumers of these to migrate to the new location, an alias was added. Unfortunately, the side effect of this alias is that pkg/system now depends on pkg/sysinfo, which means that consumers of this (such as docker/cli) now get all (indirect) dependencies of that package as dependency, which includes many dependencies that should only be needed for the daemon / runtime; - github.com/cilium/ebpf - github.com/containerd/cgroups - github.com/coreos/go-systemd/v22 - github.com/godbus/dbus/v5 - github.com/moby/sys/mountinfo - github.com/opencontainers/runtime-spec This patch moves the MemInfo related code to its own package. As the previous move was not yet part of a release, we're not adding new aliases in pkg/sysinfo. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* pkg/system: move memory-info types to pkg/systeminfoSebastiaan van Stijn2022-12-216-182/+16
| | | | | | | | These types and functions are more closely related to the functionality provided by pkg/systeminfo, and used in conjunction with the other functions in that package, so moving them there. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* pkg/system: move CheckSystemDriveAndRemoveDriveLetter to pkg/archiveSebastiaan van Stijn2022-11-294-134/+0
| | | | | | | | This one is a "bit" fuzzy, as it may not be _directly_ related to `archive`, but it's always used _in combination_ with the archive package, so moving it there. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* pkg/system: CheckSystemDriveAndRemoveDriveLetter: fix error formatSebastiaan van Stijn2022-11-292-5/+5
| | | | Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* pkg/system: move GetLongPathName to integration-cliSebastiaan van Stijn2022-11-292-33/+0
| | | | | | It's only used for an integration test, and has no external consumers. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* pkg/system: deprecate DefaultPathEnv, move to ociSebastiaan van Stijn2022-11-292-15/+18
| | | | | | | | | | This patch: - Deprecates pkg/system.DefaultPathEnv - Moves the implementation inside oci - Adds TODOs to align the default in the Builder with the one used elsewhere Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* move pkg/system: process to a separate packageSebastiaan van Stijn2022-11-043-61/+27
| | | | Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* pkg/system: IsProcessZombie() skip conversion to string, use bytes insteadSebastiaan van Stijn2022-11-041-6/+3
| | | | | | bytes.SplitN() is more performant, and skips having to do the conversion. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* pkg/system: IsProcessZombie() ignore "os.ErrNotExist" errorsSebastiaan van Stijn2022-11-041-3/+4
| | | | | | | | | If the file doesn't exist, the process isn't running, so we should be able to ignore that. Also remove an intermediate variable. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* pkg/system: IsProcessAlive() remove redundant type-castSebastiaan van Stijn2022-11-041-2/+1
| | | | Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* Merge pull request #44302 from thaJeztah/sys_windowsSebastiaan van Stijn2022-10-211-38/+55
|\ | | | | pkg/system: optimize and refactor MkdirAllWithACL()
| * pkg/system: synchronize mkdirall() with latest os.MkDirAll()Sebastiaan van Stijn2022-10-151-8/+15
| | | | | | | | Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| * pkg/system: create SecurityAttribute only once (Windows)Sebastiaan van Stijn2022-10-151-21/+27
| | | | | | | | | | | | | | | | The same attribute was generated for each path that was created, but always the same, so instead of generating it in each iteration, generate it once, and pass it to our mkdirall() implementation. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| * pkg/system: update volumePath regex to allow returning earlierSebastiaan van Stijn2022-10-151-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | The regex only matched volume paths without a trailing path-separator. In cases where a path would be passed with a trailing path-separator, it would depend on further code in mkdirall to strip the trailing slash, then to perform the regex again in the next iteration. While regexes aren't ideal, we're already executing this one, so we may as well use it to match those situations as well (instead of executing it twice), to allow us to return early. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| * pkg/system: compile volume-path regex once, and update GoDocSebastiaan van Stijn2022-10-151-10/+13
| | | | | | | | | | | | | | | | | | Ideally, we would construct this lazily, but adding a function and a sync.Once felt like a bit "too much". Also updated the GoDoc for some functions to better describe what they do. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* | Merge pull request #44265 from thaJeztah/pkg_system_move_init_step1Sebastiaan van Stijn2022-10-159-252/+298
|\ \ | |/ |/| pkg/system: cleanup, test-fixes and improvements and minor fixes
| * pkg/system: fix missing assertions and use sub-tests for ChTimesSebastiaan van Stijn2022-10-073-157/+217
| | | | | | | | | | | | | | | | | | | | | | | | These tests were effectively doing "subtests", using comments to describe each, however; - due to the use of `t.Fatal()` would terminate before completing all "subtests" - The error returned by the function being tested (`Chtimes`), was not checked, and the test used "indirect" checks to verify if it worked correctly. Adding assertions to check if the function didn't produce an error. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| * pkg/system: rename some tests to be more descriptiveSebastiaan van Stijn2022-10-073-6/+7
| | | | | | | | | | | | | | | | Removing the "Linux" suffix from one test, which should probably be rewritten to be run on "unix", to provide test-coverage for those implementations. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| * pkg/system: use t.TempDir(), remove some test-utilsSebastiaan van Stijn2022-10-076-38/+35
| | | | | | | | | | | | | | | | | | With t.TempDir(), some of the test-utilities became so small that it was more transparent to inline them. This also helps separating concenrs, as we're in the process of thinning out and decoupling some packages. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| * pkg/system: windows: setCTime(): remove redundant conversionSebastiaan van Stijn2022-10-071-8/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It looks like this function was converting the time (`windows.NsecToTimespec()`), only to convert it back (`windows.TimespecToNsec()`). This became clear when moving the lines together: ```go ctimespec := windows.NsecToTimespec(ctime.UnixNano()) c := windows.NsecToFiletime(windows.TimespecToNsec(ctimespec)) ``` And looking at the Golang code, it looks like they're indeed the exact reverse: ```go func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } func NsecToTimespec(nsec int64) (ts Timespec) { ts.Sec = nsec / 1e9 ts.Nsec = nsec % 1e9 return } ``` While modifying this code, also renaming the `e` variable to a more common `err`. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| * pkg/system: rename maxTime and re-use, define unixEpochTime, update GoDocSebastiaan van Stijn2022-10-074-27/+18
| | | | | | | | | | | | | | This more closely matches to how it's used everywhere. Also move the comment describing "what" ChTimes() does inside its GoDoc. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| * pkg/system: add note about maxTimeSebastiaan van Stijn2022-10-071-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This code caused me some head-scratches, and initially I wondered if this was a bug, but it looks to be intentional to set nsec, not sec, as time.Unix() internally divides nsec, and sets sec accordingly; https://github.com/golang/go/blob/go1.19.2/src/time/time.go#L1364-L1380 // Unix returns the local Time corresponding to the given Unix time, // sec seconds and nsec nanoseconds since January 1, 1970 UTC. // It is valid to pass nsec outside the range [0, 999999999]. // Not all sec values have a corresponding time value. One such // value is 1<<63-1 (the largest int64 value). func Unix(sec int64, nsec int64) Time { if nsec < 0 || nsec >= 1e9 { n := nsec / 1e9 sec += n nsec -= n * 1e9 if nsec < 0 { nsec += 1e9 sec-- } } return unixTime(sec, int32(nsec)) } Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| * pkg/system: move maxTime init() back to Chtimes codeSebastiaan van Stijn2022-10-072-22/+16
| | | | | | | | | | | | | | | | | | This code was moved to a separate file in fe5b34ba8828dc2f2f7db180a102cee360fec6e0, but it's unclear why it was moved (as this file is not excluded on Windows). Moving the code back into the chtimes file, to move it closer to where it's used. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* | pkg/system: remove solaris left-overSebastiaan van Stijn2022-10-091-13/+0
|/ | | | | | It was removed everywhere else, so we may as well remove it here. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* Merge pull request #44255 from thaJeztah/pkg_system_remove_GetExitCodeSebastiaan van Stijn2022-10-072-21/+2
|\ | | | | pkg/system: move GetExitCode() to pkg/idtools, and un-export
| * pkg/system: unconvertSebastiaan van Stijn2022-10-051-2/+2
| | | | | | | | Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| * pkg/system: move GetExitCode() to pkg/idtools, and un-exportSebastiaan van Stijn2022-10-051-19/+0
| | | | | | | | | | | | | | This utility was only used in a single place, and had no external consumers. Move it to where it's used. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* | pkg/system: remove Umask() utilitySebastiaan van Stijn2022-10-062-21/+0
|/ | | | | | | It was only used in a couple of places, and in most places shouldn't be used as those locations were in unix/linux-only files, so didn't need the wrapper. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* pkg/*: fix "empty-lines" (revive)Sebastiaan van Stijn2022-09-282-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | pkg/directory/directory.go:9:49: empty-lines: extra empty line at the start of a block (revive) pkg/pubsub/publisher.go:8:48: empty-lines: extra empty line at the start of a block (revive) pkg/loopback/attach_loopback.go:96:69: empty-lines: extra empty line at the start of a block (revive) pkg/devicemapper/devmapper_wrapper.go:136:48: empty-lines: extra empty line at the start of a block (revive) pkg/devicemapper/devmapper.go:391:35: empty-lines: extra empty line at the end of a block (revive) pkg/devicemapper/devmapper.go:676:35: empty-lines: extra empty line at the end of a block (revive) pkg/archive/changes_posix_test.go:15:38: empty-lines: extra empty line at the end of a block (revive) pkg/devicemapper/devmapper.go:241:51: empty-lines: extra empty line at the start of a block (revive) pkg/fileutils/fileutils_test.go:17:47: empty-lines: extra empty line at the end of a block (revive) pkg/fileutils/fileutils_test.go:34:48: empty-lines: extra empty line at the end of a block (revive) pkg/fileutils/fileutils_test.go:318:32: empty-lines: extra empty line at the end of a block (revive) pkg/tailfile/tailfile.go:171:6: empty-lines: extra empty line at the end of a block (revive) pkg/tarsum/fileinfosums_test.go:16:41: empty-lines: extra empty line at the end of a block (revive) pkg/tarsum/tarsum_test.go:198:42: empty-lines: extra empty line at the start of a block (revive) pkg/tarsum/tarsum_test.go:294:25: empty-lines: extra empty line at the start of a block (revive) pkg/tarsum/tarsum_test.go:407:34: empty-lines: extra empty line at the end of a block (revive) pkg/ioutils/fswriters_test.go:52:45: empty-lines: extra empty line at the end of a block (revive) pkg/ioutils/writers_test.go:24:39: empty-lines: extra empty line at the end of a block (revive) pkg/ioutils/bytespipe_test.go:78:26: empty-lines: extra empty line at the end of a block (revive) pkg/sysinfo/sysinfo_linux_test.go:13:37: empty-lines: extra empty line at the end of a block (revive) pkg/archive/archive_linux_test.go:57:64: empty-lines: extra empty line at the end of a block (revive) pkg/archive/changes.go:248:72: empty-lines: extra empty line at the start of a block (revive) pkg/archive/changes_posix_test.go:15:38: empty-lines: extra empty line at the end of a block (revive) pkg/archive/copy.go:248:124: empty-lines: extra empty line at the end of a block (revive) pkg/archive/diff_test.go:198:44: empty-lines: extra empty line at the end of a block (revive) pkg/archive/archive.go:304:12: empty-lines: extra empty line at the end of a block (revive) pkg/archive/archive.go:749:37: empty-lines: extra empty line at the end of a block (revive) pkg/archive/archive.go:812:81: empty-lines: extra empty line at the start of a block (revive) pkg/archive/copy_unix_test.go:347:34: empty-lines: extra empty line at the end of a block (revive) pkg/system/path.go:11:39: empty-lines: extra empty line at the end of a block (revive) pkg/system/meminfo_linux.go:29:21: empty-lines: extra empty line at the end of a block (revive) pkg/plugins/plugins.go:135:32: empty-lines: extra empty line at the end of a block (revive) pkg/authorization/response.go:71:48: empty-lines: extra empty line at the start of a block (revive) pkg/authorization/api_test.go:18:51: empty-lines: extra empty line at the end of a block (revive) pkg/authorization/middleware_test.go:23:44: empty-lines: extra empty line at the end of a block (revive) pkg/authorization/middleware_unix_test.go:17:46: empty-lines: extra empty line at the end of a block (revive) pkg/authorization/api_test.go:57:45: empty-lines: extra empty line at the end of a block (revive) pkg/authorization/response.go:83:50: empty-lines: extra empty line at the start of a block (revive) pkg/authorization/api_test.go:66:47: empty-lines: extra empty line at the end of a block (revive) pkg/authorization/middleware_unix_test.go:45:48: empty-lines: extra empty line at the end of a block (revive) pkg/authorization/response.go:145:75: empty-lines: extra empty line at the start of a block (revive) pkg/authorization/middleware_unix_test.go:56:51: empty-lines: extra empty line at the end of a block (revive) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* pkg/system: remove stubs for deprecated sequential functionsSebastiaan van Stijn2022-09-271-35/+0
| | | | | | | | These functions were moved to github.com/moby/sys/sequential, and the stubs were added in 509f19f611d9316960ae176cdf31c401aa9bcce3, which is part of the 22.x release, so we can safely remove these from master. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* pkg/containerfs: drop PathDriver abstractionCory Snider2022-09-234-22/+14
| | | | | | | With LCOW support removed, there is no need to support non-native file paths any longer. Signed-off-by: Cory Snider <csnider@mirantis.com>
* replace pkg/system Sequential funcs with moby/sys/sequentialSebastiaan van Stijn2022-08-303-201/+35
| | | | | | | | Migrating these functions to allow them being shared between moby, docker/cli, and containerd, and to allow using them without importing all of sys / system, which (in containerd) also depends on hcsshim and more. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* pkg/system: make IsAbs() platform-agnosticSebastiaan van Stijn2022-08-273-24/+20
| | | | | | | filepath.IsAbs() will short-circuit on Linux/Unix, so having a single implementation should not affect those platforms. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* gofmt GoDoc comments with go1.19Sebastiaan van Stijn2022-07-081-1/+1
| | | | | | | | Older versions of Go don't format comments, so committing this as a separate commit, so that we can already make these changes before we upgrade to Go 1.19. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* daemon: killWithSignal, killPossiblyDeadProcess: accept syscall.SignalSebastiaan van Stijn2022-05-051-0/+1
| | | | | | | This helps reducing some type-juggling / conversions further up the stack. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* pkg/system: move IsWindowsClient to pkg/parsers/operatingsystemSebastiaan van Stijn2022-03-171-14/+0
| | | | | | | | | | This function was only used in a single place, and pkg/parsers/operatingsystem already copied the `verNTWorkstation` const, so we might as well move this function there as well to "unclutter" pkg/system. The function had no external users, so not adding an alias / stub. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* pkg/system: remove deprecated (and unused) windows constsSebastiaan van Stijn2022-03-161-9/+0
| | | | | | | | | | | | | | | These consts were deprecated in 46c591b045a77b7f0f96f96a51d8304264685929, and although that has not been in a release yet (we usually deprecate for at least one release before removing), doing a search showed that there were no external consumers of these consts, so it should be fine to remove them. This patch removes the consts that were moded to pkg/idtools; - SeTakeOwnershipPrivilege - ContainerAdministratorSidString - ContainerUserSidString Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* pkg/system: remove github.com/docker/go-units dependencySebastiaan van Stijn2022-03-031-3/+2
| | | | | | | | | | | This is not "very" important, but this dependency was only used for a single const, which could be satisfied with a comment. Not very urgent, as github.com/docker/go-units is likely imported through other ways already (but it's nice to have the package be more isolated). Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* pkg/system: move EnsureRemoveAll() to pkg/containerfsSebastiaan van Stijn2022-03-034-178/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | pkg/system historically has been a bit of a kitchen-sink of things that were somewhat "system" related, but didn't have a good place for. EnsureRemoveAll() is one of those utilities. EnsureRemoveAll() is used to both unmount and remove a path, for which it depends on both github.com/moby/sys/mount, which in turn depends on github.com/moby/sys/mountinfo. pkg/system is imported in the CLI, but neither EnsureRemoveAll(), nor any of its moby/sys dependencies are used on the client side, so let's move this function somewhere else, to remove those dependencies from the CLI. I looked for plausible locations that were related; it's used in: - daemon - daemon/graphdriver/XXX/ - plugin I considered moving it into a (e.g.) "utils" package within graphdriver (but not a huge fan of "utils" packages), and given that it felt (mostly) related to cleaning up container filesystems, I decided to move it there. Some things to follow-up on after this: - Verify if this function is still needed (it feels a bit like a big hammer in a "YOLO, let's try some things just in case it fails") - Perhaps it should be integrated in `containerfs.Remove()` (so that it's used automatically) - Look if there's other implementations (and if they should be consolidated), although (e.g.) the one in containerd is a copy of ours: https://github.com/containerd/containerd/blob/v1.5.9/pkg/cri/server/helpers_linux.go#L200 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* pkg/system: rewrite IsWindowsClient() using golang.org/x/sys/windowsSebastiaan van Stijn2022-01-261-31/+5
| | | | | | Looks like we should be able to use the implementation from x/sys/windows. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* pkg/system: remove unused HasWin32KSupport()Sebastiaan van Stijn2022-01-262-26/+1
| | | | | | | | | | | | | | | This was added in 194eaa5c0f843257e66b68bd735786308a9d93b2 to check image compatibility based on Platform.Features; // For now, hard code that all base images except nanoserver depend on win32k support if imageData.Name != "nanoserver" { imageData.OSFeatures = append(imageData.OSFeatures, "win32k") } But no longer used since 1f59bc8c03df18686b93a0cd619cf2c55cbcf421 and d231260868507174d60ff58b18b14fa5bc2d5b66 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* Use syscall.Timespec.UnixTobias Klauser2022-01-031-5/+5
| | | | | | | | Use the syscall method instead of repeating the type conversions for the syscall.Stat_t Atim/Mtim members. This also allows to drop the //nolint: unconvert comments. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
* system: unbreak build for darwinTonis Tiigi2021-12-151-0/+3
| | | | Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
* Port pkg/system/mknod.go to FreeBSDArtem Khramov2021-09-223-6/+25
| | | | | | | | | | | Because FreeBSD uses 64-bit device nodes (see https://reviews.freebsd.org/rS318736), Linux implementation of `system.Mknod` & `system.Mkdev` is not sufficient. This change adds freebsd-specific implementations for `Mknod` and Mkdev`. Signed-off-by: Artem Khramov <akhramov@pm.me>
* refactor: move from io/ioutil to io and os packageEng Zer Jun2021-08-277-17/+13
| | | | | | | | The io/ioutil package has been deprecated in Go 1.16. This commit replaces the existing io/ioutil functions with their new definitions in io and os packages. Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
* Update to Go 1.17.0, and gofmt with Go 1.17Sebastiaan van Stijn2021-08-2422-0/+22
| | | | Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* Windows CI: Add support for testing with containerdOlli Janatuinen2021-08-171-16/+5
| | | | Signed-off-by: Olli Janatuinen <olli.janatuinen@gmail.com>