[OpenAFS-devel] Patch: automount for Freelance Windows clients
Jeff Riegel
riegel@almaden.ibm.com
Wed, 31 Oct 2001 12:40:46 -0800
--ew6BAiZeqk4r7MaW
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
This patch provides an automount feature for the Windows clients with the
Freelance feature enabled. It will automatically add a mount point for a
cell's root.cell volume to the AFS root when a request is made to access
that cell. Mount points may still be added manually using "fs mkmount"
or the Explorer shell extension. We are looking into providing graphical
tools to edit and manage the AFS root directory's mount points.
This patch also contains a few makefile fixes which should fix the build
problems people have been experiencing.
These diffs are from the 10/19/2001 snapshot.
-Jeff
--ew6BAiZeqk4r7MaW
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="automount.txt"
diff -Nur --exclude-from=../exclude orig-src/WINNT/afsd/cm_cell.c src/WINNT/afsd/cm_cell.c
--- orig-src/WINNT/afsd/cm_cell.c Fri Oct 5 14:40:47 2001
+++ src/WINNT/afsd/cm_cell.c Tue Oct 30 19:35:55 2001
@@ -57,14 +57,23 @@
/* load up a cell structure from the cell database, afsdcell.ini */
cm_cell_t *cm_GetCell(char *namep, long flags)
{
+ return cm_GetCell_Gen(namep, NULL, flags);
+}
+
+cm_cell_t *cm_GetCell_Gen(char *namep, char *newnamep, long flags)
+{
cm_cell_t *cp;
long code;
static cellCounter = 1; /* locked by cm_cellLock */
int ttl;
+ char fullname[200];
lock_ObtainWrite(&cm_cellLock);
for(cp = cm_allCellsp; cp; cp=cp->nextp) {
- if (strcmp(namep, cp->namep) == 0) break;
+ if (strcmp(namep, cp->namep) == 0) {
+ strcpy(fullname, cp->namep);
+ break;
+ }
}
if ((!cp && (flags & CM_FLAG_CREATE))
@@ -75,10 +84,11 @@
) {
if (!cp) cp = malloc(sizeof(*cp));
memset(cp, 0, sizeof(*cp));
- code = cm_SearchCellFile(namep, NULL, cm_AddCellProc, cp);
+ code = cm_SearchCellFile(namep, fullname, cm_AddCellProc, cp);
+ if (code) {
#ifdef AFS_AFSDB_ENV
- if (code && cm_dnsEnabled) {
- code = cm_SearchCellByDNS(namep, NULL, &ttl, cm_AddCellProc, cp);
+ if (cm_dnsEnabled /*&& cm_DomainValid(namep)*/)
+ code = cm_SearchCellByDNS(namep, fullname, &ttl, cm_AddCellProc, cp);
#endif
if (code) {
free(cp);
@@ -90,8 +100,8 @@
cp->flags |= CM_CELLFLAG_DNS;
cp->timeout = time(0) + ttl;
}
- }
#endif
+ }
/* randomise among those vlservers having the same rank*/
cm_RandomizeServer(&cp->vlServersp);
@@ -100,8 +110,8 @@
lock_InitializeMutex(&cp->mx, "cm_cell_t mutex");
/* copy in name */
- cp->namep = malloc(strlen(namep)+1);
- strcpy(cp->namep, namep);
+ cp->namep = malloc(strlen(fullname)+1);
+ strcpy(cp->namep, fullname);
/* thread on global list */
cp->nextp = cm_allCellsp;
@@ -111,6 +121,8 @@
}
done:
+ if (newnamep)
+ strcpy(newnamep, fullname);
lock_ReleaseWrite(&cm_cellLock);
return cp;
}
diff -Nur --exclude-from=../exclude orig-src/WINNT/afsd/cm_cell.h src/WINNT/afsd/cm_cell.h
--- orig-src/WINNT/afsd/cm_cell.h Fri Oct 5 14:40:47 2001
+++ src/WINNT/afsd/cm_cell.h Tue Oct 30 19:40:06 2001
@@ -30,6 +30,8 @@
extern cm_cell_t *cm_GetCell(char *namep, long flags);
+extern cm_cell_t *cm_GetCell_Gen(char *namep, char *newnamep, long flags);
+
extern cm_cell_t *cm_FindCellByID(long cellID);
extern void cm_ChangeRankCellVLServer(cm_server_t *tsp);
diff -Nur --exclude-from=../exclude orig-src/WINNT/afsd/cm_freelance.c src/WINNT/afsd/cm_freelance.c
--- orig-src/WINNT/afsd/cm_freelance.c Mon Oct 8 21:57:31 2001
+++ src/WINNT/afsd/cm_freelance.c Tue Oct 30 19:35:44 2001
@@ -435,13 +435,25 @@
return 0;
}
-long cm_FreelanceAddMount(char *filename, char *cellname, char *volume)
+long cm_FreelanceAddMount(char *filename, char *cellname, char *volume, cm_fid_t *fidp)
{
FILE *fp;
char hfile[120];
char line[200];
+ char fullname[200];
int n;
+ /* before adding, verify the cell name; if it is not a valid cell,
+ don't add the mount point */
+ /* major performance issue? */
+ if (!cm_GetCell_Gen(cellname, fullname, CM_FLAG_CREATE))
+ return -1;
+#if 0
+ if (strcmp(cellname, fullname) != 0) /* no partial matches allowed */
+ return -1;
+#endif
+
lock_ObtainMutex(&cm_Freelance_Lock);
cm_GetConfigDir(hfile);
@@ -455,12 +467,17 @@
fseek(fp, 0, SEEK_SET);
fprintf(fp, "%d", n);
fseek(fp, 0, SEEK_END);
- fprintf(fp, "%s#%s:%s\n", filename, cellname, volume);
+ fprintf(fp, "%s#%s:%s\n", filename, fullname, volume);
fclose(fp);
lock_ReleaseMutex(&cm_Freelance_Lock);
+ /*cm_reInitLocalMountPoints(&vnode);*/
+ if (fidp) {
+ fidp->unique = 1;
+ fidp->vnode = cm_noLocalMountPoints + 1; /* vnode value of last mt pt */
+ }
cm_noteLocalMountPointChange();
-
+
return 0;
}
diff -Nur --exclude-from=../exclude orig-src/WINNT/afsd/cm_ioctl.c src/WINNT/afsd/cm_ioctl.c
--- orig-src/WINNT/afsd/cm_ioctl.c Fri Oct 5 14:40:47 2001
+++ src/WINNT/afsd/cm_ioctl.c Tue Oct 30 19:36:46 2001
@@ -1176,7 +1176,7 @@
if (cm_freelanceEnabled && dscp == cm_rootSCachep) {
/* we are adding the mount point to the root dir., so call
the freelance code to do the add. */
- code = cm_FreelanceAddMount(leaf, fullCell, volume);
+ code = cm_FreelanceAddMount(leaf, fullCell, volume, NULL);
return code;
}
#endif
diff -Nur --exclude-from=../exclude orig-src/WINNT/afsd/cm_vnodeops.c src/WINNT/afsd/cm_vnodeops.c
--- orig-src/WINNT/afsd/cm_vnodeops.c Fri Oct 5 14:40:47 2001
+++ src/WINNT/afsd/cm_vnodeops.c Tue Oct 30 19:36:19 2001
@@ -959,6 +959,7 @@
cm_scache_t *mountedScp;
cm_lookupSearch_t rock;
char tname[256];
+ int getroot;
if (dscp->fid.vnode == 1 && dscp->fid.unique == 1
&& strcmp(namep, "..") == 0) {
@@ -988,12 +989,27 @@
* looking for. Any other non-zero code is an error.
*/
if (code && code != CM_ERROR_STOPNOW) return code;
-
- if (!rock.found)
+
+ getroot = (dscp==cm_rootSCachep) ;
+ if (!rock.found) {
+ if (!cm_freelanceEnabled || !getroot) {
if (flags & CM_FLAG_CHECKPATH)
return CM_ERROR_NOSUCHPATH;
else
return CM_ERROR_NOSUCHFILE;
+ }
+ else { /* nonexistent dir on freelance root, so add it */
+ code = cm_FreelanceAddMount(namep, namep, "root.cell.",
+ &rock.fid);
+ if (code < 0) { /* add mount point failed, so give up */
+ if (flags & CM_FLAG_CHECKPATH)
+ return CM_ERROR_NOSUCHPATH;
+ else
+ return CM_ERROR_NOSUCHFILE;
+ }
+ tscp = NULL; /* to force call of cm_GetSCache */
+ }
+ }
haveFid:
if ( !tscp ) /* we did not find it in the dnlc */
@@ -1190,9 +1206,17 @@
*newRootScpp = cm_rootSCachep;
cm_HoldSCache(cm_rootSCachep);
} else if (*linkp == '\\' || *linkp == '/') {
+ /* formerly, this was considered to be from the AFS root,
+ but this seems to create problems. instead, we will just
+ reject the link */
+#if 0
strcpy(tsp->data, linkp+1);
*newRootScpp = cm_rootSCachep;
cm_HoldSCache(cm_rootSCachep);
+#else
+ code = CM_ERROR_NOSUCHPATH;
+ goto done;
+#endif
}
else {
/* a relative link */
diff -Nur --exclude-from=../exclude orig-src/auth/cellconfig.c src/auth/cellconfig.c
--- orig-src/auth/cellconfig.c Tue Oct 9 17:05:30 2001
+++ src/auth/cellconfig.c Tue Oct 30 17:10:19 2001
@@ -33,12 +33,12 @@
#include <netdb.h>
#include <sys/file.h>
#include <sys/time.h>
-#include <afs/afsint.h>
#ifdef AFS_AFSDB_ENV
#include <arpa/nameser.h>
#include <resolv.h>
#endif /* AFS_AFSDB_ENV */
#endif /* AFS_NT40_ENV */
+#include <afs/afsint.h>
#include <errno.h>
#include <ctype.h>
#include <time.h>
diff -Nur --exclude-from=../exclude orig-src/bozo/NTMakefile src/bozo/NTMakefile
--- orig-src/bozo/NTMakefile Mon Sep 17 12:35:17 2001
+++ src/bozo/NTMakefile Tue Oct 30 19:02:24 2001
@@ -66,7 +66,8 @@
$(DESTDIR)\lib\afs\afsaudit.lib \
$(DESTDIR)\lib\afs\afsreg.lib \
$(DESTDIR)\lib\afs\afseventlog.lib \
- $(DESTDIR)\lib\afs\afsprocmgmt.lib
+ $(DESTDIR)\lib\afs\afsprocmgmt.lib \
+ $(DESTDIR)\lib\cm_dns.obj
$(BOSSERVER_EXEFILE): $(BOSSERVER_EXEOBJS) $(BOSSERVER_EXELIBS)
$(EXECONLINK)
@@ -100,7 +101,8 @@
$(DESTDIR)\lib\afs\afsbos.lib \
$(DESTDIR)\lib\afs\afsreg.lib \
$(DESTDIR)\lib\afs\afsprocmgmt.lib \
- $(DESTDIR)\lib\afs\afspioctl.lib
+ $(DESTDIR)\lib\afs\afspioctl.lib \
+ $(DESTDIR)\lib\cm_dns.obj
$(RS_BOS_EXEFILE): $(BOS_EXEOBJS) $(BOS_EXELIBS)
diff -Nur --exclude-from=../exclude orig-src/bucoord/NTMakefile src/bucoord/NTMakefile
--- orig-src/bucoord/NTMakefile Mon Sep 17 12:35:18 2001
+++ src/bucoord/NTMakefile Tue Oct 30 18:57:40 2001
@@ -79,7 +79,8 @@
$(DESTDIR)\lib\afs\afsusd.lib \
$(DESTDIR)\lib\afs\afsprocmgmt.lib \
$(DESTDIR)\lib\afs\afspioctl.lib \
- $(DESTDIR)\lib\afs\afsreg.lib
+ $(DESTDIR)\lib\afs\afsreg.lib \
+ $(DESTDIR)\lib\cm_dns.obj
$(EXEFILE): $(EXEOBJS) $(EXELIBS)
diff -Nur --exclude-from=../exclude orig-src/budb/NTMakefile src/budb/NTMakefile
--- orig-src/budb/NTMakefile Mon Sep 17 12:35:19 2001
+++ src/budb/NTMakefile Tue Oct 30 17:27:01 2001
@@ -75,7 +75,8 @@
$(DESTDIR)\lib\afsubik.lib \
$(DESTDIR)\lib\afs\afseventlog.lib \
$(DESTDIR)\lib\afs\afsreg.lib \
- $(DESTDIR)\lib\afs\afsprocmgmt.lib
+ $(DESTDIR)\lib\afs\afsprocmgmt.lib \
+ $(DESTDIR)\lib\cm_dns.obj
$(EXEFILE): $(EXEOBJS) $(EXELIBS)
diff -Nur --exclude-from=../exclude orig-src/butc/NTMakefile src/butc/NTMakefile
--- orig-src/butc/NTMakefile Sat Nov 4 02:04:12 2000
+++ src/butc/NTMakefile Tue Oct 30 18:59:19 2001
@@ -49,7 +49,8 @@
$(DESTDIR)\lib\afs\afsprocmgmt.lib \
$(DESTDIR)\lib\afs\afspioctl.lib \
$(DESTDIR)\lib\afs\afseventlog.lib \
- $(DESTDIR)\lib\afs\afsreg.lib
+ $(DESTDIR)\lib\afs\afsreg.lib \
+ $(DESTDIR)\lib\cm_dns.obj
$(EXEFILE): $(EXEOBJS) $(EXELIBS)
$(EXECONLINK)
diff -Nur --exclude-from=../exclude orig-src/ptserver/ptclient.c src/ptserver/ptclient.c
--- orig-src/ptserver/ptclient.c Fri Oct 5 13:58:00 2001
+++ src/ptserver/ptclient.c Tue Oct 30 19:13:34 2001
@@ -21,8 +21,8 @@
#include <WINNT/afsevent.h>
#else
#include <netinet/in.h>
-#endif
#include <netdb.h>
+#endif
#include <stdio.h>
#include <rx/xdr.h>
#include <rx/rx.h>
diff -Nur --exclude-from=../exclude orig-src/tbutc/NTMakefile src/tbutc/NTMakefile
--- orig-src/tbutc/NTMakefile Mon Sep 17 12:35:23 2001
+++ src/tbutc/NTMakefile Tue Oct 30 19:17:17 2001
@@ -73,7 +73,8 @@
!ELSE
$(DESTDIR)\lib\pthread.lib \
!ENDIF
- $(DESTDIR)\lib\afsdes.lib
+ $(DESTDIR)\lib\afsdes.lib \
+ $(DESTDIR)\lib\cm_dns.obj
# $(DESTDIR)\lib\afsauthent.lib \
diff -Nur --exclude-from=../exclude orig-src/update/NTMakefile src/update/NTMakefile
--- orig-src/update/NTMakefile Mon Sep 17 12:35:25 2001
+++ src/update/NTMakefile Tue Oct 30 18:53:40 2001
@@ -21,7 +21,8 @@
$(DESTDIR)\lib\afsubik.lib \
$(DESTDIR)\lib\afs\afseventlog.lib \
$(DESTDIR)\lib\afsrxkad.lib \
- $(DESTDIR)\lib\afs\afsprocmgmt.lib
+ $(DESTDIR)\lib\afs\afsprocmgmt.lib \
+ $(DESTDIR)\lib\cm_dns.obj
############################################################################
# Definitions for generating files via RXGEN
diff -Nur --exclude-from=../exclude orig-src/vlserver/NTMakefile src/vlserver/NTMakefile
--- orig-src/vlserver/NTMakefile Mon Apr 30 00:05:47 2001
+++ src/vlserver/NTMakefile Tue Oct 30 17:23:29 2001
@@ -85,7 +85,8 @@
$(DESTDIR)\lib\afs\afsaudit.lib \
$(DESTDIR)\lib\afs\afseventlog.lib \
$(DESTDIR)\lib\afs\afsreg.lib \
- $(DESTDIR)\lib\afs\afsprocmgmt.lib
+ $(DESTDIR)\lib\afs\afsprocmgmt.lib \
+ $(DESTDIR)\lib\cm_dns.obj
$(VLSERVER): $(VLSERVER_EXEOBJS) $(LIBFILE) $(VLSERVER_EXECLIBS)
diff -Nur --exclude-from=../exclude orig-src/volser/NTMakefile src/volser/NTMakefile
--- orig-src/volser/NTMakefile Mon Sep 17 12:35:25 2001
+++ src/volser/NTMakefile Tue Oct 30 17:30:54 2001
@@ -64,7 +64,8 @@
$(DESTDIR)\lib\afslwp.lib \
$(DESTDIR)\lib\afs\afsacl.lib \
$(DESTDIR)\lib\afs\afsreg.lib \
- $(DESTDIR)\lib\afs\afseventlog.lib
+ $(DESTDIR)\lib\afs\afseventlog.lib \
+ $(DESTDIR)\lib\cm_dns.obj
############################################################################
--ew6BAiZeqk4r7MaW--