Add getmtu and setmtu interface commands
Bug: 9372485
Change-Id: I0dfa6b1f973426d67f976a9c79be8de90e3d9c19
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
diff --git a/NetdConstants.cpp b/NetdConstants.cpp
index 1ab09a5..c3c16eb 100644
--- a/NetdConstants.cpp
+++ b/NetdConstants.cpp
@@ -122,3 +122,24 @@
close(fd);
return 0;
}
+
+int readFile(const char *path, char *buf, int *sizep)
+{
+ int fd = open(path, O_RDONLY);
+ int size;
+
+ if (fd < 0) {
+ ALOGE("Failed to open %s: %s", path, strerror(errno));
+ return -1;
+ }
+
+ size = read(fd, buf, *sizep);
+ if (size < 0) {
+ ALOGE("Failed to write %s: %s", path, strerror(errno));
+ close(fd);
+ return -1;
+ }
+ *sizep = size;
+ close(fd);
+ return 0;
+}