Windows: separate parsemode from fs into own file
authorJeffrey Altman <jaltman@your-file-system.com>
Fri, 24 Dec 2010 18:36:51 +0000 (13:36 -0500)
committerJeffrey Altman <jaltman@openafs.org>
Tue, 28 Dec 2010 14:57:14 +0000 (06:57 -0800)
Separate parsemode() from fs.c into parsemode.c.

Restructure the function prototypes and the fs.h header
to permit building fs.exe from multiple source files.

Change-Id: I80840899706fd585addd165edc13a9e79928427a
Reviewed-on: http://gerrit.openafs.org/3591
Reviewed-by: Russ Allbery <rra@stanford.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Tested-by: Jeffrey Altman <jaltman@openafs.org>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>

src/WINNT/afsd/NTMakefile
src/WINNT/afsd/fs.c
src/WINNT/afsd/fs.h
src/WINNT/afsd/parsemode.c [new file with mode: 0644]
src/WINNT/afsd/parsemode.h [new file with mode: 0644]

index e24ffda..9b0480b 100644 (file)
@@ -160,7 +160,8 @@ $(OUT)\cm_conn.obj: cm_conn.c
 
 FSOBJS=$(OUT)\fs.obj \
        $(OUT)\fs_utils.obj \
-       $(OUT)\cm_nls.obj
+       $(OUT)\cm_nls.obj \
+       $(OUT)\parsemode.obj
 
 CMDBGOBJS=$(OUT)\cmdebug.obj
 
index 3006bc7..41af204 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <afs/stds.h>
 #include <afs/com_err.h>
+#include <afs/cmd.h>
 
 #include <windows.h>
 #include <stdlib.h>
@@ -41,6 +42,7 @@
 #include "cmd.h"
 #include "afsd.h"
 #include "cm_ioctl.h"
+#include "parsemode.h"
 
 #define MAXNAME 100
 #define MAXINSIZE 1300    /* pioctl complains if data is larger than this */
@@ -53,14 +55,24 @@ static char tspace[1024];
 
 static struct ubik_client *uclient;
 
+/* some forward references */
+static void ZapList (struct AclEntry *alist);
+
+static int PruneList (struct AclEntry **ae, int dfs);
+
+static int CleanAcl(struct Acl *aa, char *fname);
+
+static int SetVolCmd(struct cmd_syndesc *as, void *arock);
+
+static int GetCellName(char *cellNamep, struct afsconf_cell *infop);
+
+static int VLDBInit(int noAuthFlag, struct afsconf_cell *infop);
 static int GetClientAddrsCmd(struct cmd_syndesc *asp, void *arock);
 static int SetClientAddrsCmd(struct cmd_syndesc *asp, void *arock);
 static int FlushMountCmd(struct cmd_syndesc *asp, void *arock);
 static int RxStatProcCmd(struct cmd_syndesc *asp, void *arock);
 static int RxStatPeerCmd(struct cmd_syndesc *asp, void *arock);
 
-extern struct cmd_syndesc *cmd_CreateSyntax();
-
 static int MemDumpCmd(struct cmd_syndesc *asp, void *arock);
 static int CSCPolicyCmd(struct cmd_syndesc *asp, void *arock);
 static int MiniDumpCmd(struct cmd_syndesc *asp, void *arock);
@@ -5553,138 +5565,6 @@ ChGrpCmd(struct cmd_syndesc *as, void *arock)
 }
 
 
