From: "Michał Poczwardowski" <dmp0x7c5@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: "Michał Poczwardowski" <dmp0x7c5@gmail.com>
Subject: [RFC v1 obexd 09/11] fuse: Add touch operation
Date: Sun, 21 Oct 2012 19:05:29 +0200 [thread overview]
Message-ID: <1350839131-12042-9-git-send-email-dmp0x7c5@gmail.com> (raw)
In-Reply-To: <1350839131-12042-1-git-send-email-dmp0x7c5@gmail.com>
---
fuse/helpers.c | 40 ++++++++++++++++++++++++++++++++++++++++
fuse/helpers.h | 1 +
fuse/obexfuse.c | 17 +++++++++++++++++
3 files changed, 58 insertions(+), 0 deletions(-)
diff --git a/fuse/helpers.c b/fuse/helpers.c
index b807f15..05948be 100644
--- a/fuse/helpers.c
+++ b/fuse/helpers.c
@@ -56,6 +56,8 @@ struct gobexhlp_location {
gchar *file;
};
+void gobexhlp_touch_real(struct gobexhlp_session* session, gchar *path);
+
static uint16_t find_rfcomm_uuid(void *user_data)
{
sdp_list_t *pds = (sdp_list_t*) user_data;
@@ -279,6 +281,12 @@ void request_new(struct gobexhlp_session *session,
{
g_print("REQUEST %s\n", name);
+ if (session->vtouch == TRUE) {
+ session->vtouch = FALSE;
+ gobexhlp_touch_real(session, session->vtouch_path);
+ g_free(session->vtouch_path);
+ }
+
if (session->request != NULL)
g_error("Another request (%s) active!\n",
session->request->name);
@@ -622,3 +630,35 @@ void gobexhlp_put(struct gobexhlp_session* session,
request_wait_free(session);
}
+/* virtual file creation */
+void gobexhlp_touch(struct gobexhlp_session* session, const char *path)
+{
+ struct stat *stbuf;
+
+ g_print("gobexhlp_touch(%s)\n", path);
+
+ stbuf = g_malloc0(sizeof(struct stat));
+ stbuf->st_mode = S_IFREG;
+ g_hash_table_replace(session->file_stat, g_strdup(path), stbuf);
+
+ session->vtouch = TRUE;
+ session->vtouch_path = g_strdup(path);
+}
+
+void gobexhlp_touch_real(struct gobexhlp_session* session, gchar *path)
+{
+ struct gobexhlp_buffer *buffer, *tmpbuf;
+
+ g_print("gobexhlp_touch_real(%s)\n", path);
+
+ tmpbuf = session->buffer; /* save buffer state */
+
+ buffer = g_malloc0(sizeof(struct gobexhlp_buffer));
+ session->rtouch = TRUE;
+ gobexhlp_put(session, buffer, path);
+ session->rtouch = FALSE;
+ g_free(buffer);
+
+ session->buffer = tmpbuf;
+}
+
diff --git a/fuse/helpers.h b/fuse/helpers.h
index 95987c4..da5f96c 100644
--- a/fuse/helpers.h
+++ b/fuse/helpers.h
@@ -59,4 +59,5 @@ struct gobexhlp_buffer *gobexhlp_get(struct gobexhlp_session* session,
void gobexhlp_put(struct gobexhlp_session* session,
struct gobexhlp_buffer *buffer,
const char *path);
+void gobexhlp_touch(struct gobexhlp_session* session, const char *path);
diff --git a/fuse/obexfuse.c b/fuse/obexfuse.c
index 900e6d7..b4599d8 100644
--- a/fuse/obexfuse.c
+++ b/fuse/obexfuse.c
@@ -215,6 +215,21 @@ static int obexfuse_release(const char *path, struct fuse_file_info *fi)
return session->status;
}
+static int obexfuse_utimens(const char *path, const struct timespec tv[2])
+{
+ /*
+ * Important for mknod (touch) operation
+ */
+ return 0;
+}
+
+static int obexfuse_mknod(const char *path, mode_t mode, dev_t dev)
+{
+ gobexhlp_touch(session, path);
+
+ return 0;
+}
+
static struct fuse_operations obexfuse_oper = {
.readdir = obexfuse_readdir,
.getattr = obexfuse_getattr,
@@ -223,6 +238,8 @@ static struct fuse_operations obexfuse_oper = {
.write = obexfuse_write,
.truncate = obexfuse_truncate,
.release = obexfuse_release,
+ .utimens = obexfuse_utimens,
+ .mknod = obexfuse_mknod,
.init = obexfuse_init,
.destroy = obexfuse_destroy,
};
--
1.7.8.6
next prev parent reply other threads:[~2012-10-21 17:05 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-21 17:05 [RFC v1 obexd 01/11] fuse: Add initial obexfuse files, fuse main and options parse Michał Poczwardowski
2012-10-21 17:05 ` [RFC v1 obexd 02/11] build: Add --enable-fuse for obexfuse Michał Poczwardowski
2012-10-21 17:05 ` [RFC v1 obexd 03/11] fuse: Add obexhlp_connect/disconnect functions with helpers Michał Poczwardowski
2012-10-21 17:05 ` [RFC v1 obexd 04/11] fuse: Add request helpers and setpath operation Michał Poczwardowski
2012-10-21 17:05 ` [RFC v1 obexd 05/11] fuse: Add readdir operation Michał Poczwardowski
2012-10-21 17:05 ` [RFC v1 obexd 06/11] fuse: Add getattr operation Michał Poczwardowski
2012-10-21 17:05 ` [RFC v1 obexd 07/11] fuse: Add open and read operations plus location helpers Michał Poczwardowski
2012-10-21 17:05 ` [RFC v1 obexd 08/11] fuse: Add write operation Michał Poczwardowski
2012-10-21 17:05 ` Michał Poczwardowski [this message]
2012-10-21 17:05 ` [RFC v1 obexd 10/11] fuse: Add unlink/rmdir operation Michał Poczwardowski
2012-10-21 17:05 ` [RFC v1 obexd 11/11] fuse: Add rename operation Michał Poczwardowski
2012-10-26 14:10 ` [RFC v1 obexd 01/11] fuse: Add initial obexfuse files, fuse main and options parse Luiz Augusto von Dentz
2012-10-26 14:14 ` Luiz Augusto von Dentz
2012-10-27 23:24 ` Michał Poczwardowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1350839131-12042-9-git-send-email-dmp0x7c5@gmail.com \
--to=dmp0x7c5@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox