Merge "defer firmware load until after filesystems are mounted"
diff --git a/libnetutils/dhcp_utils.c b/libnetutils/dhcp_utils.c
index 030e677..af82a3c 100644
--- a/libnetutils/dhcp_utils.c
+++ b/libnetutils/dhcp_utils.c
@@ -31,6 +31,7 @@
static const char DHCP_PROP_NAME_PREFIX[] = "dhcp";
static const int NAP_TIME = 200; /* wait for 200ms at a time */
/* when polling for property values */
+static const char DAEMON_NAME_RENEW[] = "iprenew";
static char errmsg[100];
/*
@@ -138,6 +139,7 @@
uint32_t *lease)
{
char result_prop_name[PROPERTY_KEY_MAX];
+ char daemon_prop_name[PROPERTY_KEY_MAX];
char prop_value[PROPERTY_VALUE_MAX] = {'\0'};
char daemon_cmd[PROPERTY_VALUE_MAX * 2];
const char *ctrl_prop = "ctl.start";
@@ -146,18 +148,23 @@
snprintf(result_prop_name, sizeof(result_prop_name), "%s.%s.result",
DHCP_PROP_NAME_PREFIX,
interface);
+
+ snprintf(daemon_prop_name, sizeof(daemon_prop_name), "%s_%s",
+ DAEMON_PROP_NAME,
+ interface);
+
/* Erase any previous setting of the dhcp result property */
property_set(result_prop_name, "");
/* Start the daemon and wait until it's ready */
if (property_get(HOSTNAME_PROP_NAME, prop_value, NULL) && (prop_value[0] != '\0'))
- snprintf(daemon_cmd, sizeof(daemon_cmd), "%s:-h %s %s", DAEMON_NAME,
+ snprintf(daemon_cmd, sizeof(daemon_cmd), "%s_%s:-h %s %s", DAEMON_NAME, interface,
prop_value, interface);
else
- snprintf(daemon_cmd, sizeof(daemon_cmd), "%s:%s", DAEMON_NAME, interface);
+ snprintf(daemon_cmd, sizeof(daemon_cmd), "%s_%s:%s", DAEMON_NAME, interface, interface);
memset(prop_value, '\0', PROPERTY_VALUE_MAX);
property_set(ctrl_prop, daemon_cmd);
- if (wait_for_property(DAEMON_PROP_NAME, desired_status, 10) < 0) {
+ if (wait_for_property(daemon_prop_name, desired_status, 10) < 0) {
snprintf(errmsg, sizeof(errmsg), "%s", "Timed out waiting for dhcpcd to start");
return -1;
}
@@ -199,15 +206,24 @@
int dhcp_stop(const char *interface)
{
char result_prop_name[PROPERTY_KEY_MAX];
+ char daemon_prop_name[PROPERTY_KEY_MAX];
+ char daemon_cmd[PROPERTY_VALUE_MAX * 2];
const char *ctrl_prop = "ctl.stop";
const char *desired_status = "stopped";
snprintf(result_prop_name, sizeof(result_prop_name), "%s.%s.result",
DHCP_PROP_NAME_PREFIX,
interface);
+
+ snprintf(daemon_prop_name, sizeof(daemon_prop_name), "%s_%s",
+ DAEMON_PROP_NAME,
+ interface);
+
+ snprintf(daemon_cmd, sizeof(daemon_cmd), "%s_%s", DAEMON_NAME, interface);
+
/* Stop the daemon and wait until it's reported to be stopped */
- property_set(ctrl_prop, DAEMON_NAME);
- if (wait_for_property(DAEMON_PROP_NAME, desired_status, 5) < 0) {
+ property_set(ctrl_prop, daemon_cmd);
+ if (wait_for_property(daemon_prop_name, desired_status, 5) < 0) {
return -1;
}
property_set(result_prop_name, "failed");
@@ -219,12 +235,20 @@
*/
int dhcp_release_lease(const char *interface)
{
+ char daemon_prop_name[PROPERTY_KEY_MAX];
+ char daemon_cmd[PROPERTY_VALUE_MAX * 2];
const char *ctrl_prop = "ctl.stop";
const char *desired_status = "stopped";
+ snprintf(daemon_prop_name, sizeof(daemon_prop_name), "%s_%s",
+ DAEMON_PROP_NAME,
+ interface);
+
+ snprintf(daemon_cmd, sizeof(daemon_cmd), "%s_%s", DAEMON_NAME, interface);
+
/* Stop the daemon and wait until it's reported to be stopped */
- property_set(ctrl_prop, DAEMON_NAME);
- if (wait_for_property(DAEMON_PROP_NAME, desired_status, 5) < 0) {
+ property_set(ctrl_prop, daemon_cmd);
+ if (wait_for_property(daemon_prop_name, desired_status, 5) < 0) {
return -1;
}
return 0;
@@ -233,3 +257,53 @@
char *dhcp_get_errmsg() {
return errmsg;
}
+
+/**
+ * Run WiMAX dhcp renew service.
+ * "wimax_renew" service shoud be included in init.rc.
+ */
+int dhcp_do_request_renew(const char *interface,
+ in_addr_t *ipaddr,
+ in_addr_t *gateway,
+ in_addr_t *mask,
+ in_addr_t *dns1,
+ in_addr_t *dns2,
+ in_addr_t *server,
+ uint32_t *lease)
+{
+ char result_prop_name[PROPERTY_KEY_MAX];
+ char prop_value[PROPERTY_VALUE_MAX] = {'\0'};
+ char daemon_cmd[PROPERTY_VALUE_MAX * 2];
+ const char *ctrl_prop = "ctl.start";
+
+ snprintf(result_prop_name, sizeof(result_prop_name), "%s.%s.result",
+ DHCP_PROP_NAME_PREFIX,
+ interface);
+
+ /* Erase any previous setting of the dhcp result property */
+ property_set(result_prop_name, "");
+
+ /* Start the renew daemon and wait until it's ready */
+ snprintf(daemon_cmd, sizeof(daemon_cmd), "%s_%s:%s", DAEMON_NAME_RENEW, interface, interface);
+ memset(prop_value, '\0', PROPERTY_VALUE_MAX);
+ property_set(ctrl_prop, daemon_cmd);
+
+ /* Wait for the daemon to return a result */
+ if (wait_for_property(result_prop_name, NULL, 30) < 0) {
+ snprintf(errmsg, sizeof(errmsg), "%s", "Timed out waiting for DHCP Renew to finish");
+ return -1;
+ }
+
+ if (!property_get(result_prop_name, prop_value, NULL)) {
+ /* shouldn't ever happen, given the success of wait_for_property() */
+ snprintf(errmsg, sizeof(errmsg), "%s", "DHCP Renew result property was not set");
+ return -1;
+ }
+ if (strcmp(prop_value, "ok") == 0) {
+ fill_ip_info(interface, ipaddr, gateway, mask, dns1, dns2, server, lease);
+ return 0;
+ } else {
+ snprintf(errmsg, sizeof(errmsg), "DHCP Renew result was %s", prop_value);
+ return -1;
+ }
+}
diff --git a/sdcard/sdcard.c b/sdcard/sdcard.c
index fd003a7..bd00311 100644
--- a/sdcard/sdcard.c
+++ b/sdcard/sdcard.c
@@ -575,17 +575,50 @@
struct fuse_attr_out out;
char *path, buffer[PATH_BUFFER_SIZE];
int res = 0;
+ struct timespec times[2];
TRACE("SETATTR fh=%llx id=%llx valid=%x\n",
req->fh, hdr->nodeid, req->valid);
- /* XXX: incomplete implementation -- truncate only. chmod/chown
- * should NEVER be implemented. */
+ /* XXX: incomplete implementation on purpose. chmod/chown
+ * should NEVER be implemented.*/
path = node_get_path(node, buffer, 0);
if (req->valid & FATTR_SIZE)
res = truncate(path, req->size);
+ if (res)
+ goto getout;
+ /* Handle changing atime and mtime. If FATTR_ATIME_and FATTR_ATIME_NOW
+ * are both set, then set it to the current time. Else, set it to the
+ * time specified in the request. Same goes for mtime. Use utimensat(2)
+ * as it allows ATIME and MTIME to be changed independently, and has
+ * nanosecond resolution which fuse also has.
+ */
+ if (req->valid & (FATTR_ATIME | FATTR_MTIME)) {
+ times[0].tv_nsec = UTIME_OMIT;
+ times[1].tv_nsec = UTIME_OMIT;
+ if (req->valid & FATTR_ATIME) {
+ if (req->valid & FATTR_ATIME_NOW) {
+ times[0].tv_nsec = UTIME_NOW;
+ } else {
+ times[0].tv_sec = req->atime;
+ times[0].tv_nsec = req->atimensec;
+ }
+ }
+ if (req->valid & FATTR_MTIME) {
+ if (req->valid & FATTR_MTIME_NOW) {
+ times[1].tv_nsec = UTIME_NOW;
+ } else {
+ times[1].tv_sec = req->mtime;
+ times[1].tv_nsec = req->mtimensec;
+ }
+ }
+ TRACE("Calling utimensat on %s with atime %ld, mtime=%ld\n", path, times[0].tv_sec, times[1].tv_sec);
+ res = utimensat(-1, path, times, 0);
+ }
+
+ getout:
memset(&out, 0, sizeof(out));
node_get_attr(node, &out.attr);
out.attr_valid = 10;