[Pvfs2-cvs] commit by sampson in pvfs2/src/client/windows/client-service: dokan-interface.c

CVS commit program cvs at parl.clemson.edu
Fri Apr 8 17:28:23 EDT 2011


Update of /projects/cvsroot/pvfs2/src/client/windows/client-service
In directory parlweb1:/tmp/cvs-serv14564/src/client/windows/client-service

Modified Files:
      Tag: windows-client
	dokan-interface.c 
Log Message:
Coding Windows permissions


Index: dokan-interface.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/client/windows/client-service/Attic/dokan-interface.c,v
diff -p -u -r1.1.2.27 -r1.1.2.28
--- dokan-interface.c	7 Apr 2011 21:49:14 -0000	1.1.2.27
+++ dokan-interface.c	8 Apr 2011 21:28:23 -0000	1.1.2.28
@@ -525,6 +525,42 @@ static void remove_credentials(ULONG64 c
 
 }
 
+/* Permission constants */
+#define PERM_READ    4
+#define PERM_WRITE   2
+#define PERM_EXECUTE 1
+
+/* Return true if user with credentials has permission (given attributes) */
+static int check_perm(PVFS_sys_attr *attr, PVFS_credentials *credentials, int perm)
+{
+    int mask;
+
+    /* root user (uid 0 or gid 0) always has rights */
+    if (credentials->uid == 0 || credentials->gid == 0)
+        return 1;
+        
+    if (attr->owner == credentials->uid)
+        /* use owner mask */
+        mask = (attr->perms >> 6) & 7;
+    else if (attr->group == credentials->gid)
+        /* use group mask (must be primary group) */
+        mask = (attr->perms >> 3) & 7;
+    else
+        /* use other mask */
+        mask = attr->perms & 7;
+
+    if (mask & perm)
+        return 1;
+
+    return 0;
+}
+
+/* Check permissions for create file call */
+static int check_create_perm(DWORD access_mode, PVFS_credentials *credentials, int perm)
+{
+    
+}
+
 static ULONG64 gen_context()
 {
     LARGE_INTEGER counter;
@@ -1050,8 +1086,9 @@ PVFS_Dokan_get_file_information(
         free(filename);
         ret = 0;
         
-        /* TODO
-           Check perms for READONLY */
+        /* Check perms for READONLY */
+        if (!check_perm(&attr, &credentials, PERM_WRITE))
+            HandleFileInformation->dwFileAttributes |= FILE_ATTRIBUTE_READONLY;
         
         /* check for temporary file */
         if (DokanFileInfo->DeleteOnClose)



More information about the Pvfs2-cvs mailing list