Skip to content

Commit

Permalink
Merge pull request #302 from hallyn/2023-12-13/idmap
Browse files Browse the repository at this point in the history
shared: Move idmap from internal
  • Loading branch information
stgraber authored Dec 15, 2023
2 parents b36c759 + 3f94117 commit 37fbbe2
Show file tree
Hide file tree
Showing 60 changed files with 154 additions and 70 deletions.
2 changes: 1 addition & 1 deletion cmd/fuidshift/main_shift.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/spf13/cobra"

"github.com/lxc/incus/internal/idmap"
"github.com/lxc/incus/shared/idmap"
)

type cmdShift struct {
Expand Down
2 changes: 1 addition & 1 deletion cmd/incusd/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

"gopkg.in/yaml.v2"

"github.com/lxc/incus/internal/idmap"
"github.com/lxc/incus/internal/instancewriter"
"github.com/lxc/incus/internal/revert"
"github.com/lxc/incus/internal/server/backup"
Expand All @@ -27,6 +26,7 @@ import (
"github.com/lxc/incus/internal/server/task"
internalUtil "github.com/lxc/incus/internal/util"
"github.com/lxc/incus/shared/api"
"github.com/lxc/incus/shared/idmap"
"github.com/lxc/incus/shared/ioprogress"
"github.com/lxc/incus/shared/logger"
"github.com/lxc/incus/shared/units"
Expand Down
2 changes: 1 addition & 1 deletion cmd/incusd/cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package main
// #cgo CFLAGS: -Werror=implicit-function-declaration
// #cgo CFLAGS: -Werror=return-type -Wendif-labels -Werror=overflow
// #cgo CFLAGS: -Wnested-externs -fexceptions
// #cgo CFLAGS: -I ../../internal/cgo
// #cgo CFLAGS: -I ../../shared/cgo
// #cgo pkg-config: lxc
// #cgo pkg-config: libcap
import "C"
2 changes: 1 addition & 1 deletion cmd/incusd/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
liblxc "github.com/lxc/go-lxc"
"golang.org/x/sys/unix"

"github.com/lxc/incus/internal/idmap"
internalIO "github.com/lxc/incus/internal/io"
"github.com/lxc/incus/internal/linux"
"github.com/lxc/incus/internal/revert"
Expand Down Expand Up @@ -74,6 +73,7 @@ import (
"github.com/lxc/incus/shared/api"
"github.com/lxc/incus/shared/archive"
"github.com/lxc/incus/shared/cancel"
"github.com/lxc/incus/shared/idmap"
"github.com/lxc/incus/shared/logger"
"github.com/lxc/incus/shared/proxy"
localtls "github.com/lxc/incus/shared/tls"
Expand Down
4 changes: 2 additions & 2 deletions cmd/incusd/devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package main
#include <stdio.h>
#include <linux/hidraw.h>
#include "../../internal/cgo/memory_utils.h"
#include "../../shared/cgo/memory_utils.h"
#ifndef HIDIOCGRAWINFO
#define HIDIOCGRAWINFO _IOR('H', 0x03, struct hidraw_devinfo)
Expand Down Expand Up @@ -43,13 +43,13 @@ import (

"golang.org/x/sys/unix"

_ "github.com/lxc/incus/internal/cgo" // Used by cgo
"github.com/lxc/incus/internal/server/cgroup"
"github.com/lxc/incus/internal/server/device"
"github.com/lxc/incus/internal/server/instance"
"github.com/lxc/incus/internal/server/instance/instancetype"
"github.com/lxc/incus/internal/server/resources"
"github.com/lxc/incus/internal/server/state"
_ "github.com/lxc/incus/shared/cgo" // Used by cgo
"github.com/lxc/incus/shared/logger"
"github.com/lxc/incus/shared/util"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/incusd/instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

"github.com/stretchr/testify/suite"

"github.com/lxc/incus/internal/idmap"
"github.com/lxc/incus/internal/server/db"
"github.com/lxc/incus/internal/server/db/cluster"
deviceConfig "github.com/lxc/incus/internal/server/device/config"
Expand All @@ -18,6 +17,7 @@ import (
storagePools "github.com/lxc/incus/internal/server/storage"
internalUtil "github.com/lxc/incus/internal/util"
"github.com/lxc/incus/shared/api"
"github.com/lxc/incus/shared/idmap"
)

type containerTestSuite struct {
Expand Down
2 changes: 1 addition & 1 deletion cmd/incusd/main_activateifneeded.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (
"github.com/spf13/cobra"

"github.com/lxc/incus/client"
"github.com/lxc/incus/internal/idmap"
"github.com/lxc/incus/internal/server/db"
"github.com/lxc/incus/internal/server/instance"
"github.com/lxc/incus/internal/server/instance/instancetype"
"github.com/lxc/incus/internal/server/node"
"github.com/lxc/incus/shared/idmap"
"github.com/lxc/incus/shared/logger"
"github.com/lxc/incus/shared/util"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/incusd/main_checkfeature.go
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ static bool kernel_supports_idmapped_mounts(void)
import "C"

import (
_ "github.com/lxc/incus/internal/cgo" // Used by cgo
_ "github.com/lxc/incus/shared/cgo" // Used by cgo
"github.com/lxc/incus/shared/logger"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/incusd/main_forkcoresched.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ import (
"github.com/spf13/cobra"

// Used by cgo
_ "github.com/lxc/incus/internal/cgo"
_ "github.com/lxc/incus/shared/cgo"
)

type cmdForkcoresched struct {
Expand Down
2 changes: 1 addition & 1 deletion cmd/incusd/main_forkexec.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ import (
"github.com/spf13/cobra"

// Used by cgo
_ "github.com/lxc/incus/internal/cgo"
_ "github.com/lxc/incus/shared/cgo"
)

type cmdForkexec struct {
Expand Down
2 changes: 1 addition & 1 deletion cmd/incusd/main_forkmount.go
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ import (
"github.com/spf13/cobra"

// Used by cgo
_ "github.com/lxc/incus/internal/cgo"
_ "github.com/lxc/incus/shared/cgo"
)

type cmdForkmount struct {
Expand Down
2 changes: 1 addition & 1 deletion cmd/incusd/main_forknet.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ import (

"github.com/spf13/cobra"

_ "github.com/lxc/incus/internal/cgo" // Used by cgo
"github.com/lxc/incus/internal/netutils"
"github.com/lxc/incus/internal/server/ip"
_ "github.com/lxc/incus/shared/cgo" // Used by cgo
"github.com/lxc/incus/shared/subprocess"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/incusd/main_forkproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,12 @@ import (
"github.com/spf13/cobra"
"golang.org/x/sys/unix"

_ "github.com/lxc/incus/internal/cgo" // Used by cgo
"github.com/lxc/incus/internal/linux"
"github.com/lxc/incus/internal/netutils"
"github.com/lxc/incus/internal/server/daemon"
deviceConfig "github.com/lxc/incus/internal/server/device/config"
"github.com/lxc/incus/internal/server/network"
_ "github.com/lxc/incus/shared/cgo" // Used by cgo
)

const forkproxyUDSSockFDNum int = C.FORKPROXY_UDS_SOCK_FD_NUM
Expand Down
12 changes: 6 additions & 6 deletions cmd/incusd/main_forksyscall.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ package main
#include <sys/xattr.h>
#include <unistd.h>
#include "../../internal/cgo/macro.h"
#include "../../internal/cgo/memory_utils.h"
#include "../../internal/cgo/mount_utils.h"
#include "../../internal/cgo/syscall_numbers.h"
#include "../../internal/cgo/syscall_wrappers.h"
#include "../../shared/cgo/macro.h"
#include "../../shared/cgo/memory_utils.h"
#include "../../shared/cgo/mount_utils.h"
#include "../../shared/cgo/syscall_numbers.h"
#include "../../shared/cgo/syscall_wrappers.h"
extern char* advance_arg(bool required);
extern void attach_userns_fd(int ns_fd);
Expand Down Expand Up @@ -556,7 +556,7 @@ import (
"github.com/spf13/cobra"

// Used by cgo
_ "github.com/lxc/incus/internal/cgo"
_ "github.com/lxc/incus/shared/cgo"
)

type cmdForksyscall struct {
Expand Down
2 changes: 1 addition & 1 deletion cmd/incusd/main_forkuevent.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ package main
#include <unistd.h>
#include "../../internal/netutils/network.c"
#include "../../internal/cgo/memory_utils.h"
#include "../../shared/cgo/memory_utils.h"
#ifndef UEVENT_SEND
#define UEVENT_SEND 16
Expand Down
16 changes: 8 additions & 8 deletions cmd/incusd/main_nsexec.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ package main
#include <sys/wait.h>
#include <unistd.h>
#include "../../internal/cgo/incus.h"
#include "../../internal/cgo/file_utils.h"
#include "../../internal/cgo/memory_utils.h"
#include "../../internal/cgo/mount_utils.h"
#include "../../internal/cgo/process_utils.h"
#include "../../internal/cgo/syscall_numbers.h"
#include "../../internal/cgo/syscall_wrappers.h"
#include "../../shared/cgo/incus.h"
#include "../../shared/cgo/file_utils.h"
#include "../../shared/cgo/memory_utils.h"
#include "../../shared/cgo/mount_utils.h"
#include "../../shared/cgo/process_utils.h"
#include "../../shared/cgo/syscall_numbers.h"
#include "../../shared/cgo/syscall_wrappers.h"
// Command line parsing and tracking
char *cmdline_buf = NULL;
Expand Down Expand Up @@ -360,5 +360,5 @@ import "C"

import (
// Used by cgo
_ "github.com/lxc/incus/internal/cgo"
_ "github.com/lxc/incus/shared/cgo"
)
2 changes: 1 addition & 1 deletion cmd/incusd/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (
"github.com/stretchr/testify/suite"
"golang.org/x/sys/unix"

"github.com/lxc/incus/internal/idmap"
"github.com/lxc/incus/internal/server/db"
"github.com/lxc/incus/internal/server/db/cluster"
"github.com/lxc/incus/internal/server/sys"
internalUtil "github.com/lxc/incus/internal/util"
"github.com/lxc/incus/shared/idmap"
)

func mockStartDaemon() (*Daemon, error) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/incusd/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import (
"github.com/gorilla/websocket"
"google.golang.org/protobuf/proto"

"github.com/lxc/incus/internal/idmap"
"github.com/lxc/incus/internal/jmap"
"github.com/lxc/incus/internal/migration"
"github.com/lxc/incus/internal/server/instance"
localMigration "github.com/lxc/incus/internal/server/migration"
"github.com/lxc/incus/internal/server/operations"
"github.com/lxc/incus/shared/api"
"github.com/lxc/incus/shared/idmap"
)

type migrationFields struct {
Expand Down
3 changes: 0 additions & 3 deletions internal/idmap/empty.go

This file was deleted.

2 changes: 1 addition & 1 deletion internal/instancewriter/instance_tar_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (

"golang.org/x/sys/unix"

"github.com/lxc/incus/internal/idmap"
"github.com/lxc/incus/internal/linux"
"github.com/lxc/incus/shared/idmap"
"github.com/lxc/incus/shared/logger"
)

Expand Down
6 changes: 3 additions & 3 deletions internal/linux/socket_linux_cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ package linux
#include <sys/types.h>
#include <sys/un.h>
#include "../cgo/process_utils.h"
#include "../cgo/syscall_wrappers.h"
#include "../../shared/cgo/process_utils.h"
#include "../../shared/cgo/syscall_wrappers.h"
#define ABSTRACT_UNIX_SOCK_LEN sizeof(((struct sockaddr_un *)0)->sun_path)
Expand Down Expand Up @@ -51,7 +51,7 @@ import (

"golang.org/x/sys/unix"

_ "github.com/lxc/incus/internal/cgo" // Used by cgo
_ "github.com/lxc/incus/shared/cgo" // Used by cgo
)

const ABSTRACT_UNIX_SOCK_LEN int = C.ABSTRACT_UNIX_SOCK_LEN
Expand Down
2 changes: 1 addition & 1 deletion internal/netutils/netns_getifaddrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <sys/socket.h>
#include <unistd.h>

#include "../cgo/compiler.h"
#include "../../shared/cgo/compiler.h"
#include "network.c"

struct netns_ifaddrs {
Expand Down
4 changes: 2 additions & 2 deletions internal/netutils/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include <sys/socket.h>
#include <unistd.h>

#include "../cgo/compiler.h"
#include "../cgo/macro.h"
#include "../../shared/cgo/compiler.h"
#include "../../shared/cgo/macro.h"

#ifndef NETNS_RTA
#define NETNS_RTA(r) \
Expand Down
2 changes: 1 addition & 1 deletion internal/netutils/unixfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <sys/un.h>

#include "unixfd.h"
#include "../cgo/memory_utils.h"
#include "../../shared/cgo/memory_utils.h"

int lxc_abstract_unix_send_fds(int fd, int *sendfds, int num_sendfds,
void *data, size_t size)
Expand Down
2 changes: 1 addition & 1 deletion internal/server/device/device_utils_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import (

"golang.org/x/sys/unix"

"github.com/lxc/incus/internal/idmap"
"github.com/lxc/incus/internal/linux"
"github.com/lxc/incus/internal/revert"
"github.com/lxc/incus/internal/server/instance"
storageDrivers "github.com/lxc/incus/internal/server/storage/drivers"
"github.com/lxc/incus/shared/idmap"
"github.com/lxc/incus/shared/osarch"
"github.com/lxc/incus/shared/subprocess"
"github.com/lxc/incus/shared/util"
Expand Down
2 changes: 1 addition & 1 deletion internal/server/device/device_utils_disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/stretchr/testify/assert"

"github.com/lxc/incus/internal/idmap"
"github.com/lxc/incus/shared/idmap"
)

func TestDiskAddRootUserNSEntry(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/server/device/device_utils_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (

"golang.org/x/sys/unix"

"github.com/lxc/incus/internal/idmap"
internalIO "github.com/lxc/incus/internal/io"
"github.com/lxc/incus/internal/linux"
deviceConfig "github.com/lxc/incus/internal/server/device/config"
"github.com/lxc/incus/internal/server/state"
"github.com/lxc/incus/shared/idmap"
"github.com/lxc/incus/shared/logger"
"github.com/lxc/incus/shared/util"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/server/device/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (

"golang.org/x/sys/unix"

"github.com/lxc/incus/internal/idmap"
internalInstance "github.com/lxc/incus/internal/instance"
"github.com/lxc/incus/internal/linux"
"github.com/lxc/incus/internal/revert"
Expand All @@ -31,6 +30,7 @@ import (
"github.com/lxc/incus/internal/server/warnings"
internalUtil "github.com/lxc/incus/internal/util"
"github.com/lxc/incus/shared/api"
"github.com/lxc/incus/shared/idmap"
"github.com/lxc/incus/shared/logger"
"github.com/lxc/incus/shared/subprocess"
"github.com/lxc/incus/shared/units"
Expand Down
2 changes: 1 addition & 1 deletion internal/server/instance/drivers/driver_lxc.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
"google.golang.org/protobuf/proto"
yaml "gopkg.in/yaml.v2"

"github.com/lxc/incus/internal/idmap"
internalInstance "github.com/lxc/incus/internal/instance"
"github.com/lxc/incus/internal/instancewriter"
internalIO "github.com/lxc/incus/internal/io"
Expand Down Expand Up @@ -72,6 +71,7 @@ import (
localUtil "github.com/lxc/incus/internal/server/util"
internalUtil "github.com/lxc/incus/internal/util"
"github.com/lxc/incus/shared/api"
"github.com/lxc/incus/shared/idmap"
"github.com/lxc/incus/shared/logger"
"github.com/lxc/incus/shared/osarch"
"github.com/lxc/incus/shared/subprocess"
Expand Down
Loading

0 comments on commit 37fbbe2

Please sign in to comment.