X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=gtk%2Fgtkmountoperation-x11.c;h=fe8beb6949d86652e5c6eb244071f9640cd35dc0;hb=d484721b5ca9e82d6422cca8a3a40f001208f87b;hp=a20c8cf428a08e7041501c3bc59bcad6b3439f32;hpb=6a278af6d2aaa8466fbc1750fbcc6cd56e1f4cdd;p=~andy%2Fgtk
diff --git a/gtk/gtkmountoperation-x11.c b/gtk/gtkmountoperation-x11.c
index a20c8cf42..fe8beb694 100644
--- a/gtk/gtkmountoperation-x11.c
+++ b/gtk/gtkmountoperation-x11.c
@@ -15,9 +15,7 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see .
*/
/*
@@ -42,10 +40,14 @@
#include
#include
-#include "gtkmountoperationprivate.h"
-
-#include "gtkalias.h"
+#if defined(__OpenBSD__)
+#include
+#include
+#include
+#include
+#endif
+#include "gtkmountoperationprivate.h"
/* ---------------------------------------------------------------------------------------------------- */
/* these functions are based on code from libwnck (LGPLv2) */
@@ -186,9 +188,6 @@ find_largest_sizes (gulong *data,
while (nitems > 0)
{
int w, h;
- gboolean replace;
-
- replace = FALSE;
if (nitems < 3)
return FALSE; /* no space for w, h */
@@ -717,6 +716,96 @@ pid_get_command_line (GPid pid)
}
/* ---------------------------------------------------------------------------------------------------- */
+
+#elif defined(__OpenBSD__)
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+static GPid
+pid_get_parent (GPid pid)
+{
+ struct kinfo_proc kp;
+ size_t len;
+ GPid ppid;
+
+ int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, pid,
+ sizeof(struct kinfo_proc), 0 };
+
+ if (sysctl(mib, G_N_ELEMENTS (mib), NULL, &len, NULL, 0) == -1)
+ return (-1);
+ mib[5] = (len / sizeof(struct kinfo_proc));
+
+ if (sysctl(mib, G_N_ELEMENTS (mib), &kp, &len, NULL, 0) < 0)
+ return -1;
+
+ ppid = kp.p_ppid;
+
+ return ppid;
+}
+
+static gchar *
+pid_get_env (GPid pid, const gchar *key)
+{
+ size_t len = PATH_MAX;
+ char **strs = NULL;
+ char *ret;
+ char *end;
+ int key_len;
+ int i;
+
+ int mib[] = { CTL_KERN, KERN_PROC_ARGS, pid, KERN_PROC_ENV };
+
+ strs = (char **)realloc(strs, len);
+
+ key_len = strlen (key);
+
+ ret = NULL;
+ if (sysctl(mib, G_N_ELEMENTS (mib), strs, &len, NULL, 0) != -1)
+ {
+ for (i = 0; strs[i] != NULL; i++)
+ {
+ if (g_str_has_prefix (strs[i], key) && (*(strs[i] + key_len) == '='))
+ {
+ ret = g_strdup (strs[i] + key_len + 1);
+
+ /* skip invalid UTF-8 */
+ if (!g_utf8_validate (ret, -1, (const gchar **) &end))
+ *end = '\0';
+ break;
+ }
+ }
+ }
+
+ g_free (strs);
+ return ret;
+}
+
+static gchar *
+pid_get_command_line (GPid pid)
+{
+ size_t len = PATH_MAX;
+ char **strs = NULL;
+ char *ret = NULL;
+ char *end;
+
+ int mib[] = { CTL_KERN, KERN_PROC_ARGS, pid, KERN_PROC_ARGV };
+
+ strs = (char **)realloc(strs, len);
+
+ if (sysctl(mib, G_N_ELEMENTS (mib), strs, &len, NULL, 0) == -1) {
+ g_free (strs);
+ return ret;
+ }
+
+ ret = g_strjoinv (" ", strs);
+ /* skip invalid UTF-8 */
+ if (!g_utf8_validate (ret, -1, (const gchar **) &end))
+ *end = '\0';
+
+ g_free (strs);
+ return ret;
+}
+
#else
/* TODO: please implement for your OS - must return valid UTF-8 */
@@ -963,7 +1052,7 @@ _gtk_mount_operation_kill_process (GPid pid,
g_set_error (error,
G_IO_ERROR,
g_io_error_from_errno (errsv),
- _("Cannot end process with pid %d: %s"),
+ _("Cannot end process with PID %d: %s"),
pid,
g_strerror (errsv));
}