From: Daniel Mack Date: Mon, 18 Aug 2014 08:55:49 +0000 (+0200) Subject: memfd: move code from public library to src/shared X-Git-Tag: v216~61^2~8 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=43bde981ccc57c744f164a9d95d46c7ce8f21808 memfd: move code from public library to src/shared Don't expose generic kernel API via libsystemd, but keep the code internal for our own usage. --- diff --git a/Makefile.am b/Makefile.am index dbaed73bd..b9deaa653 100644 --- a/Makefile.am +++ b/Makefile.am @@ -860,6 +860,8 @@ libsystemd_shared_la_SOURCES = \ src/shared/copy.h \ src/shared/base-filesystem.c \ src/shared/base-filesystem.h \ + src/shared/memfd.c \ + src/shared/memfd.h \ src/shared/nss-util.h nodist_libsystemd_shared_la_SOURCES = \ @@ -2382,7 +2384,6 @@ libsystemd_internal_la_SOURCES = \ src/systemd/sd-bus.h \ src/systemd/sd-bus-protocol.h \ src/systemd/sd-bus-vtable.h \ - src/systemd/sd-memfd.h \ src/systemd/sd-utf8.h \ src/systemd/sd-event.h \ src/systemd/sd-rtnl.h \ @@ -2432,7 +2433,6 @@ libsystemd_internal_la_SOURCES = \ src/libsystemd/sd-bus/bus-slot.h \ src/libsystemd/sd-bus/bus-protocol.h \ src/libsystemd/sd-bus/kdbus.h \ - src/libsystemd/sd-bus/sd-memfd.c \ src/libsystemd/sd-utf8/sd-utf8.c \ src/libsystemd/sd-event/sd-event.c \ src/libsystemd/sd-event/event-util.h \ @@ -2550,7 +2550,6 @@ pkginclude_HEADERS += \ src/systemd/sd-bus.h \ src/systemd/sd-bus-protocol.h \ src/systemd/sd-bus-vtable.h \ - src/systemd/sd-memfd.h \ src/systemd/sd-utf8.h \ src/systemd/sd-event.h \ src/systemd/sd-rtnl.h \ diff --git a/src/libsystemd/libsystemd.sym.m4 b/src/libsystemd/libsystemd.sym.m4 index 1c24cad10..415d89afb 100644 --- a/src/libsystemd/libsystemd.sym.m4 +++ b/src/libsystemd/libsystemd.sym.m4 @@ -359,20 +359,6 @@ global: sd_bus_track_first; sd_bus_track_next; - /* sd-memfd */ - sd_memfd_new; - sd_memfd_new_and_map; - sd_memfd_free; - sd_memfd_get_fd; - sd_memfd_get_file; - sd_memfd_dup_fd; - sd_memfd_map; - sd_memfd_set_sealed; - sd_memfd_get_sealed; - sd_memfd_get_size; - sd_memfd_set_size; - sd_memfd_get_name; - /* sd-event */ sd_event_default; sd_event_new; diff --git a/src/libsystemd/sd-bus/test-bus-zero-copy.c b/src/libsystemd/sd-bus/test-bus-zero-copy.c index 29e40aa0a..e4a87ab3c 100644 --- a/src/libsystemd/sd-bus/test-bus-zero-copy.c +++ b/src/libsystemd/sd-bus/test-bus-zero-copy.c @@ -24,9 +24,9 @@ #include "util.h" #include "log.h" +#include "memfd.h" #include "sd-bus.h" -#include "sd-memfd.h" #include "bus-message.h" #include "bus-error.h" #include "bus-kernel.h" diff --git a/src/libsystemd/sd-bus/sd-memfd.c b/src/shared/memfd.c similarity index 89% rename from src/libsystemd/sd-bus/sd-memfd.c rename to src/shared/memfd.c index 16d09e3e1..4dd70a247 100644 --- a/src/libsystemd/sd-bus/sd-memfd.c +++ b/src/shared/memfd.c @@ -28,8 +28,8 @@ #include "util.h" #include "bus-label.h" #include "missing.h" +#include "memfd.h" -#include "sd-memfd.h" #include "sd-bus.h" struct sd_memfd { @@ -37,7 +37,7 @@ struct sd_memfd { FILE *f; }; -_public_ int sd_memfd_new(sd_memfd **m, const char *name) { +int sd_memfd_new(sd_memfd **m, const char *name) { _cleanup_close_ int kdbus = -1; _cleanup_free_ char *g = NULL; @@ -100,7 +100,7 @@ _public_ int sd_memfd_new(sd_memfd **m, const char *name) { return 0; } -_public_ int sd_memfd_new_from_fd(sd_memfd **m, int fd) { +int sd_memfd_new_from_fd(sd_memfd **m, int fd) { sd_memfd *n; assert_return(m, -EINVAL); @@ -120,7 +120,7 @@ _public_ int sd_memfd_new_from_fd(sd_memfd **m, int fd) { return 0; } -_public_ void sd_memfd_free(sd_memfd *m) { +void sd_memfd_free(sd_memfd *m) { if (!m) return; @@ -132,13 +132,13 @@ _public_ void sd_memfd_free(sd_memfd *m) { free(m); } -_public_ int sd_memfd_get_fd(sd_memfd *m) { +int sd_memfd_get_fd(sd_memfd *m) { assert_return(m, -EINVAL); return m->fd; } -_public_ int sd_memfd_get_file(sd_memfd *m, FILE **f) { +int sd_memfd_get_file(sd_memfd *m, FILE **f) { assert_return(m, -EINVAL); assert_return(f, -EINVAL); @@ -152,7 +152,7 @@ _public_ int sd_memfd_get_file(sd_memfd *m, FILE **f) { return 0; } -_public_ int sd_memfd_dup_fd(sd_memfd *m) { +int sd_memfd_dup_fd(sd_memfd *m) { int fd; assert_return(m, -EINVAL); @@ -164,7 +164,7 @@ _public_ int sd_memfd_dup_fd(sd_memfd *m) { return fd; } -_public_ int sd_memfd_map(sd_memfd *m, uint64_t offset, size_t size, void **p) { +int sd_memfd_map(sd_memfd *m, uint64_t offset, size_t size, void **p) { void *q; int sealed; @@ -184,7 +184,7 @@ _public_ int sd_memfd_map(sd_memfd *m, uint64_t offset, size_t size, void **p) { return 0; } -_public_ int sd_memfd_set_sealed(sd_memfd *m) { +int sd_memfd_set_sealed(sd_memfd *m) { int r; assert_return(m, -EINVAL); @@ -196,7 +196,7 @@ _public_ int sd_memfd_set_sealed(sd_memfd *m) { return 0; } -_public_ int sd_memfd_get_sealed(sd_memfd *m) { +int sd_memfd_get_sealed(sd_memfd *m) { int r; assert_return(m, -EINVAL); @@ -209,7 +209,7 @@ _public_ int sd_memfd_get_sealed(sd_memfd *m) { (F_SEAL_SHRINK | F_SEAL_GROW | F_SEAL_WRITE); } -_public_ int sd_memfd_get_size(sd_memfd *m, uint64_t *sz) { +int sd_memfd_get_size(sd_memfd *m, uint64_t *sz) { int r; struct stat stat; @@ -224,7 +224,7 @@ _public_ int sd_memfd_get_size(sd_memfd *m, uint64_t *sz) { return r; } -_public_ int sd_memfd_set_size(sd_memfd *m, uint64_t sz) { +int sd_memfd_set_size(sd_memfd *m, uint64_t sz) { int r; assert_return(m, -EINVAL); @@ -236,7 +236,7 @@ _public_ int sd_memfd_set_size(sd_memfd *m, uint64_t sz) { return r; } -_public_ int sd_memfd_new_and_map(sd_memfd **m, const char *name, size_t sz, void **p) { +int sd_memfd_new_and_map(sd_memfd **m, const char *name, size_t sz, void **p) { sd_memfd *n; int r; @@ -260,7 +260,7 @@ _public_ int sd_memfd_new_and_map(sd_memfd **m, const char *name, size_t sz, voi return 0; } -_public_ int sd_memfd_get_name(sd_memfd *m, char **name) { +int sd_memfd_get_name(sd_memfd *m, char **name) { char path[sizeof("/proc/self/fd/") + DECIMAL_STR_MAX(int)], buf[FILENAME_MAX+1], *e; const char *delim, *end; _cleanup_free_ char *n = NULL; diff --git a/src/systemd/sd-memfd.h b/src/shared/memfd.h similarity index 100% rename from src/systemd/sd-memfd.h rename to src/shared/memfd.h diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h index 3eedb4450..a69cafbe8 100644 --- a/src/systemd/sd-bus.h +++ b/src/systemd/sd-bus.h @@ -28,7 +28,7 @@ #include "sd-id128.h" #include "sd-event.h" -#include "sd-memfd.h" +#include "memfd.h" #include "_sd-common.h" _SD_BEGIN_DECLARATIONS;