Revert "Add vport_trigger tool."
This reverts commit d737d5e2456f45f61b0281c527a40ba21c92e019.
Cherry-picked wrong version of the patchset.
Bug: 77656836
Change-Id: I33fa33156169a0f9fd55f043bffcdb3ff84df735
diff --git a/guest/commands/vport_trigger/Android.mk b/guest/commands/vport_trigger/Android.mk
deleted file mode 100644
index e994ce9..0000000
--- a/guest/commands/vport_trigger/Android.mk
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright (C) 2018 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := vport_trigger
-LOCAL_MODULE_TAGS := optional
-LOCAL_SRC_FILES := main.cpp
-LOCAL_SHARED_LIBRARIES := libcutils
-LOCAL_MULTILIB := first
-LOCAL_VENDOR_MODULE := true
-
-include $(BUILD_EXECUTABLE)
diff --git a/guest/commands/vport_trigger/main.cpp b/guest/commands/vport_trigger/main.cpp
deleted file mode 100644
index 9e4a5f7..0000000
--- a/guest/commands/vport_trigger/main.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <cutils/properties.h>
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <unistd.h>
-#include <fcntl.h>
-
-#include <climits>
-#include <sstream>
-#include <string>
-
-// Taken from android::base, which wasn't available on platform versions
-// earlier than nougat.
-
-static bool ReadFdToString(int fd, std::string* content) {
- content->clear();
- char buf[BUFSIZ];
- ssize_t n;
- while ((n = TEMP_FAILURE_RETRY(read(fd, &buf[0], sizeof(buf)))) > 0) {
- content->append(buf, n);
- }
- return (n == 0) ? true : false;
-}
-
-static bool ReadFileToString(const std::string& path, std::string* content,
- bool follow_symlinks) {
- int flags = O_RDONLY | O_CLOEXEC | (follow_symlinks ? 0 : O_NOFOLLOW);
- int fd = TEMP_FAILURE_RETRY(open(path.c_str(), flags));
- if (fd == -1) {
- return false;
- }
- bool result = ReadFdToString(fd, content);
- close(fd);
- return result;
-}
-
-int main(int argc __unused, char *argv[] __unused) {
- // QEMU seems to create on either bus 0 or bus 1.
- for (size_t bus = 0; bus < 2U; bus++) {
- // 'max_ports' is set to '31' upstream.
- for (size_t port = 0; port < 31U; port++) {
- std::ostringstream vport;
- vport << "vport" << bus << "p" << port;
- std::string sysfs("/sys/class/virtio-ports/" + vport.str() + "/name");
- struct stat st;
- if (stat(sysfs.c_str(), &st)) {
- continue;
- }
- std::string content;
- if (!ReadFileToString(sysfs, &content, true)) {
- continue;
- }
- if (content.empty()) {
- continue;
- }
- content.erase(content.end() - 1);
- // Leaves 32-11=22 characters for the port name from QEMU.
- std::string propname("sys.cf.ser." + content);
- std::string dev("/dev/" + vport.str());
- property_set(propname.c_str(), dev.c_str());
- }
- }
- return 0;
-}