-#define USR_MODES (S_ISUID|S_IRWXU)
-#define GRP_MODES (S_ISGID|S_IRWXG)
-#define EXE_MODES (S_IXUSR|S_IXGRP|S_IXOTH)
-#ifdef S_ISVTX
-#define ALL_MODES (USR_MODES|GRP_MODES|S_IRWXO|S_ISVTX)
-#else
-#define ALL_MODES (USR_MODES|GRP_MODES|S_IRWXO)
-#endif
-
-/*
- * parsemode() is Copyright 1991 by Vincent Archer.
- *    You may freely redistribute this software, in source or binary
- *    form, provided that you do not alter this copyright mention in any
- *    way.
- */
-static afs_uint32
-parsemode(char *symbolic, afs_uint32 oldmode)
-{
-    afs_uint32 who, mask, u_mask = 022, newmode, tmpmask;
-    char action;
-
-    newmode = oldmode & ALL_MODES;
-    while (*symbolic) {
-        who = 0;
-        for (; *symbolic; symbolic++) {
-                if (*symbolic == 'a') {
-                        who |= ALL_MODES;
-                        continue;
-                }
-                if (*symbolic == 'u') {
-                        who |= USR_MODES;
-                        continue;
-                }
-                if (*symbolic == 'g') {
-                        who |= GRP_MODES;
-                        continue;
-                }
-                if (*symbolic == 'o') {
-                        who |= S_IRWXO;
-                        continue;
-                }
-                break;
-        }
-        if (!*symbolic || *symbolic == ',') {
-            Die(EINVAL, "invalid mode");
-            exit(1);
-        }
-        while (*symbolic) {
-            if (*symbolic == ',')
-                break;
-            switch (*symbolic) {
-            default:
-                Die(EINVAL, "invalid mode");
-                exit(1);
-            case '+':
-            case '-':
-            case '=':
-                action = *symbolic++;
-            }
-            mask = 0;
-            for (; *symbolic; symbolic++) {
-                if (*symbolic == 'u') {
-                    tmpmask = newmode & S_IRWXU;
-                    mask |= tmpmask | (tmpmask << 3) | (tmpmask << 6);
-                    symbolic++;
-                    break;
-                }
-                if (*symbolic == 'g') {
-                    tmpmask = newmode & S_IRWXG;
-                    mask |= tmpmask | (tmpmask >> 3) | (tmpmask << 3);
-                    symbolic++;
-                    break;
-                }
-                if (*symbolic == 'o') {
-                    tmpmask = newmode & S_IRWXO;
-                    mask |= tmpmask | (tmpmask >> 3) | (tmpmask >> 6);
-                    symbolic++;
-                    break;
-                }
-                if (*symbolic == 'r') {
-                    mask |= S_IRUSR | S_IRGRP | S_IROTH;
-                    continue;
-                }
-                if (*symbolic == 'w') {
-                    mask |= S_IWUSR | S_IWGRP | S_IWOTH;
-                    continue;
-                }
-                if (*symbolic == 'x') {
-                    mask |= EXE_MODES;
-                    continue;
-                }
-                if (*symbolic == 's') {
-                    mask |= S_ISUID | S_ISGID;
-                    continue;
-                }
-                if (*symbolic == 'X') {
-                    if (S_ISDIR(oldmode) || (oldmode & EXE_MODES))
-                        mask |= EXE_MODES;
-                    continue;
-                }
-                if (*symbolic == 't') {
-                    mask |= S_ISVTX;
-                    who |= S_ISVTX;
-                    continue;
-                }
-                break;
-            }
-            switch (action) {
-            case '=':
-                if (who)
-                    newmode &= ~who;
-                else
-                    newmode = 0;
-            case '+':
-                if (who)
-                    newmode |= who & mask;
-                else
-                    newmode |= mask & (~u_mask);
-                break;
-            case '-':
-                if (who)
-                    newmode &= ~(who & mask);
-                else
-                    newmode &= ~mask | u_mask;
-            }
-        }
-        if (*symbolic)
-            symbolic++;
-  }
-  return(newmode);
-}
-
 
 static int
 ChModCmd(struct cmd_syndesc *as, void *arock)
@@ -6168,7 +6048,7 @@ int wmain(int argc, wchar_t **wargv)
     return code;
 }
 
