[OpenAFS-devel] Turning on Global Drives for Windows

Douglas E. Engert deengert@anl.gov
Thu, 19 Jun 2003 09:05:46 -0500


I would like to submit this change to turn on the global drive
mappings in the Windows OpenAFS afsd_service.c

This will allow access to AFS from system processes and scheduled tasks.
It also means that each user does not have to map AFS to his own
drive.

There may need to be additional changes, since in some situations Windows
Explorer will show a red X for the drive, but it can still be accessed. 

This is using the 1.2.x source.


Index: afsd_service.c
===================================================================
RCS file: /cvs/openafs/src/WINNT/afsd/afsd_service.c,v
retrieving revision 1.3.4.4
diff -c -r1.3.4.4 afsd_service.c
*** afsd_service.c	28 May 2003 18:36:05 -0000	1.3.4.4
--- afsd_service.c	17 Jun 2003 18:35:52 -0000
***************
*** 137,145 ****
  	}
  }
  
! #if 0
  /* This code was moved to Drivemap.cpp*/
  /* Mount a drive into AFS if the user wants us to */
  void CheckMountDrive()
  {
          char szAfsPath[_MAX_PATH];
--- 137,146 ----
  	}
  }
  
! #if 1
  /* This code was moved to Drivemap.cpp*/
  /* Mount a drive into AFS if the user wants us to */
+ /* DEE Could check first if we are run as SYSTEM */
  void CheckMountDrive()
  {
          char szAfsPath[_MAX_PATH];
***************
*** 171,179 ****
--- 172,198 ----
                          }
                  }
                  
+ #if 0
                  sprintf(szAfsPath, "\\Device\\LanmanRedirector\\%s\\%s-AFS\\%s",
szDriveToMapTo, cm_HostName, szSubMount);
          
                  dwResult = DefineDosDevice(DDD_RAW_TARGET_PATH, szDriveToMapTo,
szAfsPath);
+ #else
+ 		{
+ 			NETRESOURCE nr;
+ 			memset (&nr, 0x00, sizeof(NETRESOURCE));
+ 
+ 			sprintf(szAfsPath,"\\\\%s-AFS\\%s",cm_HostName,szSubMount);
+ 
+ 			nr.dwScope = RESOURCE_GLOBALNET;
+ 			nr.dwType=RESOURCETYPE_DISK;
+ 			nr.lpLocalName=szDriveToMapTo;
+ 			nr.lpRemoteName=szAfsPath;
+ 			nr.dwDisplayType = RESOURCEDISPLAYTYPE_SHARE;
+ 			nr.dwUsage = RESOURCEUSAGE_CONNECTABLE;
+ 
+ 			dwResult = WNetAddConnection2(&nr,NULL,NULL,FALSE);
+ 		}
+ #endif
                  afsi_log("GlobalAutoMap of %s to %s %s", szDriveToMapTo, szSubMount,
dwResult ? "succeeded" : "failed");
          }        
  
***************
*** 251,257 ****
  	}
  
          /* Check if we should mount a drive into AFS */
! /*        CheckMountDrive();*/
  
  	WaitForSingleObject(WaitToTerminate, INFINITE);
  	
--- 270,276 ----
  	}
  
          /* Check if we should mount a drive into AFS */
!         CheckMountDrive();
  
  	WaitForSingleObject(WaitToTerminate, INFINITE);


Sr:Sr:Sr:Ar7C= CB<A@6MCSr:Sr: r7C::ftp/dl8/I37C;;nC ~A~Aq:R&#w)vA8bx;;;   ϊEhr)Cs)Cs)C8jK6AHtA8bx;: Ί#vA8bx;;; ͊~A~A4Q ;S&#Eh6MCs)Cs)C9kKhs)C1;1;:lKhs)C1;1;;mK~A~Abl:T&#e~A~A:U&#~A~A4n:V&#e~A~A";:W&#mvA8bx;u ; ̊2~A~A9F;X='#K~A~A7:>'#Eh6MC s1C s1CuKAIMC7bx;2Nx;-jAJMC~AqOx; 1j