OSDN Git Service

gobex: add root support to test-server
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fri, 26 Aug 2011 09:49:36 +0000 (12:49 +0300)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 4 Dec 2012 21:22:02 +0000 (22:22 +0100)
tools/obex-server-tool.c

index d7ffe50..728e2ad 100644 (file)
@@ -45,6 +45,7 @@ static GSList *clients = NULL;
 static gboolean option_packet = FALSE;
 static gboolean option_bluetooth = FALSE;
 static int option_channel = -1;
+static char *option_root = NULL;
 
 static void sig_term(int sig)
 {
@@ -63,6 +64,8 @@ static GOptionEntry options[] = {
                        &option_packet, "Packet based transport" },
        { "stream", 's', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE,
                        &option_packet, "Stream based transport" },
+       { "root", 'r', 0, G_OPTION_ARG_STRING,
+                       &option_root, "Root dir", "/..." },
        { NULL },
 };
 
@@ -411,6 +414,11 @@ int main(int argc, char *argv[])
                exit(EXIT_FAILURE);
        }
 
+       if (option_root && chdir(option_root) > 0) {
+               perror("chdir:");
+               exit(EXIT_FAILURE);
+       }
+
        if (option_bluetooth)
                server_id = bluetooth_listen();
        else