diff options
-rw-r--r-- | Android.mk | 38 | ||||
-rw-r--r-- | main.c | 4 | ||||
-rw-r--r-- | rootdev.c | 4 |
3 files changed, 42 insertions, 4 deletions
diff --git a/Android.mk b/Android.mk new file mode 100644 index 0000000..613fa85 --- /dev/null +++ b/Android.mk @@ -0,0 +1,38 @@ +# Copyright (C) 2015 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) + +rootdev_CPPFLAGS := -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \ + -D_LARGEFILE64_SOURCE + +rootdev_CFLAGS := -Wall -Werror -Wno-sign-compare + +# Build the shared library. +include $(CLEAR_VARS) +LOCAL_MODULE := librootdev +LOCAL_CFLAGS += $(rootdev_CFLAGS) +LOCAL_CPPFLAGS += $(rootdev_CPPFLAGS) +LOCAL_SRC_FILES := rootdev.c +LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) +include $(BUILD_SHARED_LIBRARY) + +# Build the command line tool. +include $(CLEAR_VARS) +LOCAL_MODULE := rootdev +LOCAL_CFLAGS += $(rootdev_CFLAGS) +LOCAL_CPPFLAGS += $(rootdev_CPPFLAGS) +LOCAL_SHARED_LIBRARIES := librootdev +LOCAL_SRC_FILES := main.c +include $(BUILD_EXECUTABLE) @@ -47,8 +47,8 @@ static int flag_create = 0; static int flag_major = 0; static int flag_minor = 0; static const char *flag_path = "/"; -static char *flag_block_path = "/sys/block"; -static char *flag_dev_path = "/dev"; +static char *flag_block_path = NULL; +static char *flag_dev_path = NULL; static void parse_args(int argc, char **argv) { while (1) { @@ -29,7 +29,7 @@ #define MAX_SLAVE_DEPTH 8 static const char *kDefaultSearchPath = "/sys/block"; -static const char *kDefaultDevPath = "/dev"; +static const char *kDefaultDevPath = "/dev/block"; /* Encode the root device structuring here for Chromium OS */ static const char kActiveRoot[] = "/dev/ACTIVE_ROOT"; @@ -407,7 +407,7 @@ int rootdev(char *path, size_t size, bool full, bool strip) { dev_t _root_dev, *root_dev = &_root_dev; /* Yields the containing dev_t in st_dev. */ - if (stat("/", &root_statbuf) != 0) + if (stat("/data", &root_statbuf) != 0) return -1; /* Some ABIs (like mips o32) are broken and the st_dev field isn't actually |