Diff between 9a0c3a540ef7d7f69f91d4266c2663a7b5dd7fe0 and 32f70b67709f6c6e1d0f4211ce8a93d43c038106

Changed Files

File Additions Deletions Status
obexd/plugins/filesystem.c +15 -15 modified
obexd/src/mimetype.c +1 -1 modified
obexd/src/mimetype.h +1 -1 modified
obexd/src/obex.c +7 -16 modified
obexd/src/obex.h +1 -1 modified

Full Patch

diff --git a/obexd/plugins/filesystem.c b/obexd/plugins/filesystem.c
index 7458674..dcc03ff 100644
--- a/obexd/plugins/filesystem.c
+++ b/obexd/plugins/filesystem.c
@@ -46,8 +46,8 @@
 
 #include "plugin.h"
 #include "logging.h"
-#include "mimetype.h"
 #include "obex.h"
+#include "mimetype.h"
 #include "service.h"
 
 #define EOL_CHARS "\n"
@@ -123,7 +123,7 @@ static gchar *file_stat_line(gchar *filename, struct stat *fstat,
 }
 
 static gpointer filesystem_open(const char *name, int oflag, mode_t mode,
-				size_t *size, int *err)
+		size_t *size, struct OBEX_session *os, int *err)
 {
 	struct stat stats;
 	struct statvfs buf;
@@ -246,7 +246,7 @@ static int capability_exec(const char **argv, int *output, int *err)
 }
 
 static gpointer capability_open(const char *name, int oflag, mode_t mode,
-				size_t *size, int *err)
+		size_t *size, struct OBEX_session *os, int *err)
 {
 	struct capability_object *object = NULL;
 	gchar *buf;
@@ -306,26 +306,25 @@ fail:
 }
 
 static gpointer folder_open(const char *name, int oflag, mode_t mode,
-				size_t *size, int *err)
+		size_t *size, struct OBEX_session *os, int *err)
 {
-	struct obex_session *os;
 	struct stat fstat, dstat;
 	struct dirent *ep;
-	DIR *dp;
+	const gchar *folder;
 	GString *object;
-	gboolean root, pcsuite;
-	int ret;
-
-	os = obex_get_session(NULL);
+	DIR *dp;
+	gboolean root, pcsuite, symlinks;
+	gint ret;
 
-	pcsuite = os->service->service & OBEX_PCSUITE ? TRUE : FALSE;
+	pcsuite = obex_get_service(os) & OBEX_PCSUITE ? TRUE : FALSE;
 
 	object = g_string_new(FL_VERSION);
 	object = g_string_append(object, pcsuite ? FL_TYPE_PCSUITE : FL_TYPE);
 
 	object = g_string_append(object, FL_BODY_BEGIN);
 
-	root = g_str_equal(name, os->server->folder);
+	folder = obex_get_folder(os);
+	root = g_str_equal(name, folder);
 
 	dp = opendir(name);
 	if (dp == NULL) {
@@ -334,7 +333,8 @@ static gpointer folder_open(const char *name, int oflag, mode_t mode,
 		goto failed;
 	}
 
-	if (root && os->server->symlinks)
+	symlinks = obex_get_symlinks(os);
+	if (root && symlinks)
 		ret = stat(name, &dstat);
 	else {
 		object = g_string_append(object, FL_PARENT_FOLDER_ELEMENT);
@@ -361,9 +361,9 @@ static gpointer folder_open(const char *name, int oflag, mode_t mode,
 			continue;
 		}
 
-		fullname = g_build_filename(os->current_folder, ep->d_name, NULL);
+		fullname = g_build_filename(folder, ep->d_name, NULL);
 
-		if (root && os->server->symlinks)
+		if (root && symlinks)
 			ret = stat(fullname, &fstat);
 		else
 			ret = lstat(fullname, &fstat);
diff --git a/obexd/src/mimetype.c b/obexd/src/mimetype.c
index e3e1f1b..02a7879 100644
--- a/obexd/src/mimetype.c
+++ b/obexd/src/mimetype.c
@@ -33,8 +33,8 @@
 #include <openobex/obex_const.h>
 
 #include "logging.h"
-#include "mimetype.h"
 #include "obex.h"
+#include "mimetype.h"
 
 static GSList *drivers = NULL;
 
diff --git a/obexd/src/mimetype.h b/obexd/src/mimetype.h
index d9f067f..8cecc94 100644
--- a/obexd/src/mimetype.h
+++ b/obexd/src/mimetype.h
@@ -30,7 +30,7 @@ struct obex_mime_type_driver {
 	const guint8 *target;
 	const char *mimetype;
 	gpointer (*open) (const char *name, int oflag, mode_t mode,
-				size_t *size, int *err);
+			size_t *size, struct OBEX_session *os, int *err);
 	int (*close) (gpointer object);
 	ssize_t (*read) (gpointer object, void *buf, size_t count);
 	ssize_t (*write) (gpointer object, const void *buf, size_t count);
diff --git a/obexd/src/obex.c b/obexd/src/obex.c
index 9db3e71..0484523 100644
--- a/obexd/src/obex.c
+++ b/obexd/src/obex.c
@@ -439,7 +439,7 @@ int obex_stream_start(struct OBEX_session *os, const gchar *filename)
 	gpointer object;
 	size_t size;
 
-	object = os->driver->open(filename, O_RDONLY, 0, &size, &err);
+	object = os->driver->open(filename, O_RDONLY, 0, &size, os, &err);
 	if (object == NULL) {
 		error("open(%s): %s (%d)", filename, strerror(-err), -err);
 		goto fail;
@@ -525,7 +525,7 @@ gint obex_prepare_put(struct obex_session *os)
 	path = g_build_filename(os->current_folder, os->name, NULL);
 	os->object = os->driver->open(path, O_WRONLY | O_CREAT | O_TRUNC, 0600,
 					os->size != OBJECT_SIZE_UNKNOWN ?
-					(size_t *) &os->size : NULL, &err);
+					(size_t *) &os->size : NULL, os, &err);
 	if (os->object == NULL) {
 		error("open(%s): %s (%d)", path, strerror(-err), -err);
 		g_free(path);
@@ -1087,20 +1087,6 @@ gint obex_tty_session_stop(void)
 	return 0;
 }
 
-struct obex_session *obex_get_session(gpointer object)
-{
-	GSList *l;
-
-	for (l = sessions; l; l = l->next) {
-		struct obex_session *os = l->data;
-
-		if (os->object == object)
-			return os;
-	}
-
-	return NULL;
-}
-
 const char *obex_get_name(struct OBEX_session *os)
 {
 	return os->name;
@@ -1140,6 +1126,11 @@ const char *obex_get_root_folder(struct OBEX_session *os)
 	return os->server->folder;
 }
 
+guint16 obex_get_service(struct OBEX_session *os)
+{
+	return os->service->service;
+}
+
 gboolean obex_get_symlinks(struct OBEX_session *os)
 {
 	return os->server->symlinks;
diff --git a/obexd/src/obex.h b/obexd/src/obex.h
index d0e70e2..12f6117 100644
--- a/obexd/src/obex.h
+++ b/obexd/src/obex.h
@@ -88,7 +88,6 @@ struct obex_session {
 void obex_connect_cb(GIOChannel *io, GError *err, gpointer user_data);
 
 gint obex_session_start(GIOChannel *io, struct server *server);
-struct obex_session *obex_get_session(gpointer object);
 int obex_stream_start(struct OBEX_session *os, const gchar *filename);
 gint obex_prepare_put(struct obex_session *os);
 const char *obex_get_name(struct OBEX_session *os);
@@ -98,6 +97,7 @@ const char *obex_get_type(struct OBEX_session *os);
 const char *obex_get_folder(struct OBEX_session *os);
 void obex_set_folder(struct OBEX_session *os, const char *folder);
 const char *obex_get_root_folder(struct OBEX_session *os);
+guint16 obex_get_service(struct OBEX_session *os);
 gboolean obex_get_symlinks(struct OBEX_session *os);
 const char *obex_get_capability_path(struct OBEX_session *os);
 gboolean obex_get_auto_accept(struct OBEX_session *os);