aboutsummaryrefslogtreecommitdiffstats
path: root/src/usermap.h
diff options
context:
space:
mode:
authorMartin Pärtel <martin.partel@gmail.com>2012-03-13 16:53:07 +0200
committerMartin Pärtel <martin.partel@gmail.com>2012-03-13 16:53:07 +0200
commit66d6de935a32fbf3aae2ef091b417a6572c8e6fd (patch)
tree10ad62b92e4d87d08b7b6d1c10e4c502a59c9271 /src/usermap.h
parentc6375194b97c7f879357a3c31a74f8376b42d344 (diff)
downloadbindfs-66d6de935a32fbf3aae2ef091b417a6572c8e6fd.tar.gz
Added --map.
Diffstat (limited to 'src/usermap.h')
-rw-r--r--src/usermap.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/usermap.h b/src/usermap.h
new file mode 100644
index 0000000..8a74bb1
--- /dev/null
+++ b/src/usermap.h
@@ -0,0 +1,60 @@
+/*
+ Copyright 2012 Martin Pärtel <martin.partel@gmail.com>
+
+ This file is part of bindfs.
+
+ bindfs is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ bindfs is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with bindfs. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef INC_BINDFS_USERMAP_H
+#define INC_BINDFS_USERMAP_H
+
+#include <config.h>
+
+#include <stdio.h>
+#include <unistd.h>
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+/* A map of user IDs to userIDs and group IDs to group IDs. */
+struct UserMap;
+typedef struct UserMap UserMap;
+
+typedef enum UsermapStatus {
+ usermap_status_ok = 0,
+ usermap_status_duplicate_key = 1
+} UsermapStatus;
+
+UserMap *usermap_create();
+void usermap_destroy(UserMap *map);
+
+UsermapStatus usermap_add_uid(UserMap *map, uid_t from, uid_t to);
+UsermapStatus usermap_add_gid(UserMap *map, gid_t from, gid_t to);
+
+const char* usermap_errorstr(UsermapStatus status);
+
+/* Returns the uid that u is mapped to, or u if none. */
+uid_t usermap_get_uid(UserMap *map, uid_t u);
+
+/* Returns the gid that g is mapped to, or g if none. */
+gid_t usermap_get_gid(UserMap *map, gid_t g);
+
+/* Returns the uid that u is mapped to, or -1 if none. */
+uid_t usermap_get_uid_or_none(UserMap *map, uid_t u);
+
+/* Returns the gid that g is mapped to, or -1 if none. */
+gid_t usermap_get_gid_or_none(UserMap *map, gid_t g);
+
+#endif