-static void 
+void
 Die(int code, char *filename)
 { /*Die*/
 
index 43516f7..c8a0545 100644 (file)
 #ifndef __FS_H_ENV__
 #define __FS_H_ENV__ 1
 
-/* some forward references */
-static void ZapList (struct AclEntry *alist);
+void Die(int code, char *filename);
 
-static int PruneList (struct AclEntry **ae, int dfs);
-
-static int CleanAcl(struct Acl *aa, char *fname);
-
-static int SetVolCmd(struct cmd_syndesc *as, void *arock);
-
-static int GetCellName(char *cellNamep, struct afsconf_cell *infop);
-
-static int VLDBInit(int noAuthFlag, struct afsconf_cell *infop);
-
-static void Die(int code, char *filename);
 #endif /* FS_H_ENV */
diff --git a/src/WINNT/afsd/parsemode.c b/src/WINNT/afsd/parsemode.c
new file mode 100644 (file)
index 0000000..c413f4d
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+ * Copyright 1991 by Vincent Archer.
+ *    You may freely redistribute this software, in source or binary
+ *    form, provided that you do not alter this copyright mention in any
+ *    way.
+ */
+
+#include <afsconfig.h>
+#include <afs/param.h>
+#include <roken.h>
+
+#include <stdlib.h>
+#include <sys/stat.h>
+#include "parsemode.h"
+#include "fs.h"
+
+afs_uint32
+parsemode(char *symbolic, afs_uint32 oldmode)
+{
+    afs_uint32 who, mask, u_mask = 022, newmode, tmpmask;
+    char action;
+
+    newmode = oldmode & ALL_MODES;
+    while (*symbolic) {
+        who = 0;
+        for (; *symbolic; symbolic++) {
+                if (*symbolic == 'a') {
+                        who |= ALL_MODES;
+                        continue;
+                }
+                if (*symbolic == 'u') {
+                        who |= USR_MODES;
+                        continue;
+                }
+                if (*symbolic == 'g') {
+                        who |= GRP_MODES;
+                        continue;
+                }
+                if (*symbolic == 'o') {
+                        who |= S_IRWXO;
+                        continue;
+                }
+                break;
+        }
+        if (!*symbolic || *symbolic == ',') {
+            Die(EINVAL, "invalid mode");
+            exit(1);
+        }
+        while (*symbolic) {
+            if (*symbolic == ',')
+                break;
+            switch (*symbolic) {
+            default:
+                Die(EINVAL, "invalid mode");
+                exit(1);
+            case '+':
+            case '-':
+            case '=':
+                action = *symbolic++;
+            }
+            mask = 0;
+            for (; *symbolic; symbolic++) {
+                if (*symbolic == 'u') {
+                    tmpmask = newmode & S_IRWXU;
+                    mask |= tmpmask | (tmpmask << 3) | (tmpmask << 6);
+                    symbolic++;
+                    break;
+                }
+                if (*symbolic == 'g') {
+                    tmpmask = newmode & S_IRWXG;
+                    mask |= tmpmask | (tmpmask >> 3) | (tmpmask << 3);
+                    symbolic++;
+                    break;
+                }
+                if (*symbolic == 'o') {
+                    tmpmask = newmode & S_IRWXO;
+                    mask |= tmpmask | (tmpmask >> 3) | (tmpmask >> 6);
+                    symbolic++;
+                    break;
+                }
+                if (*symbolic == 'r') {
+                    mask |= S_IRUSR | S_IRGRP | S_IROTH;
+                    continue;
+                }
+                if (*symbolic == 'w') {
+                    mask |= S_IWUSR | S_IWGRP | S_IWOTH;
+                    continue;
+                }
+                if (*symbolic == 'x') {
+                    mask |= EXE_MODES;
+                    continue;
+                }
+                if (*symbolic == 's') {
+                    mask |= S_ISUID | S_ISGID;
+                    continue;
+                }
+                if (*symbolic == 'X') {
+                    if (S_ISDIR(oldmode) || (oldmode & EXE_MODES))
+                        mask |= EXE_MODES;
+                    continue;
+                }
+                if (*symbolic == 't') {
+                    mask |= S_ISVTX;
+                    who |= S_ISVTX;
+                    continue;
+                }
+                break;
+            }
+            switch (action) {
+            case '=':
+                if (who)
+                    newmode &= ~who;
+                else
+                    newmode = 0;
+            case '+':
+                if (who)
+                    newmode |= who & mask;
+                else
+                    newmode |= mask & (~u_mask);
+                break;
+            case '-':
+                if (who)
+                    newmode &= ~(who & mask);
+                else
+                    newmode &= ~mask | u_mask;
+            }
+        }
+        if (*symbolic)
+            symbolic++;
+  }
+  return(newmode);
+}
+
diff --git a/src/WINNT/afsd/parsemode.h b/src/WINNT/afsd/parsemode.h
new file mode 100644 (file)
index 0000000..30ca6bc
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright 1991 by Vincent Archer.
+ *    You may freely redistribute this software, in source or binary
+ *    form, provided that you do not alter this copyright mention in any
+ *    way.
+ */
+
+#ifndef OPENAFS_WINNT_AFSD_PARSEMODE_H
+#define OPENAFS_WINNT_AFSD_PARSEMODE_H
+extern afs_uint32 parsemode(char *symbolic, afs_uint32 oldmode);
+
+#define USR_MODES (S_ISUID|S_IRWXU)
+#define GRP_MODES (S_ISGID|S_IRWXG)
+#define EXE_MODES (S_IXUSR|S_IXGRP|S_IXOTH)
+#ifdef S_ISVTX
+#define ALL_MODES (USR_MODES|GRP_MODES|S_IRWXO|S_ISVTX)
+#else
+#define ALL_MODES (USR_MODES|GRP_MODES|S_IRWXO)
+#endif
+
+#endif /* OPENAFS_WINNT_AFSD_PARSEMODE_H */