summaryrefslogtreecommitdiff
path: root/document-portal
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2016-05-06 16:03:27 +0200
committerAlexander Larsson <alexl@redhat.com>2016-05-06 16:03:27 +0200
commit1ffdf27d927c7944e3bce9b1cd3c101d823fd826 (patch)
treeb91268da5ea5f1d224977ce4e5bbb75386d9a424 /document-portal
parentafa12a446fcc473eb740146805856e76ad82b4af (diff)
downloadxdg-app-1ffdf27d927c7944e3bce9b1cd3c101d823fd826.tar.gz
uncruftify: Initial run, all non-problematic changes
Diffstat (limited to 'document-portal')
-rw-r--r--document-portal/xdp-enums.h10
-rw-r--r--document-portal/xdp-fuse.c385
-rw-r--r--document-portal/xdp-fuse.h14
-rw-r--r--document-portal/xdp-main.c147
-rw-r--r--document-portal/xdp-util.c8
-rw-r--r--document-portal/xdp-util.h38
6 files changed, 325 insertions, 277 deletions
diff --git a/document-portal/xdp-enums.h b/document-portal/xdp-enums.h
index 4169fab..7a3d743 100644
--- a/document-portal/xdp-enums.h
+++ b/document-portal/xdp-enums.h
@@ -4,12 +4,12 @@
G_BEGIN_DECLS
typedef enum {
- XDP_PERMISSION_FLAGS_READ = (1<<0),
- XDP_PERMISSION_FLAGS_WRITE = (1<<1),
- XDP_PERMISSION_FLAGS_GRANT_PERMISSIONS = (1<<2),
- XDP_PERMISSION_FLAGS_DELETE = (1<<3),
+ XDP_PERMISSION_FLAGS_READ = (1 << 0),
+ XDP_PERMISSION_FLAGS_WRITE = (1 << 1),
+ XDP_PERMISSION_FLAGS_GRANT_PERMISSIONS = (1 << 2),
+ XDP_PERMISSION_FLAGS_DELETE = (1 << 3),
- XDP_PERMISSION_FLAGS_ALL = ((1<<4) - 1)
+ XDP_PERMISSION_FLAGS_ALL = ((1 << 4) - 1)
} XdpPermissionFlags;
G_END_DECLS
diff --git a/document-portal/xdp-fuse.c b/document-portal/xdp-fuse.c
index 845d47e..53476fd 100644
--- a/document-portal/xdp-fuse.c
+++ b/document-portal/xdp-fuse.c
@@ -43,15 +43,16 @@ typedef enum {
typedef struct _XdpInode XdpInode;
-struct _XdpInode {
+struct _XdpInode
+{
gint ref_count; /* atomic */
/* These are all immutable */
- fuse_ino_t ino;
+ fuse_ino_t ino;
XdpInodeType type;
- XdpInode *parent;
- char *app_id;
- char *doc_id;
+ XdpInode *parent;
+ char *app_id;
+ char *doc_id;
/* For doc dirs */
char *basename;
@@ -61,31 +62,32 @@ struct _XdpInode {
/* mutable data */
- GList *children; /* lazily filled, protected by inodes lock */
- char *filename; /* variable (for non-dirs), null if deleted,
- protected by inodes lock *and* mutex */
+ GList *children; /* lazily filled, protected by inodes lock */
+ char *filename; /* variable (for non-dirs), null if deleted,
+ protected by inodes lock *and* mutex */
gboolean is_doc; /* True if this is the document file for this dir */
/* Used when the file is open, protected by mutex */
- GMutex mutex; /* Always lock inodes lock (if needed) before mutex */
- GList *open_files;
- int dir_fd;
- int fd; /* RW fd for tempfiles, RO fd for doc files */
- char *backing_filename;
- char *trunc_filename;
- int trunc_fd;
+ GMutex mutex; /* Always lock inodes lock (if needed) before mutex */
+ GList *open_files;
+ int dir_fd;
+ int fd; /* RW fd for tempfiles, RO fd for doc files */
+ char *backing_filename;
+ char *trunc_filename;
+ int trunc_fd;
gboolean truncated;
};
typedef struct _XdpFile XdpFile;
-struct _XdpFile {
+struct _XdpFile
+{
XdpInode *inode;
- int open_mode;
+ int open_mode;
};
-#define ROOT_INODE 1
-#define BY_APP_INODE 2
+#define ROOT_INODE 1
+#define BY_APP_INODE 2
#define BY_APP_NAME "by-app"
static GHashTable *dir_to_inode_nr;
@@ -95,7 +97,7 @@ static XdpInode *root_inode;
static XdpInode *by_app_inode;
static fuse_ino_t next_inode_nr = 3;
-G_LOCK_DEFINE(inodes);
+G_LOCK_DEFINE (inodes);
static GThread *fuse_thread = NULL;
static struct fuse_session *session = NULL;
@@ -107,6 +109,7 @@ static int
reopen_fd (int fd, int flags)
{
g_autofree char *path = g_strdup_printf ("/proc/self/fd/%d", fd);
+
return open (path, flags | O_CLOEXEC);
}
@@ -131,7 +134,9 @@ get_dir_inode_nr_unlocked (const char *app_id, const char *doc_id)
g_autofree char *dir = NULL;
if (app_id == NULL)
- dir = g_strdup (doc_id);
+ {
+ dir = g_strdup (doc_id);
+ }
else
{
if (doc_id == NULL)
@@ -142,17 +147,17 @@ get_dir_inode_nr_unlocked (const char *app_id, const char *doc_id)
res = g_hash_table_lookup (dir_to_inode_nr, dir);
if (res != NULL)
- return (fuse_ino_t)(gsize)res;
+ return (fuse_ino_t) (gsize) res;
allocated = allocate_inode_unlocked ();
- g_hash_table_insert (dir_to_inode_nr, g_strdup (dir), (gpointer)allocated);
+ g_hash_table_insert (dir_to_inode_nr, g_strdup (dir), (gpointer) allocated);
return allocated;
}
static fuse_ino_t
get_dir_inode_nr (const char *app_id, const char *doc_id)
{
- AUTOLOCK(inodes);
+ AUTOLOCK (inodes);
return get_dir_inode_nr_unlocked (app_id, doc_id);
}
@@ -160,7 +165,8 @@ static void
allocate_app_dir_inode_nr (char **app_ids)
{
int i;
- AUTOLOCK(inodes);
+
+ AUTOLOCK (inodes);
for (i = 0; app_ids[i] != NULL; i++)
get_dir_inode_nr_unlocked (app_ids[i], NULL);
}
@@ -172,7 +178,7 @@ get_allocated_app_dirs (void)
gpointer key, value;
GPtrArray *array = g_ptr_array_new ();
- AUTOLOCK(inodes);
+ AUTOLOCK (inodes);
g_hash_table_iter_init (&iter, dir_to_inode_nr);
while (g_hash_table_iter_next (&iter, &key, &value))
{
@@ -185,13 +191,14 @@ get_allocated_app_dirs (void)
}
}
g_ptr_array_add (array, NULL);
- return (char **)g_ptr_array_free (array, FALSE);
+ return (char **) g_ptr_array_free (array, FALSE);
}
-static void xdp_inode_unref_internal (XdpInode *inode, gboolean locked);
+static void xdp_inode_unref_internal (XdpInode *inode,
+ gboolean locked);
static void xdp_inode_unref (XdpInode *inode);
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(XdpInode, xdp_inode_unref)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (XdpInode, xdp_inode_unref)
static void
xdp_inode_destroy (XdpInode *inode, gboolean locked)
@@ -227,11 +234,11 @@ xdp_inode_unref_internal (XdpInode *inode, gboolean locked)
return;
/* here we want to atomically do: if (ref_count>1) { ref_count--; return; } */
- retry_atomic_decrement1:
+retry_atomic_decrement1:
old_ref = g_atomic_int_get (&inode->ref_count);
if (old_ref > 1)
{
- if (!g_atomic_int_compare_and_exchange ((int *)&inode->ref_count, old_ref, old_ref - 1))
+ if (!g_atomic_int_compare_and_exchange ((int *) &inode->ref_count, old_ref, old_ref - 1))
goto retry_atomic_decrement1;
}
else
@@ -243,20 +250,20 @@ xdp_inode_unref_internal (XdpInode *inode, gboolean locked)
}
/* Protect against revival from xdp_inode_lookup() */
if (!locked)
- G_LOCK(inodes);
- if (!g_atomic_int_compare_and_exchange ((int *)&inode->ref_count, old_ref, old_ref - 1))
+ G_LOCK (inodes);
+ if (!g_atomic_int_compare_and_exchange ((int *) &inode->ref_count, old_ref, old_ref - 1))
{
if (!locked)
- G_UNLOCK(inodes);
+ G_UNLOCK (inodes);
goto retry_atomic_decrement1;
}
- g_hash_table_remove (inodes, (gpointer)inode->ino);
+ g_hash_table_remove (inodes, (gpointer) inode->ino);
if (inode->parent)
inode->parent->children = g_list_remove (inode->parent->children, inode);
if (!locked)
- G_UNLOCK(inodes);
+ G_UNLOCK (inodes);
xdp_inode_destroy (inode, locked);
}
@@ -269,12 +276,12 @@ xdp_inode_unref (XdpInode *inode)
}
static XdpInode *
-xdp_inode_new_unlocked (fuse_ino_t ino,
+xdp_inode_new_unlocked (fuse_ino_t ino,
XdpInodeType type,
- XdpInode *parent,
- const char *filename,
- const char *app_id,
- const char *doc_id)
+ XdpInode *parent,
+ const char *filename,
+ const char *app_id,
+ const char *doc_id)
{
XdpInode *inode;
@@ -292,20 +299,20 @@ xdp_inode_new_unlocked (fuse_ino_t ino,
if (parent)
parent->children = g_list_prepend (parent->children, inode);
- g_hash_table_insert (inodes, (gpointer)ino, inode);
+ g_hash_table_insert (inodes, (gpointer) ino, inode);
return inode;
}
static XdpInode *
-xdp_inode_new (fuse_ino_t ino,
+xdp_inode_new (fuse_ino_t ino,
XdpInodeType type,
- XdpInode *parent,
- const char *filename,
- const char *app_id,
- const char *doc_id)
+ XdpInode *parent,
+ const char *filename,
+ const char *app_id,
+ const char *doc_id)
{
- AUTOLOCK(inodes);
+ AUTOLOCK (inodes);
return xdp_inode_new_unlocked (ino, type, parent, filename, app_id, doc_id);
}
@@ -314,7 +321,7 @@ xdp_inode_lookup_unlocked (fuse_ino_t inode_nr)
{
XdpInode *inode;
- inode = g_hash_table_lookup (inodes, (gpointer)inode_nr);
+ inode = g_hash_table_lookup (inodes, (gpointer) inode_nr);
if (inode != NULL)
return xdp_inode_ref (inode);
return NULL;
@@ -325,7 +332,7 @@ xdp_inode_list_children (XdpInode *inode)
{
GList *list = NULL, *l;
- AUTOLOCK(inodes);
+ AUTOLOCK (inodes);
for (l = inode->children; l != NULL; l = l->next)
{
XdpInode *child = l->data;
@@ -354,7 +361,7 @@ xdp_inode_lookup_child_unlocked (XdpInode *inode, const char *filename)
static XdpInode *
xdp_inode_lookup_child (XdpInode *inode, const char *filename)
{
- AUTOLOCK(inodes);
+ AUTOLOCK (inodes);
return xdp_inode_lookup_child_unlocked (inode, filename);
}
@@ -433,7 +440,7 @@ xdp_inode_unlink_child (XdpInode *dir, const char *filename)
XdpInode *child_inode;
glnx_fd_close int dir_fd = -1;
- AUTOLOCK(inodes);
+ AUTOLOCK (inodes);
child_inode = xdp_inode_lookup_child_unlocked (dir, filename);
if (child_inode == NULL)
return NULL;
@@ -458,7 +465,7 @@ xdp_inode_unlink_child (XdpInode *dir, const char *filename)
/* Sets errno */
static int
-xdp_inode_rename_child (XdpInode *dir,
+xdp_inode_rename_child (XdpInode *dir,
const char *src_filename,
const char *dst_filename)
{
@@ -467,7 +474,7 @@ xdp_inode_rename_child (XdpInode *dir,
glnx_fd_close int dir_fd = -1;
int res;
- AUTOLOCK(inodes);
+ AUTOLOCK (inodes);
src_inode = xdp_inode_lookup_child_unlocked (dir, src_filename);
if (src_inode == NULL)
{
@@ -568,7 +575,7 @@ xdp_inode_rename_child (XdpInode *dir,
char *
xdp_inode_get_filename (XdpInode *inode)
{
- AUTOLOCK(inodes);
+ AUTOLOCK (inodes);
return g_strdup (inode->filename);
}
@@ -579,7 +586,7 @@ xdp_inode_ensure_document_file (XdpInode *dir)
g_assert (dir->type == XDP_INODE_APP_DOC_DIR || dir->type == XDP_INODE_DOC_DIR);
- AUTOLOCK(inodes);
+ AUTOLOCK (inodes);
inode = xdp_inode_lookup_child_unlocked (dir, dir->basename);
if (inode == NULL)
@@ -603,7 +610,7 @@ create_tmp_for_doc (XdpInode *dir, int dir_fd, int flags, mode_t mode, int *fd_o
g_autofree char *template = g_strconcat (".xdp_", dir->basename, ".XXXXXX", NULL);
int fd;
- fd = xdg_app_mkstempat (dir_fd, template, flags|O_CLOEXEC, mode);
+ fd = xdg_app_mkstempat (dir_fd, template, flags | O_CLOEXEC, mode);
if (fd == -1)
return NULL;
@@ -614,11 +621,11 @@ create_tmp_for_doc (XdpInode *dir, int dir_fd, int flags, mode_t mode, int *fd_o
/* sets errno */
static XdpInode *
-xdp_inode_create_file (XdpInode *dir,
+xdp_inode_create_file (XdpInode *dir,
const char *filename,
- mode_t mode,
- gboolean truncate,
- gboolean exclusive)
+ mode_t mode,
+ gboolean truncate,
+ gboolean exclusive)
{
XdpInode *inode;
g_autofree char *backing_filename = NULL;
@@ -630,7 +637,7 @@ xdp_inode_create_file (XdpInode *dir,
g_assert (dir->type == XDP_INODE_APP_DOC_DIR || dir->type == XDP_INODE_DOC_DIR);
- AUTOLOCK(inodes);
+ AUTOLOCK (inodes);
inode = xdp_inode_lookup_child_unlocked (dir, filename);
if (inode != NULL)
@@ -661,7 +668,7 @@ xdp_inode_create_file (XdpInode *dir,
if (is_doc)
{
backing_filename = g_strdup (filename);
- int flags = O_CREAT|O_RDONLY|O_NOFOLLOW|O_CLOEXEC;
+ int flags = O_CREAT | O_RDONLY | O_NOFOLLOW | O_CLOEXEC;
if (exclusive)
flags |= O_EXCL;
@@ -711,7 +718,7 @@ xdp_inode_create_file (XdpInode *dir,
static XdpInode *
xdp_inode_lookup (fuse_ino_t inode_nr)
{
- AUTOLOCK(inodes);
+ AUTOLOCK (inodes);
return xdp_inode_lookup_unlocked (inode_nr);
}
@@ -770,12 +777,12 @@ xdp_inode_get_dir_unlocked (const char *app_id, const char *doc_id, XdgAppDbEntr
static XdpInode *
xdp_inode_get_dir (const char *app_id, const char *doc_id, XdgAppDbEntry *entry)
{
- AUTOLOCK(inodes);
+ AUTOLOCK (inodes);
return xdp_inode_get_dir_unlocked (app_id, doc_id, entry);
}
/********************************************************************** \
- * FUSE Implementation
+* FUSE Implementation
\***********************************************************************/
static int
@@ -837,7 +844,7 @@ xdp_inode_locked_get_write_fd (XdpInode *inode)
}
static int
-xdp_inode_stat (XdpInode *inode,
+xdp_inode_stat (XdpInode *inode,
struct stat *stbuf)
{
stbuf->st_ino = inode->ino;
@@ -859,7 +866,7 @@ xdp_inode_stat (XdpInode *inode,
case XDP_INODE_DOC_FILE:
{
- g_autoptr (XdgAppDbEntry) entry = NULL;
+ g_autoptr(XdgAppDbEntry) entry = NULL;
struct stat tmp_stbuf;
gboolean can_see, can_write;
int fd, res, errsv;
@@ -884,7 +891,9 @@ xdp_inode_stat (XdpInode *inode,
fd = xdp_inode_locked_get_fd (inode);
if (fd != -1)
- res = fstat (fd, &tmp_stbuf);
+ {
+ res = fstat (fd, &tmp_stbuf);
+ }
else
{
glnx_fd_close int dir_fd = xdp_inode_open_dir_fd (inode->parent);
@@ -927,14 +936,14 @@ xdp_inode_stat (XdpInode *inode,
}
static void
-xdp_fuse_lookup (fuse_req_t req,
- fuse_ino_t parent,
+xdp_fuse_lookup (fuse_req_t req,
+ fuse_ino_t parent,
const char *name)
{
g_autoptr(XdpInode) parent_inode = NULL;
struct fuse_entry_param e = {0};
g_autoptr(XdpInode) child_inode = NULL;
- g_autoptr (XdgAppDbEntry) entry = NULL;
+ g_autoptr(XdgAppDbEntry) entry = NULL;
g_debug ("xdp_fuse_lookup %lx/%s -> ", parent, name);
@@ -954,7 +963,9 @@ xdp_fuse_lookup (fuse_req_t req,
{
case XDP_INODE_ROOT:
if (strcmp (name, BY_APP_NAME) == 0)
- child_inode = xdp_inode_ref (by_app_inode);
+ {
+ child_inode = xdp_inode_ref (by_app_inode);
+ }
else
{
entry = xdp_lookup_doc (name);
@@ -1024,7 +1035,7 @@ xdp_fuse_lookup (fuse_req_t req,
e.ino = child_inode->ino;
- g_debug ("xdp_fuse_lookup <- inode %lx", (long)e.ino);
+ g_debug ("xdp_fuse_lookup <- inode %lx", (long) e.ino);
xdp_inode_ref (child_inode); /* Ref given to the kernel, returned in xdp_fuse_forget() */
fuse_reply_entry (req, &e);
}
@@ -1037,7 +1048,9 @@ xdp_fuse_forget (fuse_req_t req, fuse_ino_t ino, unsigned long nlookup)
inode = xdp_inode_lookup (ino);
if (inode == NULL)
- g_warning ("xdp_fuse_forget, unknown inode");
+ {
+ g_warning ("xdp_fuse_forget, unknown inode");
+ }
else
{
while (nlookup > 0)
@@ -1050,21 +1063,23 @@ xdp_fuse_forget (fuse_req_t req, fuse_ino_t ino, unsigned long nlookup)
fuse_reply_none (req);
}
-struct dirbuf {
- char *p;
+struct dirbuf
+{
+ char *p;
size_t size;
};
static void
-dirbuf_add (fuse_req_t req,
+dirbuf_add (fuse_req_t req,
struct dirbuf *b,
- const char *name,
- fuse_ino_t ino,
- mode_t mode)
+ const char *name,
+ fuse_ino_t ino,
+ mode_t mode)
{
struct stat stbuf;
size_t oldsize = b->size;
+
b->size += fuse_add_direntry (req, NULL, 0, name, NULL, 0);
b->p = (char *) g_realloc (b->p, b->size);
memset (&stbuf, 0, sizeof (stbuf));
@@ -1077,9 +1092,9 @@ dirbuf_add (fuse_req_t req,
}
static void
-dirbuf_add_docs (fuse_req_t req,
+dirbuf_add_docs (fuse_req_t req,
struct dirbuf *b,
- const char *app_id)
+ const char *app_id)
{
g_auto(GStrv) docs = NULL;
fuse_ino_t ino;
@@ -1101,11 +1116,11 @@ dirbuf_add_docs (fuse_req_t req,
}
static int
-reply_buf_limited (fuse_req_t req,
+reply_buf_limited (fuse_req_t req,
const char *buf,
- size_t bufsize,
- off_t off,
- size_t maxsize)
+ size_t bufsize,
+ off_t off,
+ size_t maxsize)
{
if (off < bufsize)
return fuse_reply_buf (req, buf + off,
@@ -1118,14 +1133,14 @@ static void
xdp_fuse_readdir (fuse_req_t req, fuse_ino_t ino, size_t size,
off_t off, struct fuse_file_info *fi)
{
- struct dirbuf *b = (struct dirbuf *)(fi->fh);
+ struct dirbuf *b = (struct dirbuf *) (fi->fh);
reply_buf_limited (req, b->p, b->size, off, size);
}
static void
-xdp_fuse_opendir (fuse_req_t req,
- fuse_ino_t ino,
+xdp_fuse_opendir (fuse_req_t req,
+ fuse_ino_t ino,
struct fuse_file_info *fi)
{
g_autoptr(XdpInode) inode = NULL;
@@ -1187,7 +1202,7 @@ xdp_fuse_opendir (fuse_req_t req,
{
GList *children, *l;
g_autoptr(XdpInode) doc_inode = NULL;
- g_autoptr (XdgAppDbEntry) entry = NULL;
+ g_autoptr(XdgAppDbEntry) entry = NULL;
entry = xdp_lookup_doc (inode->doc_id);
if (entry == NULL)
@@ -1223,21 +1238,22 @@ xdp_fuse_opendir (fuse_req_t req,
if (b.p != NULL)
{
- fi->fh = (gsize)g_memdup (&b, sizeof (b));
+ fi->fh = (gsize) g_memdup (&b, sizeof (b));
if (fuse_reply_open (req, fi) == -ENOENT)
{
g_free (b.p);
- g_free ((gpointer)(fi->fh));
+ g_free ((gpointer) (fi->fh));
}
}
}
static void
-xdp_fuse_releasedir (fuse_req_t req,
- fuse_ino_t ino,
+xdp_fuse_releasedir (fuse_req_t req,
+ fuse_ino_t ino,
struct fuse_file_info *fi)
{
- struct dirbuf *b = (struct dirbuf *)(fi->fh);
+ struct dirbuf *b = (struct dirbuf *) (fi->fh);
+
g_free (b->p);
g_free (b);
fuse_reply_err (req, 0);
@@ -1246,8 +1262,8 @@ xdp_fuse_releasedir (fuse_req_t req,
static void
-xdp_fuse_getattr (fuse_req_t req,
- fuse_ino_t ino,
+xdp_fuse_getattr (fuse_req_t req,
+ fuse_ino_t ino,
struct fuse_file_info *fi)
{
g_autoptr(XdpInode) inode = NULL;
@@ -1273,9 +1289,9 @@ xdp_fuse_getattr (fuse_req_t req,
}
static void
-xdp_fuse_fsyncdir (fuse_req_t req,
- fuse_ino_t ino,
- int datasync,
+xdp_fuse_fsyncdir (fuse_req_t req,
+ fuse_ino_t ino,
+ int datasync,
struct fuse_file_info *fi)
{
g_autoptr(XdpInode) inode = NULL;
@@ -1293,11 +1309,11 @@ xdp_fuse_fsyncdir (fuse_req_t req,
if (inode->type == XDP_INODE_APP_DOC_DIR ||
inode->type == XDP_INODE_DOC_DIR)
{
- g_autoptr (XdgAppDbEntry) entry = xdp_lookup_doc (inode->doc_id);
+ g_autoptr(XdgAppDbEntry) entry = xdp_lookup_doc (inode->doc_id);
if (entry != NULL)
{
g_autofree char *dirname = xdp_entry_dup_dirname (entry);
- int fd = open (dirname, O_DIRECTORY|O_RDONLY);
+ int fd = open (dirname, O_DIRECTORY | O_RDONLY);
if (fd >= 0)
{
if (datasync)
@@ -1314,9 +1330,10 @@ xdp_fuse_fsyncdir (fuse_req_t req,
static XdpFile *
xdp_file_new (XdpInode *inode,
- int open_mode)
+ int open_mode)
{
XdpFile *file = g_new (XdpFile, 1);
+
file->inode = xdp_inode_ref (inode);
file->open_mode = open_mode;
@@ -1414,9 +1431,9 @@ xdp_file_free (XdpFile *file)
/* sets errno */
static int
-xdp_inode_locked_ensure_fd_open (XdpInode *inode,
+xdp_inode_locked_ensure_fd_open (XdpInode *inode,
XdgAppDbEntry *entry,
- gboolean for_write)
+ gboolean for_write)
{
/* Ensure all fds are open */
if (inode->dir_fd == -1)
@@ -1434,7 +1451,7 @@ xdp_inode_locked_ensure_fd_open (XdpInode *inode,
if (inode->fd == -1)
{
- int mode = O_NOFOLLOW|O_CLOEXEC;
+ int mode = O_NOFOLLOW | O_CLOEXEC;
if (inode->is_doc)
mode |= O_RDONLY;
@@ -1465,8 +1482,8 @@ xdp_inode_locked_ensure_fd_open (XdpInode *inode,
}
static void
-xdp_fuse_open (fuse_req_t req,
- fuse_ino_t ino,
+xdp_fuse_open (fuse_req_t req,
+ fuse_ino_t ino,
struct fuse_file_info *fi)
{
g_autoptr(XdpInode) inode = NULL;
@@ -1532,24 +1549,26 @@ xdp_fuse_open (fuse_req_t req,
if (file != NULL)
{
- fi->fh = (gsize)file;
+ fi->fh = (gsize) file;
if (fuse_reply_open (req, fi))
xdp_file_free (file);
}
else
- fuse_reply_err (req, errsv);
+ {
+ fuse_reply_err (req, errsv);
+ }
}
static void
-xdp_fuse_create (fuse_req_t req,
- fuse_ino_t parent,
- const char *filename,
- mode_t mode,
+xdp_fuse_create (fuse_req_t req,
+ fuse_ino_t parent,
+ const char *filename,
+ mode_t mode,
struct fuse_file_info *fi)
{
g_autoptr(XdpInode) parent_inode = NULL;
- g_autoptr (XdgAppDbEntry) entry = NULL;
+ g_autoptr(XdgAppDbEntry) entry = NULL;
struct fuse_entry_param e = {0};
gboolean can_see, can_write;
int open_mode;
@@ -1654,7 +1673,7 @@ xdp_fuse_create (fuse_req_t req,
xdp_inode_ref (inode); /* Ref given to the kernel, returned in xdp_fuse_forget() */
- fi->fh = (gsize)file;
+ fi->fh = (gsize) file;
if (fuse_reply_create (req, &e, fi))
{
xdp_file_free (file);
@@ -1662,22 +1681,24 @@ xdp_fuse_create (fuse_req_t req,
}
}
else
- fuse_reply_err (req, errsv);
+ {
+ fuse_reply_err (req, errsv);
+ }
}
static void
-xdp_fuse_read (fuse_req_t req,
- fuse_ino_t ino,
- size_t size,
- off_t off,
+xdp_fuse_read (fuse_req_t req,
+ fuse_ino_t ino,
+ size_t size,
+ off_t off,
struct fuse_file_info *fi)
{
- XdpFile *file = (gpointer)fi->fh;
+ XdpFile *file = (gpointer) fi->fh;
XdpInode *inode = file->inode;
struct fuse_bufvec bufv = FUSE_BUFVEC_INIT (size);
int fd;
- g_debug ("xdp_fuse_real %lx %ld %ld", ino, (long)size, (long)off);
+ g_debug ("xdp_fuse_real %lx %ld %ld", ino, (long) size, (long) off);
g_mutex_lock (&inode->mutex);
@@ -1703,12 +1724,12 @@ xdp_fuse_read (fuse_req_t req,
g_mutex_unlock (&inode->mutex);
}
-static void
-xdp_fuse_release (fuse_req_t req,
- fuse_ino_t ino,
+static void
+xdp_fuse_release (fuse_req_t req,
+ fuse_ino_t ino,
struct fuse_file_info *fi)
{
- XdpFile *file = (gpointer)fi->fh;
+ XdpFile *file = (gpointer) fi->fh;
g_debug ("xdp_fuse_release %lx (fi=%p)", ino, fi);
@@ -1736,10 +1757,10 @@ truncateat (int dir_fd, const char *filename, int size)
}
static void
-xdp_fuse_setattr (fuse_req_t req,
- fuse_ino_t ino,
- struct stat *attr,
- int to_set,
+xdp_fuse_setattr (fuse_req_t req,
+ fuse_ino_t ino,
+ struct stat *attr,
+ int to_set,
struct fuse_file_info *fi)
{
g_autoptr(XdpInode) inode = NULL;
@@ -1782,7 +1803,9 @@ xdp_fuse_setattr (fuse_req_t req,
g_mutex_lock (&inode->mutex);
if (!can_write)
- res = EACCES;
+ {
+ res = EACCES;
+ }
else if (inode->is_doc)
{
/* Only allow ftruncate with the file open for write. We could
@@ -1794,13 +1817,19 @@ xdp_fuse_setattr (fuse_req_t req,
* trunc_fd.
*/
if (inode->trunc_fd == -1)
- res = EACCES;
+ {
+ res = EACCES;
+ }
else if (!inode->truncated && attr->st_size != 0)
- res = ENOSYS;
+ {
+ res = ENOSYS;
+ }
else
{
if (ftruncate (inode->trunc_fd, attr->st_size) != 0)
- res = errno;
+ {
+ res = errno;
+ }
else if (!inode->truncated)
{
inode->truncated = TRUE;
@@ -1829,7 +1858,9 @@ xdp_fuse_setattr (fuse_req_t req,
else if (to_set == FUSE_SET_ATTR_MODE)
{
if (!can_write)
- res = EACCES;
+ {
+ res = EACCES;
+ }
else
{
int fd = xdp_inode_locked_get_write_fd (inode);
@@ -1839,10 +1870,14 @@ xdp_fuse_setattr (fuse_req_t req,
}
}
else
- res = ENOSYS;
+ {
+ res = ENOSYS;
+ }
if (res != 0)
- fuse_reply_err (req, ENOSYS);
+ {
+ fuse_reply_err (req, ENOSYS);
+ }
else
{
if (xdp_inode_stat (inode, &newattr) != 0)
@@ -1852,26 +1887,28 @@ xdp_fuse_setattr (fuse_req_t req,
}
}
-static void
-xdp_fuse_write (fuse_req_t req,
- fuse_ino_t ino,
- const char *buf,
- size_t size,
- off_t off,
+static void
+xdp_fuse_write (fuse_req_t req,
+ fuse_ino_t ino,
+ const char *buf,
+ size_t size,
+ off_t off,
struct fuse_file_info *fi)
{
- XdpFile *file = (gpointer)fi->fh;
+ XdpFile *file = (gpointer) fi->fh;
XdpInode *inode = file->inode;
int fd;
int res;
- g_debug ("xdp_fuse_write %lx %ld %ld", ino, (long)size, (long)off);
+ g_debug ("xdp_fuse_write %lx %ld %ld", ino, (long) size, (long) off);
g_mutex_lock (&inode->mutex);
fd = xdp_inode_locked_get_write_fd (inode);
if (fd < 0)
- fuse_reply_err (req, errno);
+ {
+ fuse_reply_err (req, errno);
+ }
else
{
res = pwrite (fd, buf, size, off);
@@ -1885,25 +1922,27 @@ xdp_fuse_write (fuse_req_t req,
}
static void
-xdp_fuse_write_buf (fuse_req_t req,
- fuse_ino_t ino,
- struct fuse_bufvec *bufv,
- off_t off,
+xdp_fuse_write_buf (fuse_req_t req,
+ fuse_ino_t ino,
+ struct fuse_bufvec *bufv,
+ off_t off,
struct fuse_file_info *fi)
{
- XdpFile *file = (gpointer)fi->fh;
- struct fuse_bufvec dst = FUSE_BUFVEC_INIT(fuse_buf_size(bufv));
+ XdpFile *file = (gpointer) fi->fh;
+ struct fuse_bufvec dst = FUSE_BUFVEC_INIT (fuse_buf_size (bufv));
XdpInode *inode = file->inode;
int fd;
int res;
- g_debug ("xdp_fuse_write_buf %lx %ld", ino, (long)off);
+ g_debug ("xdp_fuse_write_buf %lx %ld", ino, (long) off);
g_mutex_lock (&inode->mutex);
fd = xdp_inode_locked_get_write_fd (inode);
if (fd == -1)
- fuse_reply_err (req, errno);
+ {
+ fuse_reply_err (req, errno);
+ }
else
{
dst.buf[0].flags = FUSE_BUF_IS_FD | FUSE_BUF_FD_SEEK;
@@ -1921,9 +1960,9 @@ xdp_fuse_write_buf (fuse_req_t req,
}
static void
-xdp_fuse_fsync (fuse_req_t req,
- fuse_ino_t ino,
- int datasync,
+xdp_fuse_fsync (fuse_req_t req,
+ fuse_ino_t ino,
+ int datasync,
struct fuse_file_info *fi)
{
g_autoptr(XdpInode) inode = NULL;
@@ -1955,8 +1994,8 @@ xdp_fuse_fsync (fuse_req_t req,
}
static void
-xdp_fuse_unlink (fuse_req_t req,
- fuse_ino_t parent,
+xdp_fuse_unlink (fuse_req_t req,
+ fuse_ino_t parent,
const char *filename)
{
g_autoptr(XdpInode) parent_inode = NULL;
@@ -1996,14 +2035,14 @@ xdp_fuse_unlink (fuse_req_t req,
}
static void
-xdp_fuse_rename (fuse_req_t req,
- fuse_ino_t parent,
+xdp_fuse_rename (fuse_req_t req,
+ fuse_ino_t parent,
const char *name,
- fuse_ino_t newparent,
+ fuse_ino_t newparent,
const char *newname)
{
g_autoptr(XdpInode) parent_inode = NULL;
- g_autoptr (XdgAppDbEntry) entry = NULL;
+ g_autoptr(XdgAppDbEntry) entry = NULL;
gboolean can_see, can_write;
g_debug ("xdp_fuse_rename %lx/%s -> %lx/%s", parent, name, newparent, newname);
@@ -2093,8 +2132,8 @@ static struct fuse_lowlevel_ops xdp_fuse_oper = {
/* Called when a apps permissions to see a document is changed,
and with null opt_app_id when the doc is created/removed */
void
-xdp_fuse_invalidate_doc_app (const char *doc_id,
- const char *opt_app_id)
+xdp_fuse_invalidate_doc_app (const char *doc_id,
+ const char *opt_app_id)
{
g_autoptr(XdpInode) inode = NULL;
fuse_ino_t ino;
@@ -2107,7 +2146,7 @@ xdp_fuse_invalidate_doc_app (const char *doc_id,
g_debug ("invalidate %s/%s", doc_id, opt_app_id ? opt_app_id : "*");
- AUTOLOCK(inodes);
+ AUTOLOCK (inodes);
ino = get_dir_inode_nr_unlocked (opt_app_id, doc_id);
inode = xdp_inode_lookup_unlocked (ino);
if (inode != NULL)
@@ -2148,7 +2187,7 @@ const char *
xdp_fuse_get_mountpoint (void)
{
if (mount_path == NULL)
- mount_path = g_build_filename (g_get_user_runtime_dir(), "doc", NULL);
+ mount_path = g_build_filename (g_get_user_runtime_dir (), "doc", NULL);
return mount_path;
}
@@ -2172,7 +2211,7 @@ xdp_fuse_mainloop (gpointer data)
fuse_session_loop_mt (session);
- fuse_session_remove_chan(main_ch);
+ fuse_session_remove_chan (main_ch);
fuse_session_destroy (session);
fuse_unmount (mount_path, main_ch);
return NULL;
@@ -2182,7 +2221,7 @@ gboolean
xdp_fuse_init (GError **error)
{
char *argv[] = { "xdp-fuse", "-osplice_write,splice_move,splice_read" };
- struct fuse_args args = FUSE_ARGS_INIT(G_N_ELEMENTS(argv), argv);
+ struct fuse_args args = FUSE_ARGS_INIT (G_N_ELEMENTS (argv), argv);
struct stat st;
const char *mount_path;
@@ -2197,13 +2236,13 @@ xdp_fuse_init (GError **error)
if (stat (mount_path, &st) == -1 && errno == ENOTCONN)
{
- char *argv[] = { "fusermount", "-u", (char *)mount_path, NULL };
+ char *argv[] = { "fusermount", "-u", (char *) mount_path, NULL };
g_spawn_sync (NULL, argv, NULL, G_SPAWN_SEARCH_PATH,
NULL, NULL, NULL, NULL, NULL, NULL);
}
- if (g_mkdir_with_parents (mount_path, 0700))
+ if (g_mkdir_with_parents (mount_path, 0700))
{
g_set_error (error, XDG_APP_PORTAL_ERROR, XDG_APP_PORTAL_ERROR_FAILED,
"Unable to create dir %s", mount_path);
diff --git a/document-portal/xdp-fuse.h b/document-portal/xdp-fuse.h
index ef46a82..4b7c10f 100644
--- a/document-portal/xdp-fuse.h
+++ b/document-portal/xdp-fuse.h
@@ -6,15 +6,15 @@
G_BEGIN_DECLS
-char ** xdp_list_apps (void);
-char ** xdp_list_docs (void);
+char ** xdp_list_apps (void);
+char ** xdp_list_docs (void);
XdgAppDbEntry *xdp_lookup_doc (const char *doc_id);
-gboolean xdp_fuse_init (GError **error);
-void xdp_fuse_exit (void);
-const char *xdp_fuse_get_mountpoint (void);
-void xdp_fuse_invalidate_doc_app (const char *doc_id,
- const char *opt_app_id);
+gboolean xdp_fuse_init (GError **error);
+void xdp_fuse_exit (void);
+const char *xdp_fuse_get_mountpoint (void);
+void xdp_fuse_invalidate_doc_app (const char *doc_id,
+ const char *opt_app_id);
char *xdp_fuse_lookup_id_for_inode (ino_t inode);
diff --git a/document-portal/xdp-main.c b/document-portal/xdp-main.c
index 4b7a2e5..8b243e2 100644
--- a/document-portal/xdp-main.c
+++ b/document-portal/xdp-main.c
@@ -25,10 +25,10 @@
typedef struct
{
- char *doc_id;
- int fd;
- char *owner;
- guint flags;
+ char *doc_id;
+ int fd;
+ char *owner;
+ guint flags;
GDBusMethodInvocation *finish_invocation;
} XdpDocUpdate;
@@ -41,26 +41,26 @@ static int daemon_event_fd = -1;
static int final_exit_status = 0;
static dev_t fuse_dev = 0;
-G_LOCK_DEFINE(db);
+G_LOCK_DEFINE (db);
char **
xdp_list_apps (void)
{
- AUTOLOCK(db);
+ AUTOLOCK (db);
return xdg_app_db_list_apps (db);
}
char **
xdp_list_docs (void)
{
- AUTOLOCK(db);
+ AUTOLOCK (db);
return xdg_app_db_list_ids (db);
}
XdgAppDbEntry *
xdp_lookup_doc (const char *doc_id)
{
- AUTOLOCK(db);
+ AUTOLOCK (db);
return xdg_app_db_lookup (db, doc_id);
}
@@ -73,12 +73,13 @@ persist_entry (XdgAppDbEntry *entry)
}
static void
-do_set_permissions (XdgAppDbEntry *entry,
- const char *doc_id,
- const char *app_id,
+do_set_permissions (XdgAppDbEntry *entry,
+ const char *doc_id,
+ const char *app_id,
XdpPermissionFlags perms)
{
g_autofree const char **perms_s = xdg_unparse_permissions (perms);
+
g_autoptr(XdgAppDbEntry) new_entry = NULL;
g_debug ("set_permissions %s %s %x", doc_id, app_id, perms);
@@ -87,31 +88,34 @@ do_set_permissions (XdgAppDbEntry *entry,
xdg_app_db_set_entry (db, doc_id, new_entry);
if (persist_entry (new_entry))
- xdg_app_permission_store_call_set_permission (permission_store,
- TABLE_NAME,
- FALSE,
- doc_id,
- app_id,
- perms_s,
- NULL,
- NULL, NULL);
+ {
+ xdg_app_permission_store_call_set_permission (permission_store,
+ TABLE_NAME,
+ FALSE,
+ doc_id,
+ app_id,
+ perms_s,
+ NULL,
+ NULL, NULL);
+ }
}
static void
portal_grant_permissions (GDBusMethodInvocation *invocation,
- GVariant *parameters,
- const char *app_id)
+ GVariant *parameters,
+ const char *app_id)
{
const char *target_app_id;
const char *id;
g_autofree const char **permissions = NULL;
XdpPermissionFlags perms;
+
g_autoptr(XdgAppDbEntry) entry = NULL;
g_variant_get (parameters, "(&s&s^a&s)", &id, &target_app_id, &permissions);
{
- AUTOLOCK(db);
+ AUTOLOCK (db);
entry = xdg_app_db_lookup (db, id);
if (entry == NULL)
@@ -151,19 +155,20 @@ portal_grant_permissions (GDBusMethodInvocation *invocation,
static void
portal_revoke_permissions (GDBusMethodInvocation *invocation,
- GVariant *parameters,
- const char *app_id)
+ GVariant *parameters,
+ const char *app_id)
{
const char *target_app_id;
const char *id;
g_autofree const char **permissions = NULL;
+
g_autoptr(XdgAppDbEntry) entry = NULL;
XdpPermissionFlags perms;
g_variant_get (parameters, "(&s&s^a&s)", &id, &target_app_id, &permissions);
{
- AUTOLOCK(db);
+ AUTOLOCK (db);
entry = xdg_app_db_lookup (db, id);
if (entry == NULL)
@@ -204,10 +209,11 @@ portal_revoke_permissions (GDBusMethodInvocation *invocation,
static void
portal_delete (GDBusMethodInvocation *invocation,
- GVariant *parameters,
- const char *app_id)
+ GVariant *parameters,
+ const char *app_id)
{
const char *id;
+
g_autoptr(XdgAppDbEntry) entry = NULL;
g_autofree const char **old_apps = NULL;
int i;
@@ -215,13 +221,13 @@ portal_delete (GDBusMethodInvocation *invocation,
g_variant_get (parameters, "(s)", &id);
{
- AUTOLOCK(db);
+ AUTOLOCK (db);
entry = xdg_app_db_lookup (db, id);
if (entry == NULL)
{
g_dbus_method_invocation_return_error (invocation, XDG_APP_PORTAL_ERROR, XDG_APP_PORTAL_ERROR_NOT_FOUND,
- "No such document: %s", id);
+ "No such document: %s", id);
return;
}
@@ -255,7 +261,7 @@ char *
do_create_doc (struct stat *parent_st_buf, const char *path, gboolean reuse_existing, gboolean persistent)
{
g_autoptr(GVariant) data = NULL;
- g_autoptr (XdgAppDbEntry) entry = NULL;
+ g_autoptr(XdgAppDbEntry) entry = NULL;
g_auto(GStrv) ids = NULL;
char *id = NULL;
guint32 flags = 0;
@@ -267,8 +273,8 @@ do_create_doc (struct stat *parent_st_buf, const char *path, gboolean reuse_exis
data =
g_variant_ref_sink (g_variant_new ("(^ayttu)",
path,
- (guint64)parent_st_buf->st_dev,
- (guint64)parent_st_buf->st_ino,
+ (guint64) parent_st_buf->st_dev,
+ (guint64) parent_st_buf->st_ino,
flags));
if (reuse_existing)
@@ -284,7 +290,7 @@ do_create_doc (struct stat *parent_st_buf, const char *path, gboolean reuse_exis
g_autoptr(XdgAppDbEntry) existing = NULL;
g_clear_pointer (&id, g_free);
- id = xdp_name_from_id ((guint32)g_random_int ());
+ id = xdp_name_from_id ((guint32) g_random_int ());
existing = xdg_app_db_lookup (db, id);
if (existing == NULL)
break;
@@ -296,21 +302,23 @@ do_create_doc (struct stat *parent_st_buf, const char *path, gboolean reuse_exis
xdg_app_db_set_entry (db, id, entry);
if (persistent)
- xdg_app_permission_store_call_set (permission_store,
- TABLE_NAME,
- TRUE,
- id,
- g_variant_new_array (G_VARIANT_TYPE("{sas}"), NULL, 0),
- g_variant_new_variant (data),
- NULL, NULL, NULL);
+ {
+ xdg_app_permission_store_call_set (permission_store,
+ TABLE_NAME,
+ TRUE,
+ id,
+ g_variant_new_array (G_VARIANT_TYPE ("{sas}"), NULL, 0),
+ g_variant_new_variant (data),
+ NULL, NULL, NULL);
+ }
return id;
}
static void
portal_add (GDBusMethodInvocation *invocation,
- GVariant *parameters,
- const char *app_id)
+ GVariant *parameters,
+ const char *app_id)
{
GDBusMessage *message;
GUnixFDList *fd_list;
@@ -319,7 +327,7 @@ portal_add (GDBusMethodInvocation *invocation,
int fd_id, fd, fds_len, fd_flags;
glnx_fd_close int dir_fd = -1;
const int *fds;
- char path_buffer[PATH_MAX+1];
+ char path_buffer[PATH_MAX + 1];
ssize_t symlink_size;
struct stat st_buf, real_st_buf, real_parent_st_buf;
g_autofree char *dirname = NULL;
@@ -369,7 +377,7 @@ portal_add (GDBusMethodInvocation *invocation,
could later replace a parent with a symlink and make us read some other file */
dirname = g_path_get_dirname (path_buffer);
name = g_path_get_basename (path_buffer);
- dir_fd = open (dirname, O_CLOEXEC|O_PATH);
+ dir_fd = open (dirname, O_CLOEXEC | O_PATH);
if (fstat (dir_fd, &real_parent_st_buf) < 0 ||
fstatat (dir_fd, name, &real_st_buf, AT_SYMLINK_NOFOLLOW) < 0 ||
@@ -403,7 +411,7 @@ portal_add (GDBusMethodInvocation *invocation,
/* Don't lock the db before doing the fuse call above, because it takes takes a lock
that can block something calling back, causing a deadlock on the db lock */
- AUTOLOCK(db);
+ AUTOLOCK (db);
/* If the entry doesn't exist anymore, fail. Also fail if not
resuse_existing, because otherwise the user could use this to
@@ -422,7 +430,7 @@ portal_add (GDBusMethodInvocation *invocation,
else
{
{
- AUTOLOCK(db);
+ AUTOLOCK (db);
id = do_create_doc (&real_parent_st_buf, path_buffer, reuse_existing, persistent);
@@ -458,8 +466,8 @@ portal_add (GDBusMethodInvocation *invocation,
static void
portal_add_named (GDBusMethodInvocation *invocation,
- GVariant *parameters,
- const char *app_id)
+ GVariant *parameters,
+ const char *app_id)
{
GDBusMessage *message;
GUnixFDList *fd_list;
@@ -467,12 +475,13 @@ portal_add_named (GDBusMethodInvocation *invocation,
g_autofree char *proc_path = NULL;
int parent_fd_id, parent_fd, fds_len, fd_flags;
const int *fds;
- char parent_path_buffer[PATH_MAX+1];
+ char parent_path_buffer[PATH_MAX + 1];
g_autofree char *path = NULL;
ssize_t symlink_size;
struct stat parent_st_buf;
const char *filename;
gboolean reuse_existing, persistent;
+
g_autoptr(GVariant) filename_v = NULL;
g_variant_get (parameters, "(h@aybb)", &parent_fd_id, &filename_v, &reuse_existing, &persistent);
@@ -542,7 +551,7 @@ portal_add_named (GDBusMethodInvocation *invocation,
g_debug ("portal_add_named %s", path);
- AUTOLOCK(db);
+ AUTOLOCK (db);
id = do_create_doc (&parent_st_buf, path, reuse_existing, persistent);
@@ -552,15 +561,16 @@ portal_add_named (GDBusMethodInvocation *invocation,
typedef void (*PortalMethod) (GDBusMethodInvocation *invocation,
- GVariant *parameters,
- const char *app_id);
+ GVariant *parameters,
+ const char *app_id);
static void
-got_app_id_cb (GObject *source_object,
+got_app_id_cb (GObject *source_object,
GAsyncResult *res,
- gpointer user_data)
+ gpointer user_data)
{
GDBusMethodInvocation *invocation = G_DBUS_METHOD_INVOCATION (source_object);
+
g_autoptr(GError) error = NULL;
g_autofree char *app_id = NULL;
PortalMethod portal_method = user_data;
@@ -574,7 +584,7 @@ got_app_id_cb (GObject *source_object,
}
static gboolean
-handle_method (GCallback method_callback,
+handle_method (GCallback method_callback,
GDBusMethodInvocation *invocation)
{
xdg_app_invocation_lookup_app_id (invocation, NULL, got_app_id_cb, method_callback);
@@ -695,9 +705,9 @@ exit_handler (int sig)
}
static int
-set_one_signal_handler (int sig,
+set_one_signal_handler (int sig,
void (*handler)(int),
- int remove)
+ int remove)
{
struct sigaction sa;
struct sigaction old_sa;
@@ -735,10 +745,10 @@ static GOptionEntry entries[] = {
};
static void
-message_handler (const gchar *log_domain,
+message_handler (const gchar *log_domain,
GLogLevelFlags log_level,
- const gchar *message,
- gpointer user_data)
+ const gchar *message,
+ gpointer user_data)
{
/* Make this look like normal console output */
if (log_level & G_LOG_LEVEL_DEBUG)
@@ -752,9 +762,10 @@ main (int argc,
char **argv)
{
guint owner_id;
+
g_autoptr(GError) error = NULL;
g_autofree char *path = NULL;
- GDBusConnection *session_bus;
+ GDBusConnection *session_bus;
GOptionContext *context;
setlocale (LC_ALL, "");
@@ -810,7 +821,7 @@ main (int argc,
do_exit (3);
}
- permission_store = xdg_app_permission_store_proxy_new_sync (session_bus,G_DBUS_PROXY_FLAGS_NONE,
+ permission_store = xdg_app_permission_store_proxy_new_sync (session_bus, G_DBUS_PROXY_FLAGS_NONE,
"org.freedesktop.XdgApp",
"/org/freedesktop/XdgApp/PermissionStore",
NULL, &error);
@@ -825,13 +836,11 @@ main (int argc,
g_signal_connect (session_bus, "closed", G_CALLBACK (session_bus_closed), NULL);
- if (set_one_signal_handler(SIGHUP, exit_handler, 0) == -1 ||
- set_one_signal_handler(SIGINT, exit_handler, 0) == -1 ||
- set_one_signal_handler(SIGTERM, exit_handler, 0) == -1 ||
- set_one_signal_handler(SIGPIPE, SIG_IGN, 0) == -1)
- {
- do_exit (5);
- }
+ if (set_one_signal_handler (SIGHUP, exit_handler, 0) == -1 ||
+ set_one_signal_handler (SIGINT, exit_handler, 0) == -1 ||
+ set_one_signal_handler (SIGTERM, exit_handler, 0) == -1 ||
+ set_one_signal_handler (SIGPIPE, SIG_IGN, 0) == -1)
+ do_exit (5);
owner_id = g_bus_own_name (G_BUS_TYPE_SESSION,
"org.freedesktop.portal.Documents",
diff --git a/document-portal/xdp-util.c b/document-portal/xdp-util.c
index 6725f41..c1c491a 100644
--- a/document-portal/xdp-util.c
+++ b/document-portal/xdp-util.c
@@ -22,7 +22,7 @@ xdg_unparse_permissions (XdpPermissionFlags permissions)
g_ptr_array_add (array, "delete");
g_ptr_array_add (array, NULL);
- return (const char **)g_ptr_array_free (array, FALSE);
+ return (const char **) g_ptr_array_free (array, FALSE);
}
XdpPermissionFlags
@@ -51,7 +51,7 @@ xdp_parse_permissions (const char **permissions)
XdpPermissionFlags
xdp_entry_get_permissions (XdgAppDbEntry *entry,
- const char *app_id)
+ const char *app_id)
{
g_autofree const char **permissions = NULL;
@@ -63,8 +63,8 @@ xdp_entry_get_permissions (XdgAppDbEntry *entry,
}
gboolean
-xdp_entry_has_permissions (XdgAppDbEntry *entry,
- const char *app_id,
+xdp_entry_has_permissions (XdgAppDbEntry *entry,
+ const char *app_id,
XdpPermissionFlags perms)
{
XdpPermissionFlags current_perms;
diff --git a/document-portal/xdp-util.h b/document-portal/xdp-util.h
index 77e0bae..d44ec8d 100644
--- a/document-portal/xdp-util.h
+++ b/document-portal/xdp-util.h
@@ -7,25 +7,25 @@
G_BEGIN_DECLS
-#define XDP_ENTRY_FLAG_UNIQUE (1<<0)
-#define XDP_ENTRY_FLAG_TRANSIENT (1<<1)
-
-const char ** xdg_unparse_permissions (XdpPermissionFlags permissions);
-XdpPermissionFlags xdp_parse_permissions (const char **permissions);
-
-XdpPermissionFlags xdp_entry_get_permissions (XdgAppDbEntry *entry,
- const char *app_id);
-gboolean xdp_entry_has_permissions (XdgAppDbEntry *entry,
- const char *app_id,
- XdpPermissionFlags perms);
-const char * xdp_entry_get_path (XdgAppDbEntry *entry);
-char * xdp_entry_dup_basename (XdgAppDbEntry *entry);
-char * xdp_entry_dup_dirname (XdgAppDbEntry *entry);
-guint64 xdp_entry_get_device (XdgAppDbEntry *entry);
-guint64 xdp_entry_get_inode (XdgAppDbEntry *entry);
-guint32 xdp_entry_get_flags (XdgAppDbEntry *entry);
-
-char * xdp_name_from_id (guint32 doc_id);
+#define XDP_ENTRY_FLAG_UNIQUE (1 << 0)
+#define XDP_ENTRY_FLAG_TRANSIENT (1 << 1)
+
+const char ** xdg_unparse_permissions (XdpPermissionFlags permissions);
+XdpPermissionFlags xdp_parse_permissions (const char **permissions);
+
+XdpPermissionFlags xdp_entry_get_permissions (XdgAppDbEntry *entry,
+ const char *app_id);
+gboolean xdp_entry_has_permissions (XdgAppDbEntry *entry,
+ const char *app_id,
+ XdpPermissionFlags perms);
+const char * xdp_entry_get_path (XdgAppDbEntry *entry);
+char * xdp_entry_dup_basename (XdgAppDbEntry *entry);
+char * xdp_entry_dup_dirname (XdgAppDbEntry *entry);
+guint64 xdp_entry_get_device (XdgAppDbEntry *entry);
+guint64 xdp_entry_get_inode (XdgAppDbEntry *entry);
+guint32 xdp_entry_get_flags (XdgAppDbEntry *entry);
+
+char * xdp_name_from_id (guint32 doc_id);
G_END_DECLS