diff options
author | Dan Winship <danw@gnome.org> | 2013-11-08 08:49:06 -0500 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2013-11-15 10:49:43 -0500 |
commit | 7bc7da83ec46143392d8657e1923adcc6a94794e (patch) | |
tree | ddea0bb2e66810f5b8bb898653508d4918431937 /src/NetworkManagerUtils.c | |
parent | 1981323b19f1ad22e53ef9ac1cd3783346e7c121 (diff) | |
download | NetworkManager-7bc7da83ec46143392d8657e1923adcc6a94794e.tar.gz |
core: remove redundant sysctl utilities
NMDevice was still using the old sysctl functions from
NetworkManagerUtils rather than the new NMPlatform ones. Fix it, and
remove the old functions.
Diffstat (limited to 'src/NetworkManagerUtils.c')
-rw-r--r-- | src/NetworkManagerUtils.c | 110 |
1 files changed, 0 insertions, 110 deletions
diff --git a/src/NetworkManagerUtils.c b/src/NetworkManagerUtils.c index e09b94acf8..c2cf5e7a50 100644 --- a/src/NetworkManagerUtils.c +++ b/src/NetworkManagerUtils.c @@ -408,116 +408,6 @@ value_hash_add_object_property (GHashTable *hash, value_hash_add (hash, key, value); } -/** - * nm_utils_do_sysctl: - * @path: path to write @value to - * @value: value to write to @path - * - * Writes @value to the file at @path, trying 3 times on failure. - * - * Returns: %TRUE on success. On failure, returns %FALSE and sets errno. - */ -gboolean -nm_utils_do_sysctl (const char *path, const char *value) -{ - int fd, len, nwrote, tries, saved_errno = 0; - char *actual; - - g_return_val_if_fail (path != NULL, FALSE); - g_return_val_if_fail (value != NULL, FALSE); - - fd = open (path, O_WRONLY | O_TRUNC); - if (fd == -1) { - saved_errno = errno; - nm_log_warn (LOGD_CORE, "sysctl: failed to open '%s': (%d) %s", - path, saved_errno, strerror (saved_errno)); - errno = saved_errno; - return FALSE; - } - - nm_log_dbg (LOGD_CORE, "sysctl: setting '%s' to '%s'", path, value); - - /* Most sysfs and sysctl options don't care about a trailing CR, while some - * (like infiniband) do. So always add the CR. Also, neither sysfs nor - * sysctl support partial writes so the CR must be added to the string we're - * about to write. - */ - actual = g_strdup_printf ("%s\n", value); - - /* Try to write the entire value three times if a partial write occurs */ - len = strlen (actual); - for (tries = 0, nwrote = 0; tries < 3 && nwrote != len; tries++) { - errno = 0; - nwrote = write (fd, actual, len); - if (nwrote == -1) { - if (errno == EINTR) - continue; - saved_errno = errno; - break; - } - } - g_free (actual); - close (fd); - - if (nwrote != len && saved_errno != EEXIST) { - nm_log_warn (LOGD_CORE, "sysctl: failed to set '%s' to '%s': (%d) %s", - path, value, saved_errno, strerror (saved_errno)); - } - - errno = saved_errno; - return (nwrote == len); -} - -gboolean -nm_utils_get_proc_sys_net_value (const char *path, - const char *iface, - gint32 *out_value) -{ - GError *error = NULL; - char *contents = NULL; - gboolean success = FALSE; - long int tmp; - - if (!g_file_get_contents (path, &contents, NULL, &error)) { - nm_log_dbg (LOGD_DEVICE, "(%s): error reading %s: (%d) %s", - iface, path, - error ? error->code : -1, - error && error->message ? error->message : "(unknown)"); - g_clear_error (&error); - } else { - errno = 0; - tmp = strtol (contents, NULL, 10); - if (errno == 0) { - *out_value = (gint32) tmp; - success = TRUE; - } - g_free (contents); - } - - return success; -} - -gboolean -nm_utils_get_proc_sys_net_value_with_bounds (const char *path, - const char *iface, - gint32 *out_value, - gint32 valid_min, - gint32 valid_max) -{ - gboolean result; - gint32 val; - - result = nm_utils_get_proc_sys_net_value (path, iface, &val); - - if (result) { - if (val >= valid_min && val <= valid_max) - *out_value = val; - else - result = FALSE; - } - - return result; -} static char * get_new_connection_name (const GSList *existing, |