summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSven Eden <yamakuzure@gmx.net>2018-03-13 19:16:48 +0100
committerSven Eden <yamakuzure@gmx.net>2018-03-15 06:06:08 +0100
commit702b393b61061115a0b8cc166be5be3d6431ecfa (patch)
tree197a846b3039b2ef517d9b86dee731e21e07ad20 /src
parentd911f1cdcb6f314a1ec33493281520627fff0d08 (diff)
Prep v236: Remove obsolete files that have slithered in.
Diffstat (limited to 'src')
-rw-r--r--src/network/netdev/vxcan.c89
-rw-r--r--src/partition/growfs.c237
-rw-r--r--src/partition/makefs.c106
-rw-r--r--src/resolve/resolved-dnssd-bus.c132
4 files changed, 0 insertions, 564 deletions
diff --git a/src/network/netdev/vxcan.c b/src/network/netdev/vxcan.c
deleted file mode 100644
index e8a71d645..000000000
--- a/src/network/netdev/vxcan.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/***
- This file is part of elogind.
-
- Copyright 2017 Susant Sahani
-
- elogind is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- elogind is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with elogind; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include "netdev/vxcan.h"
-#include "missing.h"
-
-static int netdev_vxcan_fill_message_create(NetDev *netdev, Link *link, sd_netlink_message *m) {
- VxCan *v;
- int r;
-
- assert(netdev);
- assert(!link);
- assert(m);
-
- v = VXCAN(netdev);
-
- assert(v);
-
- r = sd_netlink_message_open_container(m, VXCAN_INFO_PEER);
- if (r < 0)
- return log_netdev_error_errno(netdev, r, "Could not append VXCAN_INFO_PEER attribute: %m");
-
- if (v->ifname_peer) {
- r = sd_netlink_message_append_string(m, IFLA_IFNAME, v->ifname_peer);
- if (r < 0)
- return log_error_errno(r, "Failed to add vxcan netlink interface peer name: %m");
- }
-
- r = sd_netlink_message_close_container(m);
- if (r < 0)
- return log_netdev_error_errno(netdev, r, "Could not append VXCAN_INFO_PEER attribute: %m");
-
- return r;
-}
-
-static int netdev_vxcan_verify(NetDev *netdev, const char *filename) {
- VxCan *v;
-
- assert(netdev);
- assert(filename);
-
- v = VXCAN(netdev);
-
- assert(v);
-
- if (!v->ifname_peer) {
- log_warning("VxCan NetDev without peer name configured in %s. Ignoring", filename);
- return -EINVAL;
- }
-
- return 0;
-}
-
-static void vxcan_done(NetDev *n) {
- VxCan *v;
-
- assert(n);
-
- v = VXCAN(n);
-
- assert(v);
-
- free(v->ifname_peer);
-}
-
-const NetDevVTable vxcan_vtable = {
- .object_size = sizeof(VxCan),
- .sections = "Match\0NetDev\0VXCAN\0",
- .done = vxcan_done,
- .fill_message_create = netdev_vxcan_fill_message_create,
- .create_type = NETDEV_CREATE_INDEPENDENT,
- .config_verify = netdev_vxcan_verify,
-};
diff --git a/src/partition/growfs.c b/src/partition/growfs.c
deleted file mode 100644
index 816aad394..000000000
--- a/src/partition/growfs.c
+++ /dev/null
@@ -1,237 +0,0 @@
-/* SPDX-License-Identifier: LGPL-2.1+ */
-/***
- This file is part of elogind.
-
- Copyright 2017 Zbigniew Jędrzejewski-Szmek
-
- elogind is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- elogind is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with elogind; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <errno.h>
-#include <fcntl.h>
-#include <linux/magic.h>
-#include <sys/ioctl.h>
-#include <sys/mount.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/vfs.h>
-
-#include "crypt-util.h"
-#include "device-nodes.h"
-#include "dissect-image.h"
-#include "escape.h"
-#include "fd-util.h"
-#include "format-util.h"
-#include "log.h"
-#include "missing.h"
-#include "mount-util.h"
-#include "parse-util.h"
-#include "path-util.h"
-#include "strv.h"
-
-static int resize_ext4(int mountfd, int devfd, uint64_t numblocks, uint64_t blocksize) {
- assert((uint64_t) (int) blocksize == blocksize);
-
- if (ioctl(mountfd, EXT4_IOC_RESIZE_FS, &numblocks) != 0)
- return -errno;
-
- return 0;
-}
-
-static int resize_btrfs(int mountfd, int devfd, uint64_t numblocks, uint64_t blocksize) {
- struct btrfs_ioctl_vol_args args = {};
- int r;
-
- assert((uint64_t) (int) blocksize == blocksize);
-
- r = snprintf(args.name, sizeof(args.name), "%"PRIu64, numblocks * blocksize);
- /* The buffer is large enough for any number to fit... */
- assert((size_t) r < sizeof(args.name));
-
- if (ioctl(mountfd, BTRFS_IOC_RESIZE, &args) != 0)
- return -errno;
-
- return 0;
-}
-
-static int resize_crypt_luks_device(dev_t devno, const char *fstype, dev_t main_devno) {
- char devpath[DEV_NUM_PATH_MAX], main_devpath[DEV_NUM_PATH_MAX];
- _cleanup_close_ int main_devfd = -1;
- _cleanup_(crypt_freep) struct crypt_device *cd = NULL;
- uint64_t size;
- int r;
-
- xsprintf_dev_num_path(main_devpath, "block", main_devno);
- main_devfd = open(main_devpath, O_RDONLY|O_CLOEXEC);
- if (main_devfd < 0)
- return log_error_errno(errno, "Failed to open \"%s\": %m", main_devpath);
-
- if (ioctl(main_devfd, BLKGETSIZE64, &size) != 0)
- return log_error_errno(errno, "Failed to query size of \"%s\" (before resize): %m",
- main_devpath);
-
- log_debug("%s is %"PRIu64" bytes", main_devpath, size);
-
- xsprintf_dev_num_path(devpath, "block", devno);
- r = crypt_init(&cd, devpath);
- if (r < 0)
- return log_error_errno(r, "crypt_init(\"%s\") failed: %m", devpath);
-
- crypt_set_log_callback(cd, cryptsetup_log_glue, NULL);
-
- r = crypt_load(cd, CRYPT_LUKS, NULL);
- if (r < 0)
- return log_debug_errno(r, "Failed to load LUKS metadata for %s: %m", devpath);
-
- r = crypt_resize(cd, main_devpath, 0);
- if (r < 0)
- return log_error_errno(r, "crypt_resize() of %s failed: %m", devpath);
-
- if (ioctl(main_devfd, BLKGETSIZE64, &size) != 0)
- log_warning_errno(errno, "Failed to query size of \"%s\" (after resize): %m",
- devpath);
- else
- log_debug("%s is now %"PRIu64" bytes", main_devpath, size);
-
- return 1;
-}
-
-static int maybe_resize_slave_device(const char *mountpath, dev_t main_devno) {
- dev_t devno;
- char devpath[DEV_NUM_PATH_MAX];
- _cleanup_free_ char *fstype = NULL;
- int r;
-
- crypt_set_log_callback(NULL, cryptsetup_log_glue, NULL);
- crypt_set_debug_level(1);
-
- r = get_block_device_harder(mountpath, &devno);
- if (r < 0)
- return log_error_errno(r, "Failed to determine underlying block device of \"%s\": %m",
- mountpath);
-
- log_debug("Underlying device %d:%d, main dev %d:%d, %s",
- major(devno), minor(devno),
- major(main_devno), minor(main_devno),
- devno == main_devno ? "same" : "different");
- if (devno == main_devno)
- return 0;
-
- xsprintf_dev_num_path(devpath, "block", devno);
- r = probe_filesystem(devpath, &fstype);
- if (r < 0)
- return log_warning_errno(r, "Failed to probe \"%s\": %m", devpath);
-
- if (streq_ptr(fstype, "crypto_LUKS"))
- return resize_crypt_luks_device(devno, fstype, main_devno);
-
- log_debug("Don't know how to resize %s of type %s, ignoring", devpath, strnull(fstype));
- return 0;
-}
-
-int main(int argc, char *argv[]) {
- dev_t devno;
- _cleanup_close_ int mountfd = -1, devfd = -1;
- int blocksize;
- uint64_t size, numblocks;
- char devpath[DEV_NUM_PATH_MAX], fb[FORMAT_BYTES_MAX];
- struct statfs sfs;
- int r;
-
- if (argc != 2) {
- log_error("This program requires one argument (the mountpoint).");
- return EXIT_FAILURE;
- }
-
- log_set_target(LOG_TARGET_AUTO);
- log_parse_environment();
- log_open();
-
- r = path_is_mount_point(argv[1], NULL, 0);
- if (r < 0) {
- log_error_errno(r, "Failed to check if \"%s\" is a mount point: %m", argv[1]);
- return EXIT_FAILURE;
- }
- if (r == 0) {
- log_error_errno(r, "\"%s\" is not a mount point: %m", argv[1]);
- return EXIT_FAILURE;
- }
-
- r = get_block_device(argv[1], &devno);
- if (r < 0) {
- log_error_errno(r, "Failed to determine block device of \"%s\": %m", argv[1]);
- return EXIT_FAILURE;
- }
-
- r = maybe_resize_slave_device(argv[1], devno);
- if (r < 0)
- return EXIT_FAILURE;
-
- mountfd = open(argv[1], O_RDONLY|O_CLOEXEC);
- if (mountfd < 0) {
- log_error_errno(errno, "Failed to open \"%s\": %m", argv[1]);
- return EXIT_FAILURE;
- }
-
- xsprintf_dev_num_path(devpath, "block", devno);
- devfd = open(devpath, O_RDONLY|O_CLOEXEC);
- if (devfd < 0) {
- log_error_errno(errno, "Failed to open \"%s\": %m", devpath);
- return EXIT_FAILURE;
- }
-
- if (ioctl(devfd, BLKBSZGET, &blocksize) != 0) {
- log_error_errno(errno, "Failed to query block size of \"%s\": %m", devpath);
- return EXIT_FAILURE;
- }
-
- if (ioctl(devfd, BLKGETSIZE64, &size) != 0) {
- log_error_errno(errno, "Failed to query size of \"%s\": %m", devpath);
- return EXIT_FAILURE;
- }
-
- if (size % blocksize != 0)
- log_notice("Partition size %"PRIu64" is not a multiple of the blocksize %d,"
- " ignoring %"PRIu64" bytes", size, blocksize, size % blocksize);
-
- numblocks = size / blocksize;
-
- if (fstatfs(mountfd, &sfs) < 0) {
- log_error_errno(errno, "Failed to stat file system \"%s\": %m", argv[1]);
- return EXIT_FAILURE;
- }
-
- switch(sfs.f_type) {
- case EXT4_SUPER_MAGIC:
- r = resize_ext4(mountfd, devfd, numblocks, blocksize);
- break;
- case BTRFS_SUPER_MAGIC:
- r = resize_btrfs(mountfd, devfd, numblocks, blocksize);
- break;
- default:
- log_error("Don't know how to resize fs %llx on \"%s\"",
- (long long unsigned) sfs.f_type, argv[1]);
- return EXIT_FAILURE;
- }
-
- if (r < 0) {
- log_error_errno(r, "Failed to resize \"%s\" to %"PRIu64" blocks: %m",
- argv[1], numblocks);
- return EXIT_FAILURE;
- }
-
- log_info("Successfully resized \"%s\" to %s bytes (%"PRIu64" blocks of %d bytes).",
- argv[1], format_bytes(fb, sizeof fb, size), numblocks, blocksize);
- return EXIT_SUCCESS;
-}
diff --git a/src/partition/makefs.c b/src/partition/makefs.c
deleted file mode 100644
index a171eaeb4..000000000
--- a/src/partition/makefs.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/***
- SPDX-License-Identifier: LGPL-2.1+
-
- This file is part of elogind.
-
- Copyright 2017 Zbigniew Jędrzejewski-Szmek
-
- elogind is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- elogind is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with elogind; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <fcntl.h>
-#include <signal.h>
-#include <sys/prctl.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include "alloc-util.h"
-#include "dissect-image.h"
-#include "signal-util.h"
-#include "string-util.h"
-
-static int makefs(const char *type, const char *device) {
- const char *mkfs;
- pid_t pid;
-
- if (streq(type, "swap"))
- mkfs = "/sbin/mkswap";
- else
- mkfs = strjoina("/sbin/mkfs.", type);
- if (access(mkfs, X_OK) != 0)
- return log_error_errno(errno, "%s is not executable: %m", mkfs);
-
- pid = fork();
- if (pid < 0)
- return log_error_errno(errno, "fork(): %m");
-
- if (pid == 0) {
- const char *cmdline[3] = { mkfs, device, NULL };
-
- /* Child */
-
- (void) reset_all_signal_handlers();
- (void) reset_signal_mask();
- assert_se(prctl(PR_SET_PDEATHSIG, SIGTERM) == 0);
-
- execv(cmdline[0], (char**) cmdline);
- _exit(EXIT_FAILURE);
- }
-
- return wait_for_terminate_and_warn(mkfs, pid, true);
-}
-
-int main(int argc, char *argv[]) {
- const char *device, *type;
- _cleanup_free_ char *detected = NULL;
- struct stat st;
- int r;
-
- log_set_target(LOG_TARGET_AUTO);
- log_parse_environment();
- log_open();
-
- if (argc != 3) {
- log_error("This program expects two arguments.");
- return EXIT_FAILURE;
- }
-
- type = argv[1];
- device = argv[2];
-
- if (stat(device, &st) < 0) {
- r = log_error_errno(errno, "Failed to stat \"%s\": %m", device);
- goto finish;
- }
-
- if (!S_ISBLK(st.st_mode))
- log_info("%s is not a block device.", device);
-
- r = probe_filesystem(device, &detected);
- if (r < 0) {
- log_warning_errno(r, "Failed to probe \"%s\": %m", device);
- goto finish;
- }
-
- if (detected) {
- log_info("%s is not empty (type %s), exiting", device, detected);
- goto finish;
- }
-
- r = makefs(type, device);
-
-finish:
- return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
-}
diff --git a/src/resolve/resolved-dnssd-bus.c b/src/resolve/resolved-dnssd-bus.c
deleted file mode 100644
index 3795d7887..000000000
--- a/src/resolve/resolved-dnssd-bus.c
+++ /dev/null
@@ -1,132 +0,0 @@
-/***
- This file is part of elogind.
-
- Copyright 2017 Dmitry Rozhkov
-
- elogind is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- elogind is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with elogind; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include "alloc-util.h"
-#include "resolved-dnssd.h"
-#include "resolved-dnssd-bus.h"
-#include "resolved-link.h"
-#include "strv.h"
-
-int bus_dnssd_method_unregister(sd_bus_message *message, void *userdata, sd_bus_error *error) {
- DnssdService *s = userdata;
- Manager *m;
- Iterator i;
- Link *l;
- int r;
-
- assert(message);
- assert(s);
-
- m = s->manager;
-
- HASHMAP_FOREACH(l, m->links, i) {
- if (l->mdns_ipv4_scope) {
- r = dns_scope_announce(l->mdns_ipv4_scope, true);
- if (r < 0)
- log_warning_errno(r, "Failed to send goodbye messages in IPv4 scope: %m");
-
- dns_zone_remove_rr(&l->mdns_ipv4_scope->zone, s->ptr_rr);
- dns_zone_remove_rr(&l->mdns_ipv4_scope->zone, s->srv_rr);
- dns_zone_remove_rr(&l->mdns_ipv4_scope->zone, s->txt_rr);
- }
-
- if (l->mdns_ipv6_scope) {
- r = dns_scope_announce(l->mdns_ipv6_scope, true);
- if (r < 0)
- log_warning_errno(r, "Failed to send goodbye messages in IPv6 scope: %m");
-
- dns_zone_remove_rr(&l->mdns_ipv6_scope->zone, s->ptr_rr);
- dns_zone_remove_rr(&l->mdns_ipv6_scope->zone, s->srv_rr);
- dns_zone_remove_rr(&l->mdns_ipv6_scope->zone, s->txt_rr);
- }
- }
-
- dnssd_service_free(s);
-
- manager_refresh_rrs(m);
-
- return sd_bus_reply_method_return(message, NULL);
-}
-
-const sd_bus_vtable dnssd_vtable[] = {
- SD_BUS_VTABLE_START(0),
-
- SD_BUS_METHOD("Unregister", NULL, NULL, bus_dnssd_method_unregister, 0),
- SD_BUS_SIGNAL("Conflicted", NULL, 0),
-
- SD_BUS_VTABLE_END
-};
-
-int dnssd_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error) {
- _cleanup_free_ char *name = NULL;
- Manager *m = userdata;
- DnssdService *service;
- int r;
-
- assert(bus);
- assert(path);
- assert(interface);
- assert(found);
- assert(m);
-
- r = sd_bus_path_decode(path, "/org/freedesktop/resolve1/dnssd", &name);
- if (r <= 0)
- return 0;
-
- service = hashmap_get(m->dnssd_services, name);
- if (!service)
- return 0;
-
- *found = service;
- return 1;
-}
-
-int dnssd_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error) {
- _cleanup_strv_free_ char **l = NULL;
- Manager *m = userdata;
- DnssdService *service;
- Iterator i;
- unsigned c = 0;
- int r;
-
- assert(bus);
- assert(path);
- assert(m);
- assert(nodes);
-
- l = new0(char*, hashmap_size(m->dnssd_services) + 1);
- if (!l)
- return -ENOMEM;
-
- HASHMAP_FOREACH(service, m->dnssd_services, i) {
- char *p;
-
- r = sd_bus_path_encode("/org/freedesktop/resolve1/dnssd", service->name, &p);
- if (r < 0)
- return r;
-
- l[c++] = p;
- }
-
- l[c] = NULL;
- *nodes = l;
- l = NULL;
-
- return 1;
-}