Index: openafs/src/JAVA/classes/.classpath
diff -c /dev/null openafs/src/JAVA/classes/.classpath:1.1.2.2
*** /dev/null	Sat Oct 22 02:14:46 2005
--- openafs/src/JAVA/classes/.classpath	Fri Oct 14 22:14:09 2005
***************
*** 0 ****
--- 1,6 ----
+ <?xml version="1.0" encoding="UTF-8"?>
+ <classpath>
+ 	<classpathentry kind="src" path=""/>
+ 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ 	<classpathentry kind="output" path=""/>
+ </classpath>
Index: openafs/src/JAVA/classes/.project
diff -c /dev/null openafs/src/JAVA/classes/.project:1.1.2.2
*** /dev/null	Sat Oct 22 02:14:46 2005
--- openafs/src/JAVA/classes/.project	Fri Oct 14 22:14:09 2005
***************
*** 0 ****
--- 1,17 ----
+ <?xml version="1.0" encoding="UTF-8"?>
+ <projectDescription>
+ 	<name>JAVA-openafs</name>
+ 	<comment></comment>
+ 	<projects>
+ 	</projects>
+ 	<buildSpec>
+ 		<buildCommand>
+ 			<name>org.eclipse.jdt.core.javabuilder</name>
+ 			<arguments>
+ 			</arguments>
+ 		</buildCommand>
+ 	</buildSpec>
+ 	<natures>
+ 		<nature>org.eclipse.jdt.core.javanature</nature>
+ 	</natures>
+ </projectDescription>
Index: openafs/src/JAVA/classes/ErrorMessages.properties
diff -c openafs/src/JAVA/classes/ErrorMessages.properties:1.2 openafs/src/JAVA/classes/ErrorMessages.properties:1.2.2.1
*** openafs/src/JAVA/classes/ErrorMessages.properties:1.2	Thu Jun 19 12:53:13 2003
--- openafs/src/JAVA/classes/ErrorMessages.properties	Fri Oct 14 22:14:09 2005
***************
*** 12,37 ****
  E1004 = Operation was forced to abort
  
  #-----------------------------------------------------------
- # Internal JAFS Error Codes
- #-----------------------------------------------------------
- E1050 = Could not allocate memory.
- E1051 = Could not find specified Java class.
- E1052 = Could not find specified Java method.
- E1053 = Could not find specified Java field.
- E1054 = Invalid argument value, argument is NULL.
- E1055 = Username provided is NULL.
- E1056 = Password provided is NULL.
- E1057 = Group name provided is NULL.
- E1058 = Group owner provided is NULL.
- E1059 = Volume name provided is NULL.
- E1060 = Partition name provided is NULL.
- E1061 = Process name provided is NULL.
- E1062 = Server name provided is NULL.
- E1063 = Cell name provided is NULL.
- E1064 = Invalid path name provided, path is NULL.
- E1065 = Invalid ACL provided, string is NULL.
- 
- #-----------------------------------------------------------
  # Standard UNIX Error Codes
  #-----------------------------------------------------------
  E1   = Operation not permitted
--- 12,17 ----
Index: openafs/src/JAVA/classes/testAFS.java
diff -c /dev/null openafs/src/JAVA/classes/testAFS.java:1.1.2.2
*** /dev/null	Sat Oct 22 02:14:46 2005
--- openafs/src/JAVA/classes/testAFS.java	Fri Oct 14 22:14:09 2005
***************
*** 0 ****
--- 1,684 ----
+ import java.io.File;
+ import java.util.GregorianCalendar;
+ 
+ import org.openafs.jafs.*;
+ 
+ 
+ 
+ /**
+  * @version 	1.0
+  * @author
+  */
+ public class testAFS
+ {
+ 	public class TesterThread implements Runnable
+ 	{
+ 		private String user = null;
+ 		private String pass = null;
+ 		private String cell = null;
+ 		private boolean letItRun = true;
+ 
+ 		public TesterThread(String user, String pass, String cell)
+ 		{
+ 			this.user = user;
+ 			this.pass = pass;
+ 			this.cell = cell;
+ 		}
+ 		public void finish()
+ 		{
+ 			letItRun = false;
+ 		}
+ 		public void run()
+ 		{
+ 			while(letItRun)
+ 			{
+ 				try
+ 				{
+ 					Token t = new Token(user, pass, cell);
+ 					Cell c = new Cell(t, false);
+ 					c.getInfo();
+ 	
+ 					for(int j=0; j<100; j++)
+ 					{
+ 						ACL acl = new ACL("/afs/." + cell, true);
+ 					}
+ 
+ 					c.close();
+ 				} catch(Exception e) {
+ 					e.printStackTrace();
+ 				}
+ 				Thread.yield();
+ 			}
+ 		}
+ 	}
+ 	
+ 	
+ 	static java.io.PrintStream out = System.out;
+ 	static String firstCellPathRW = null;
+ 
+ 	static boolean allowDump = true;
+ 	
+ 	static int ident = 0;
+ 
+ 	static void DumpBegin()
+ 	{
+ 		if (allowDump)
+ 		{
+ 			for(int i=0; i<ident; i++)
+ 				out.print("   ");
+ 		}
+ 	}
+ 	static void Dump(String str)
+ 	{
+ 		if (allowDump)
+ 			out.print(str);
+ 	}
+ 	static void DumpEnd()
+ 	{
+ 		if (allowDump)
+ 			out.println();
+ 	}
+ 	static void DumpLn(String str)
+ 	{
+ 		DumpBegin();
+ 		Dump(str);
+ 		DumpEnd();
+ 	}
+ 
+ 	public static String getGregDateStr(GregorianCalendar gc)
+ 	{
+ 		if (gc==null)
+ 			return "null";
+ 		else
+ 			return gc.getTime().toString();
+ 	}
+ 
+ 	public static void DumpToken(Token t)
+ 	{
+ 		try
+ 		{
+ 			DumpLn("Token: user=" + t.getUsername() +
+ 					" cell=" + t.getCellName() + " expiration=" + t.getExpiration());
+ 		} catch(AFSException e) {
+ 			e.printStackTrace();
+ 		}
+ 	}
+ 
+ 	public static void DumpFile(org.openafs.jafs.File f)
+ 	{
+ 		try
+ 		{
+ 			DumpBegin();
+ 			f.refresh();
+ 			Dump("File name: " + f.getPath() + ": ");
+ 			if (f.isDirectory()) {
+ 				Dump("This is a directory.");
+ 			} else if (f.isLink()) {
+ 				Dump("This is a symbolic-link.");
+ 				Dump(" Its target is: " + f.getTarget());
+ 				f.validate();
+ 				if (f.isFile()) {
+ 					Dump(" This object is now a file!");
+ 				} else if (f.isDirectory()) {
+ 					Dump(" This object is now a directory!");
+ 				} else if (f.isMountPoint()) {
+ 					Dump(" This object is now a volume mount point!");
+ 				}
+ 			} else if (f.isMountPoint()) {
+ 				Dump(" This is a volume mount point.");
+ 			} else if (f.isFile()) {
+ 				Dump(" This is a file. Size: " + f.length());
+ 			}
+ 			DumpEnd();
+ 
+ 			ACL acl = new ACL(f.getPath());
+ 			ident++;
+ 			DumpLn(acl.toString());
+ 			ident--;
+ 		} catch(AFSException e) {
+ 			e.printStackTrace();
+ 		}
+ 	}
+ 
+ 	public static void DumpCell(Cell cell)
+ 	{
+ 		try
+ 		{
+ 			DumpLn("Cell: " + cell.getName());
+ 			ident++;
+ 			DumpLn("MaxGroupID: " + cell.getMaxGroupID());
+ 			DumpLn("MaxUserID: " + cell.getMaxUserID());
+ 			ident--;
+ 	
+ 			//test some queries, don't write to output
+ 			cell.getInfo();
+ 			cell.getInfoGroups();
+ 			cell.getInfoServers();
+ 			cell.getInfoUsers();
+ 		} catch(AFSException e) {
+ 			e.printStackTrace();
+ 		}
+ 	}
+ 
+ 	public static void DumpServer(Server s)
+ 	{
+ 		DumpLn("Server: " + s.getName());
+ 		ident++;
+ 		try
+ 		{
+ 			try //pServer'SLES9 bug:
+ 			{
+ 				DumpLn("BinaryRestartTime: " + s.getBinaryRestartTime());
+ 			} catch(AFSException e) {
+ 				e.printStackTrace();
+ 			}
+ 			DumpLn("TotalFreeSpace:" + s.getTotalFreeSpace());
+ 			DumpLn("TotalSpace:" + s.getTotalSpace());
+ 			DumpLn("TotalUsedSpace:" + s.getTotalUsedSpace());
+ 			DumpLn("GeneralRestartTime:" + s.getGeneralRestartTime());
+ 			DumpBegin();
+ 			Dump("ip addresses: ");
+ 			String[] ipAddrs = s.getIPAddresses();
+ 			for(int i=0; i<ipAddrs.length; i++)
+ 			{
+ 				Dump(ipAddrs[i] + " ");
+ 			}
+ 			DumpEnd();
+ 			DumpBegin();
+ 			Dump("isFileServer: " + s.isFileServer());
+ 			Dump(" isBadFileserver: " + s.isBadFileServer());
+ 			Dump(" isDatabase: " + s.isDatabase());
+ 			Dump(" isBadDatabase: " + s.isBadDatabase());
+ 		} catch(AFSException e) {
+ 			e.printStackTrace();
+ 		}			
+ 		ident--;
+ 
+ 		try
+ 		{
+ 			//test some queries, don't write to output
+ 			s.getInfo();
+ 			try
+ 			{
+ 				s.getInfoKeys();
+ 			} catch(AFSException e) {
+ 				e.printStackTrace();
+ 			}
+ 			try	//is there any partitions? why parts can be null...
+ 			{	//wrong programming concept: null instead of an empty array !!!
+ 				s.getInfoPartitions();
+ 			} catch(Exception e) {
+ 				e.printStackTrace();
+ 			}
+ 			s.getInfoProcesses();
+ 		} catch(AFSException e) {
+ 			e.printStackTrace();
+ 		}
+ 	}
+ 
+ 	public static void DumpVolume(Volume v)
+ 	{
+ 		try
+ 		{
+ 			DumpBegin();
+ 			Dump("Volume name: " + v.getName());
+ 			Dump(" ID: " + v.getID());
+ 			DumpEnd();
+ 		} catch(AFSException e) {
+ 			e.printStackTrace();
+ 		}
+ 
+ 		ident++;
+ 		try
+ 		{
+ 			DumpBegin();
+ 			Dump("BackupID: " + v.getBackupID());
+ 			Dump(" ReadOnlyID: " + v.getReadOnlyID());
+ 			Dump(" ReadWriteID: " + v.getReadWriteID());
+ 			DumpEnd();
+ 			DumpBegin();
+ 			Dump("LastUpdateDate: " + getGregDateStr(v.getLastUpdateDate()));
+ 			Dump(" CreationDate: " + getGregDateStr(v.getCreationDate()));
+ 			Dump(" AccessesSinceMidnight: " + v.getAccessesSinceMidnight());
+ 			DumpEnd();
+ 			DumpBegin();
+ 			Dump("FileCount: " + v.getFileCount());
+ 			Dump(" CurrentSize: " + v.getCurrentSize());
+ 			Dump(" TotalFreeSpace: " + v.getTotalFreeSpace());
+ 			DumpEnd();
+ 			DumpBegin();
+ 			Dump("Type: " + v.getType());
+ 			Dump(" Disposition: " + v.getDisposition());
+ 			DumpEnd();
+ 			
+ 			//test some queries, don't write to output
+ 			v.getInfo();
+ 		} catch(AFSException e) {
+ 			e.printStackTrace();
+ 		}
+ 		ident--;
+ 	}
+ 
+ 	public static void DumpPartition(Partition p)
+ 	{
+ 		try
+ 		{
+ 			DumpBegin();
+ 			Dump("Partition name: " + p.getName());
+ 			Dump(" ID: " + p.getID());
+ 			Dump(" DeviceName: " + p.getDeviceName());
+ 			DumpEnd();
+ 		} catch(AFSException e) {
+ 			e.printStackTrace();
+ 		}
+ 		ident++;
+ 		try
+ 		{
+ 			DumpBegin();
+ 			Dump("TotalFreeSpace: " + p.getTotalFreeSpace());
+ 			Dump(" TotalQuota: " + p.getTotalQuota());
+ 			Dump(" TotalTotalSpace: " + p.getTotalSpace());
+ 			DumpEnd();
+ 
+ 			//test some queries, don't write to output
+ 			p.getInfo();
+ 			p.getInfoVolumes();
+ 		} catch(AFSException e) {
+ 			e.printStackTrace();
+ 		}
+ 		ident--;
+ 	}
+ 
+ 	public static void DumpGroup(Group g)
+ 	{
+ 		try
+ 		{
+ 			DumpBegin();
+ 			Dump("Group name: " + g.getName());
+ 			Dump(" Type: " + g.getType());
+ 			Dump(" UID: " + g.getUID());
+ 			DumpEnd();
+ 			
+ 			//test some queries, don't write to output
+ 			g.getInfo();
+ 		} catch(AFSException e) {
+ 			e.printStackTrace();
+ 		}
+ 	}
+ 
+ 	public static void DumpUser(User u)
+ 	{
+ 		DumpLn("User name: " + u.getName());
+ 		ident++;
+ 		try
+ 		{
+ 
+ 			DumpLn("EncryptionKey" + u.getEncryptionKey());
+ 			DumpBegin();
+ 			Dump("DaysToPasswordExpire: " + u.getDaysToPasswordExpire());
+ 			Dump(" FailLoginCount: " + u.getFailLoginCount());
+ 			Dump(" KeyCheckSum: " + u.getKeyCheckSum());
+ 			DumpEnd();
+ 			DumpBegin();
+ 			Dump("UserExpirationDate: " + getGregDateStr(u.getUserExpirationDate()));
+ 			Dump(" MaxTicketLifetime: " + u.getMaxTicketLifetime());
+ 			Dump(" LockedUntilDate: " + getGregDateStr(u.getLockedUntilDate()));
+ 			DumpEnd();
+ 
+ 			
+ 			//test some queries, don't write to output
+ 			u.getInfo();
+ 			u.getInfoGroups();
+ 			u.getInfoGroupsOwned();
+ 		} catch(AFSException e) {
+ 			e.printStackTrace();
+ 		}
+ 		ident--;
+ 	}
+ 
+ 	static void DumpProcess(org.openafs.jafs.Process p)
+ 	{
+ 		DumpLn("Process name: " + p.getName());
+ 		ident++;
+ 		try
+ 		{
+ 
+ 			DumpBegin();
+ 			Dump("StartTimeDate: " + getGregDateStr(p.getStartTimeDate()));
+ 			Dump(" ExitTimeDate: " + getGregDateStr(p.getExitTimeDate()));
+ 			DumpEnd();
+ 			
+ 			//test some queries, don't write to output
+ 			p.getInfo();
+ 		} catch(AFSException e) {
+ 			e.printStackTrace();
+ 		}
+ 		ident--;
+ 	}
+ 
+ 	public static Token testToken(String user, String pass, String cell)
+ 	{
+ 		Token token = null;
+ 		try
+ 		{
+ 			token = new Token(user, pass, cell);
+ 			DumpToken(token);
+ 			testCell(token);
+ 		} catch(AFSException e) {
+ 			e.printStackTrace();
+ 		}
+ 		return token;
+ 	}
+ 
+ 	public static void testFilesRecursive(File dir)
+ 	{
+ 		try
+ 		{
+ 			java.io.File fj = new java.io.File(dir.getPath());
+ 			String[] strSubdirs = fj.list();
+ 			for(int i=0; i<strSubdirs.length; i++)
+ 			{
+ 				org.openafs.jafs.File f = new org.openafs.jafs.File(
+ 						dir.getPath() + "/" + strSubdirs[i]);
+ 				DumpFile(f);
+ 				f.validate();
+ 				if (f.isDirectory() || f.isMountPoint() || f.isLink())
+ 				{
+ 					testFilesRecursive(dir);
+ 				}
+ 			}
+ 		} catch(AFSFileException e) {
+ 			e.printStackTrace();
+ 		}
+ 	}
+ 
+ 	public static void testFiles()
+ 	throws AFSException, AFSFileException
+ 	{
+ 		org.openafs.jafs.File f = new org.openafs.jafs.File(firstCellPathRW);
+ 		DumpFile(f);
+ 		testFilesRecursive(f);
+ 	}
+ 	
+ 	public static void testCell(Token token)
+ 	{
+ 		Cell cell = null;
+ 		try
+ 		{
+ 			cell = new Cell(token, false);
+ 
+ 			DumpCell(cell);
+ 		} catch(AFSException e) {
+ 			e.printStackTrace();
+ 		}
+ 		if (cell==null)
+ 			return;
+ 
+ 		ident++;
+ 		try
+ 		{
+ 			Group[]	groups = cell.getGroups();
+ 			for(int i=0; i<groups.length; i++)
+ 			{
+ 				testGroup(groups[i]);
+ 			}
+ 	
+ 			Server[] servers = cell.getServers();
+ 			for(int j=0; j<servers.length; j++)
+ 			{
+ 				testServer(servers[j]);
+ 			}
+ 		} catch(AFSException e) {
+ 			e.printStackTrace();
+ 		}
+ 		ident--;
+ 
+ 		try
+ 		{
+ 			if (cell!=null)
+ 				cell.close();
+                 } catch(AFSException e) {
+                         e.printStackTrace();
+                 }
+ 	}
+ 	
+ 	public static void testServer(Server server)
+ 	throws AFSException
+ 	{
+ 		DumpServer(server);
+ 		ident++;
+ 		try
+ 		{
+ 			Partition[] parts = server.getPartitions();
+ 			if (parts!=null)
+ 			{
+ 				for(int i=0; i<parts.length; i++)
+ 				{
+ 					testPartition(parts[i]);
+ 				}
+ 			}
+ 	
+ 			org.openafs.jafs.Process[] procs = server.getProcesses();
+ 			if (procs!=null)
+ 			{
+ 				for(int i=0; i<procs.length; i++)
+ 				{
+ 					DumpProcess(procs[i]);
+ 				}
+ 			}
+ 
+ 			DumpLn("salvage...");
+ 			server.salvage();
+ 			DumpLn("getLog...");
+ 			try
+ 			{
+ 				server.getLog("/var/log/openafs/BosLog");
+ 			} catch(AFSException e) {
+ 				e.printStackTrace();
+ 			}
+ 			//DumpLn("stopAllProcesses...");
+ 			//server.stopAllProcesses();
+ 			//DumpLn("startAllProcesses...");
+ 			//server.startAllProcesses();
+ 			DumpLn("syncServer...");
+ 			server.syncServer();
+ 			DumpLn("syncVLDB...");
+ 			server.syncVLDB();
+ 			DumpLn("ok.");
+ 		} catch(AFSException e) {
+ 			e.printStackTrace();
+ 		}
+ 		ident--;
+ 	}
+ 
+ 	public static void testProcess(org.openafs.jafs.Process p)
+ 	throws AFSException
+ 	{
+ 		DumpProcess(p);
+ 	}
+ 
+ 	public static void testPartition(Partition part)
+ 	throws AFSException
+ 	{
+ 		DumpPartition(part);
+ 		ident++;
+ 
+ 		Volume[] vols = part.getVolumes();
+ 		for(int i=0; i<vols.length; i++)
+ 		{
+ 			testVolume(vols[i]);
+ 		}
+ 
+ 		ident--;
+ 	}
+ 	
+ 	public static void testVolume(Volume vol)
+ 	throws AFSException
+ 	{
+ 		DumpVolume(vol);
+ 	}
+ 	
+ 	public static void testGroup(Group group)
+ 	throws AFSException
+ 	{
+ 		DumpGroup(group);
+ 		ident++;
+ 
+ 		User[] users = group.getMembers();
+ 		for(int i=0; i<users.length; i++)
+ 		{
+ 			testUser(users[i]);
+ 		}
+ 
+ 		ident--;
+ 	}
+ 	
+ 	public static void testUser(User user)
+ 	throws AFSException
+ 	{
+ 		DumpUser(user);
+ 	}
+ 
+ 	public static void testNewVolume(String cellName, String userName, String passString)
+ 	{
+ 		if (firstCellPathRW==null)
+ 		{
+ 			System.err.println("testNewVolume cannot be executed (null args).");
+ 			return;
+ 		}
+ 
+ 		String volName = "myTestJafsVolume92834";
+ 		String mpName = firstCellPathRW + "/" + volName;
+ 		try
+ 		{
+ 			Token token = new Token(cellName, userName, passString);
+ 			Cell cell = new Cell(token, false);
+ 			Server[] servers = cell.getServers();
+ 			if (servers.length==0)
+ 			{
+ 				System.err.println("Error: failed to run\"testNewVolume\"!");
+ 				return;
+ 			}
+ 			Partition firstPart = null;
+ 			int i;
+ 			for(i=0; i<servers.length; i++)
+ 			{
+ 				Partition[] parts = servers[i].getPartitions();
+ 				if (parts==null)
+ 					continue;
+ 
+ 				if (parts.length!=0)
+ 				{
+ 					firstPart = parts[0];
+ 					break;
+ 				}
+ 			}
+ 			if (firstPart==null)
+ 			{
+ 				System.err.println("Error: failed to find any partition on any server - \"testNewVolume\" couldn't be tested!");
+ 				return;
+ 			}
+ 
+ 			Volume v = new Volume(volName, firstPart);
+ 			DumpLn("Creating a new volume " + volName + " ...");
+ 			v.create(0);
+ 
+ 			v.lock();
+ 			v.unlock();
+ 
+ 			volName = "myTestJafsVolume2389";
+ 			DumpLn("Renaming volume to " + volName + " ...");
+ 			v.rename(volName);
+ 
+ 			DumpLn("Creating an rw mount point " + mpName + " ...");
+ 			v.createMountPoint(mpName, true);
+ 
+ 			DumpLn("Deleting mount point...");
+ 			java.lang.Runtime.getRuntime().exec("fs rmmount " + mpName);
+ 			
+ 			DumpLn("Creating RO...");
+ 			Volume volRO = v.createReadOnly(firstPart);
+ 
+ 			DumpLn("Creating backup...");
+ 			v.createBackup();
+ 
+ 			DumpLn("Releaseing volume...");
+ 			v.release();
+ 
+ 			//v.moveTo();	//needs a more careful test env
+ 
+ 			DumpLn("Salvaging volume...");
+ 			v.salvage();
+ 
+ 			DumpLn("Deleting volume...");
+ 			v.delete();
+ 
+ 			DumpLn("Deleting RO site...");
+ 			volRO.delete();
+ 
+ 			DumpLn("OK.");
+ 		} catch(Exception e) {
+ 			e.printStackTrace();
+ 		}
+ 	}
+ 	
+ 	public static void main(String[] args)
+ 	{
+ 
+ 		try
+ 		{
+ 			if (args.length<4)
+ 			{
+ 				System.err.println("testAFS <user> <pass> <cell_name> <# of cycles>");
+ 				return;
+ 			}
+ 
+ 			Class.forName("org.openafs.jafs.Token");	//initialization...
+ 			System.out.println("Java interface version: " + VersionInfo.getVersionOfJavaInterface());
+ 			System.out.println("Library version: " + VersionInfo.getVersionOfLibrary());
+ 			System.out.println("Build info: " + VersionInfo.getBuildInfo());
+ 
+ 			//first test whether token is valid
+ 			//and load libraries with it
+ 			Token t0 = new Token(args[0], args[1], args[2]);
+ 			t0.close();
+ 
+ 			System.out.print("Starting another tester thread...");
+ 			testAFS	ta = new testAFS();
+ 			TesterThread tt = ta.new TesterThread(args[0], args[1], args[2]);
+ 			Thread tTest = new Thread(tt);
+ 			tTest.start();
+ 			System.out.println("started.");
+ 
+ 			firstCellPathRW = "/afs/." + args[2];
+ 			int numOfCycles = Integer.parseInt(args[3]);
+ 			for(int i=0; i<numOfCycles || numOfCycles==0; i++)
+ 			{
+ 				testToken(args[0], args[1], args[2]);
+ 
+ 				testFiles();
+ 
+ 				testNewVolume(args[0], args[1], args[2]);
+ 
+ 				System.out.print("ACL excercising...");
+ 				allowDump = false;
+ 				for(int j=0; j<100; j++)
+ 				{
+ 					testFiles();
+ 					System.out.print(".");
+ 				}
+ 				System.out.println();
+ 				allowDump = true;
+ 
+ 				AFSException afs = new AFSException(1);
+ 
+ 				System.out.println("cycle #" + (i+1) + "/" + numOfCycles + " done.");
+ 			}
+ 
+ 			tt.finish();
+ 			System.out.println("All done.");
+ 		} catch (Exception e) {
+ 			e.printStackTrace();
+ 		}
+ 	}
+ }
Index: openafs/src/JAVA/classes/org/openafs/jafs/ACL.java
diff -c openafs/src/JAVA/classes/org/openafs/jafs/ACL.java:1.2 openafs/src/JAVA/classes/org/openafs/jafs/ACL.java:1.2.2.1
*** openafs/src/JAVA/classes/org/openafs/jafs/ACL.java:1.2	Thu Jun 19 12:53:14 2003
--- openafs/src/JAVA/classes/org/openafs/jafs/ACL.java	Fri Oct 14 22:14:09 2005
***************
*** 33,629 ****
   * This class is an extension of the standard Java File class with file-based 
   * manipulation methods overridden by integrated AFS native methods.
   *
-  * @version 2.2, 03/24/2003 - Added new Delta ACL functionality and changes 
-  *                            from Stonehenge.
   * @version 2.0, 04/18/2001 - Completely revised class for efficiency.
   */
  
  public class ACL implements Serializable, Comparable
  {
!   private ACL.Entry[] positiveEntries;
!   private ACL.Entry[] negativeEntries;
! 
!   private ACL.Entry[] positiveExpungeEntries;
!   private ACL.Entry[] negativeExpungeEntries;
! 
!   /** 
!    * Path for this ACL, if null then this ACL instance is most likely a 
!    * Delta ACL.
!    */
!   private String path = null;
   
!   private ACL()
!   {
!   }
!   public ACL( String path ) throws AFSException
!   {
!     this( path, true );
!   }
!   public ACL( String path, boolean init ) throws AFSException
    {
!     int numberPositiveEntries = 0;
!     int numberNegativeEntries = 0;
!     ACL.Entry aclEntry;
!     String buffer;
! 
!     this.path = path;
! 
!     if ( init ) {
!       StringTokenizer st = new StringTokenizer( getACLString(path), "\n\t" );
!   
!       buffer = st.nextToken();
!       numberPositiveEntries = new Integer(buffer).intValue();
!       positiveEntries = new ACL.Entry[numberPositiveEntries];
!   
!       buffer = st.nextToken();
!       numberNegativeEntries = new Integer(buffer).intValue();
!       negativeEntries = new ACL.Entry[numberNegativeEntries];
    
!       for(int i = 0; i < numberPositiveEntries; i++)
!       {
!         aclEntry = new ACL.Entry();
!         aclEntry.setUser(st.nextToken());
!         aclEntry.setPermissions(new Integer(st.nextToken()).intValue());
!         positiveEntries[i] = aclEntry;
!       }
!   
!       for(int i = 0; i < numberNegativeEntries; i++)
!       {
!         aclEntry = new ACL.Entry();
!         aclEntry.setUser(st.nextToken());
!         aclEntry.setPermissions(new Integer(st.nextToken()).intValue());
!         negativeEntries[i] = aclEntry;
!       }
!     } else {
!       positiveEntries = new ACL.Entry[0];
!       negativeEntries = new ACL.Entry[0];
!     }
!   }
!   /**
!    * Returns the total number of ACL entries, this is the sum of positive
!    * and negative entries.
!    *
!    * @return Total number of ACL entries
!    */
    public int getEntryCount()
    {
!     return getPositiveEntryCount() + getNegativeEntryCount();
    }
-   /**
-    * Returns the path this ACL instance is bound to.
-    *
-    * @return Path for this ACL
-    */
    public String getPath()
    {
      return path;
    }
!   /**
!    * Writes the ACL to AFS, making all changes immediately effective.
!    * This method requires an active connection to AFS.
!    */
!   public void flush() throws AFSException
!   {
!     setACLString(path, getFormattedString());
!   }
! 
! 
!   /*--------------------------------------------------------------------------*/
!   /* Positive ACL Methods                                                     */
!   /*--------------------------------------------------------------------------*/
! 
!   /**
!    * Returns the number of positive ACL entries for this ACL instance.
!    *
!    * @return Positive ACL entry count
!    */
!   public int getPositiveEntryCount()
    {
!     return ( positiveEntries == null ) ? 0 : positiveEntries.length;
    }
-   /**
-    * Returns all positive ACL entries for this ACL instance.
-    *
-    * @return All positive ACL entries
-    */
    public ACL.Entry[] getPositiveEntries()
    {
!     return ( positiveEntries == null ) ? new ACL.Entry[0] : positiveEntries;
!   }
!   /**
!    * Returns the positive ACL entry associated with the specified 
!    * user/group name.
!    *
!    * @param  name Name of user/group for desired ACL entry.
!    * @return Positive ACL entry
!    * @see ACL.Entry#getUser()
!    */
!   public Entry getPositiveEntry(String name)
!   {
!     int n = getPositiveEntryCount();
!     for (int i = 0; i < n; i++) {
!       if (positiveEntries[i].getUser().equalsIgnoreCase(name)) {
!         return positiveEntries[i];
!       }
!     }
!     return null;
!   }
!   /**
!    * Returns all positive ACL entries to be expunged; used in Delta ACLs.
!    *
!    * @return All positive ACL entries
!    */
!   public ACL.Entry[] getPositiveExpungeEntries()
!   {
!     return ( positiveExpungeEntries == null ) ? new ACL.Entry[0] : positiveExpungeEntries;
!   }
!   /**
!    * Returns <code>true</code> if this ACL contains the specified ACL entry.
!    *
!    * @param  entry Positive ACL entry
!    * @return <code>true</code> if the specified ACL entry is present; 
!    *         <code>false</code> otherwise.
!    */
!   public boolean containsPositiveEntry(Entry entry)
!   {
!     int n = getPositiveEntryCount();
!     for (int i = 0; i < n; i++) {
!       if (positiveEntries[i].equals(entry)) {
!         return true;
!       }
!     }
!     return false;
    }
!   /**
!    * Adds a single positive ACL entry to this ACL instance.
!    *
!    * @param entry ACL.Entry object to add
!    */
!   public void addPositiveEntry( ACL.Entry entry ) throws AFSException
    {
!     int n = getPositiveEntryCount();
      ACL.Entry[] e = new ACL.Entry[n + 1];
-     if ( n > 0 ) System.arraycopy(positiveEntries, 0, e, 0, n);
-     e[n] = entry;
-     positiveEntries = e;
-     update();
-   }
-   /**
-    * Adds the provided list of positive ACL entries to this ACL instance.
-    *
-    * @param entries Array of ACL.Entry objects to add
-    */
-   public void addPositiveEntries( ACL.Entry[] entries ) throws AFSException
-   {
-     int n = getPositiveEntryCount();
-     ACL.Entry[] e = new ACL.Entry[n + entries.length];
      System.arraycopy(positiveEntries, 0, e, 0, n);
!     System.arraycopy(entries,0,e,n,entries.length);
      positiveEntries = e;
!     update();
    }
!   /**
!    * Sets the complete array of positive ACL entries to the provided
!    * ACL entry list (<code>entries</code>) for this ACL instance.
!    *
!    * @param entries Array of ACL.Entry objects that represent this
!    *                ACL's positive entry list.
!    */
!   public void setPositiveEntries( ACL.Entry[] entries ) throws AFSException
    {
      this.positiveEntries = entries;
!     update();
!   }
!   /**
!    * Add a positive ACL entry to the list of positive ACL entries to be 
!    * expunged; used in Delta ACLs.
!    *
!    * @param entry Positive ACL entries to be expunged.
!    */
!   public void addPositiveExpungeEntry( ACL.Entry entry ) throws AFSException
!   {
!     int n = ( positiveExpungeEntries == null ) ? 0 : positiveExpungeEntries.length;
!     ACL.Entry[] e = new ACL.Entry[n + 1];
!     if ( n > 0 ) System.arraycopy(positiveExpungeEntries, 0, e, 0, n);
!     e[n] = entry;
!     positiveExpungeEntries = e;
!     update();
!   }
! 
!   /**
!    * Removes a single positive ACL entry from this ACL instance.
!    *
!    * @param entry ACL.Entry object to removed
!    */
!   public void removePositiveEntry(Entry entry) throws AFSException
!   {
!     int n = getPositiveEntryCount();
!     ArrayList list = new ArrayList();
! 
!     for (int i = 0; i < n; i++) {
!       if (!positiveEntries[i].equals(entry)) {
!         list.add(positiveEntries[i]);
!       }
!     }
! 
!     positiveEntries = (ACL.Entry[]) list.toArray(new ACL.Entry[list.size()]);
!     update();
!   }
!   /**
!    * Removes all positive ACL entries from this ACL instance.
!    */
!   public void removeAllPositiveEntries() throws AFSException
!   {
!     positiveEntries = new Entry[0];
!     update();
!   }
! 
! 
!   /*--------------------------------------------------------------------------*/
!   /* Negative ACL Methods                                                     */
!   /*--------------------------------------------------------------------------*/
! 
!   /**
!    * Returns the number of negative ACL entries for this ACL instance.
!    *
!    * @return Negative ACL entry count
!    */
!   public int getNegativeEntryCount()
!   {
!     return ( negativeEntries == null ) ? 0 : negativeEntries.length;
    }
-   /**
-    * Returns all negative ACL entries for this ACL instance.
-    *
-    * @return All negative ACL entries
-    */
    public ACL.Entry[] getNegativeEntries()
    {
!     return ( negativeEntries == null ) ? new ACL.Entry[0] : negativeEntries;
!   }
!   /**
!    * Returns the negative ACL entry associated with the specified 
!    * user/group name.
!    *
!    * @param  name Name of user/group for desired ACL entry.
!    * @return Negative ACL entry
!    * @see ACL.Entry#getUser()
!    */
!   public Entry getNegativeEntry(String name)
!   {
!     int n = getNegativeEntryCount();
!     for (int i = 0; i < n; i++) {
!       if (negativeEntries[i].getUser().equalsIgnoreCase(name)) {
!         return negativeEntries[i];
!       }
!     }
!     return null;
!   }
!   /**
!    * Returns all negative ACL entries to be expunged; used in Delta ACLs.
!    *
!    * @return All negative ACL entries to be expunged.
!    */
!   public ACL.Entry[] getNegativeExpungeEntries()
!   {
!     return ( negativeExpungeEntries == null ) ? new ACL.Entry[0] : negativeExpungeEntries;
!   }
!   /**
!    * Returns <code>true</code> if this ACL contains the specified ACL entry.
!    *
!    * @param  entry Negative ACL entry
!    * @return <code>true</code> if the specified ACL entry is present; 
!    *         <code>false</code> otherwise.
!    */
!   public boolean containsNegative(Entry entry)
!   {
!     int n = getNegativeEntryCount();
!     for (int i = 0; i < n; i++) {
!       if (negativeEntries[i].equals(entry)) {
!         return true;
!       }
!     }
!     return false;
    }
!   /**
!    * Adds a single negative ACL entry to this ACL instance.
!    *
!    * @param entry ACL.Entry object to add
!    */
!   public void addNegativeEntry( ACL.Entry entry ) throws AFSException
    {
!     int n = getNegativeEntryCount();
      ACL.Entry[] e = new ACL.Entry[n + 1];
!     if ( n > 0 ) System.arraycopy(negativeEntries, 0, e, 0, n);
      e[n] = entry;
      negativeEntries = e;
!     update();
    }
!   /**
!    * Adds the provided list of negative ACL entries to this ACL instance.
!    *
!    * @param entries Array of ACL.Entry objects to add
!    */
!   public void addNegativeEntries( ACL.Entry[] entries ) throws AFSException
    {
!     int n = getNegativeEntryCount();
!     ACL.Entry[] e = new ACL.Entry[n + entries.length];
!     System.arraycopy(negativeEntries, 0, e, 0, n);
!     System.arraycopy(entries,0,e,n,entries.length);
!     negativeEntries = e;
!     update();
    }
!   /**
!    * Add a negative ACL entry to the list of negative ACL entries to be 
!    * expunged; used in Delta ACLs.
!    *
!    * @param entry Negative ACL entries to be expunged.
!    */
!   public void addNegativeExpungeEntry( ACL.Entry entry ) throws AFSException
    {
!     int n = ( negativeExpungeEntries == null ) ? 0 : negativeExpungeEntries.length;
!     ACL.Entry[] e = new ACL.Entry[n + 1];
!     if ( n > 0 ) System.arraycopy(negativeExpungeEntries, 0, e, 0, n);
!     e[n] = entry;
!     negativeExpungeEntries = e;
!     update();
    }
!   /**
!    * Sets the complete array of negative ACL entries to the provided
!    * ACL entry list (<code>entries</code>) for this ACL instance.
!    *
!    * @param entries Array of ACL.Entry objects that represent this
!    *                ACL's negative entry list.
!    */
!   public void setNegativeEntries( ACL.Entry[] entries ) throws AFSException
    {
      this.negativeEntries = entries;
!     update();
    }
  
!   /**
!    * Removes a single negative ACL entry from this ACL instance.
!    *
!    * @param entry ACL.Entry object to removed
!    */
!   public void removeNegativeEntry(Entry entry) throws AFSException
    {
!     int n = getNegativeEntryCount();
!     ArrayList list = new ArrayList();
!         
!     for (int i = 0; i < n; i++) {
!       if (!negativeEntries[i].equals(entry)) {
!         list.add(negativeEntries[i]);
!       }
!     }
! 
!     negativeEntries = (ACL.Entry[]) list.toArray(new ACL.Entry[list.size()]);
!     update();
    }
    
    /**
!    * Removes all negative ACL entries from this ACL instance.
     */
!   public void removeAllNegativeEntries() throws AFSException
!   {
!     negativeEntries = new Entry[0];
!     update();
    }
    
- 
-   /*--------------------------------------------------------------------------*/
-   /* Delta ACL Methods                                                        */
-   /*--------------------------------------------------------------------------*/
- 
    /**
!    * Returns a "Delta ACL", which is an ACL that represents only the difference
!    * (delta) of two ACLs, relative to the current ACL instance by the provided
!    * ACL specified by <code>acl</code>.
!    *
!    * <P> This ACL instance represents the base or reference object while the 
!    * provided ACL (<code>acl</code>) represents the object in question. 
!    * Therefore, if the provided ACL has an entry that differs from the base ACL,
!    * then the resulting Delta ACL will contain that entry found in the provided 
!    * ACL; base ACL entries are never entered into the Delta ACL, but rather are
!    * used solely for comparison.
!    *
!    * @param acl the ACL to compare this ACL instance to
!    * @return Delta ACL by comparing this ACL instance with <code>acl</code>
     */
!   public ACL getDeltaACL( ACL acl ) throws AFSException
!   {
!     ACL delta = new ACL();
!     int n = getPositiveEntryCount();
!     
!     ACL.Entry[] pEntries = acl.getPositiveEntries();
!     for ( int i = 0; i < pEntries.length; i++ )
!     {
!       boolean match = false;
!       for ( int j = 0; j < n; j++ )
!       {
!         if ( pEntries[i].equals( positiveEntries[j] ) ) {
!           match = true;
!           break;
!         }
!       }
!       if ( !match ) delta.addPositiveEntry( pEntries[i] );
!     }
! 
!     // Check for positive entries that need to be expunged.
!     n = getPositiveEntryCount();
!     if ( n > pEntries.length ) {
!       for ( int i = 0; i < n; i++ )
!       {
!         String eu = positiveEntries[i].getUser();
!         boolean match = false;
!         for ( int j = 0; j < pEntries.length; j++ )
!         {
!           if ( eu != null && eu.equals( pEntries[j].getUser() ) ) {
!             match = true;
!             break;
!           }
!         }
!         if ( !match ) delta.addPositiveExpungeEntry( positiveEntries[i] );
!       }
!     }
! 
!     n = getNegativeEntryCount();
!     ACL.Entry[] nEntries = acl.getNegativeEntries();
!     for ( int i = 0; i < nEntries.length; i++ )
!     {
!       boolean match = false;
!       for ( int j = 0; j < n; j++ )
!       {
!         if ( nEntries[i].equals( negativeEntries[j] ) ) {
!           match = true;
!           break;
!         }
!       }
!       if ( !match ) delta.addNegativeEntry( nEntries[i] );
!     }
! 
!     // Check for negative entries that need to be expunged.
!     n = getNegativeEntryCount();
!     if ( n > nEntries.length ) {
!       for ( int i = 0; i < n; i++ )
!       {
!         String eu = negativeEntries[i].getUser();
!         boolean match = false;
!         for ( int j = 0; j < nEntries.length; j++ )
!         {
!           if ( eu != null && eu.equals( nEntries[j].getUser() ) ) {
!             match = true;
!             break;
!           }
!         }
!         if ( !match ) delta.addNegativeExpungeEntry( negativeEntries[i] );
!       }
!     }
! 
!     return delta;
    }
! 
    /**
!    * Updates the current ACL instance by replacing, adding, or deleting 
!    * ACL entries designated by the specified Delta ACL (<code>delta</code>).
!    *
!    * <P> If the provided Delta ACL has an entry that differs from this ACL 
!    * instance, then the ACL entry of the Delta ACL will be set.
!    *
!    * @param delta the Delta ACL to be applied to this ACL instance
     */
!   public void update( ACL delta ) throws AFSException
!   {
!     ArrayList pos = new ArrayList( this.getPositiveEntryCount() );
!     ArrayList neg = new ArrayList( this.getNegativeEntryCount() );
! 
!     ACL.Entry[] pExpungeEntries = delta.getPositiveExpungeEntries();
!     ACL.Entry[] nExpungeEntries = delta.getNegativeExpungeEntries();
! 
!     ACL.Entry[] pEntries = delta.getPositiveEntries();
!     ACL.Entry[] nEntries = delta.getNegativeEntries();
! 
!     // Delete positive expunge entries first
!     int n = getPositiveEntryCount();
!     for ( int i = 0; i < n; i++ )
!     {
!       boolean match = false;
!       for ( int j = 0; j < pExpungeEntries.length; j++ )
!       {
!         if ( pExpungeEntries[j].equals( positiveEntries[i] ) ) {
!           match = true;
!           break;
!         }
!       }
!       if ( !match ) pos.add( positiveEntries[i] );
!     }
! 
!     // Now check for entries that need replacing
!     for ( int i = 0; i < pEntries.length; i++ )
!     {
!       boolean match = false;
!       String user = pEntries[i].getUser();
!       for ( int j = 0; j < pos.size(); j++ )
!       {
!         if ( user.equals( ((ACL.Entry)pos.get(j)).getUser() ) ) {
!           pos.set( j, pEntries[i] );
!           match = true;
!           break;
!         }
!       }
!       if ( !match ) pos.add( pEntries[i] );
!     }
!     setPositiveEntries( (ACL.Entry[])pos.toArray(new ACL.Entry[pos.size()]) );
! 
!     // Delete negative expunge entries next
!     n = getNegativeEntryCount();
!     for ( int i = 0; i < n; i++ )
!     {
!       boolean match = false;
!       for ( int j = 0; j < nExpungeEntries.length; j++ )
!       {
!         if ( nExpungeEntries[j].equals( negativeEntries[i] ) ) {
!           match = true;
!           break;
!         }
!       }
!       if ( !match ) neg.add( negativeEntries[i] );
!     }
! 
!     // Now check for entries that need replacing (negative)
!     for ( int i = 0; i < nEntries.length; i++ )
!     {
!       boolean match = false;
!       String user = nEntries[i].getUser();
!       for ( int j = 0; j < neg.size(); j++ )
!       {
!         if ( user.equals( ((ACL.Entry)neg.get(j)).getUser() ) ) {
!           neg.set( j, nEntries[i] );
!           match = true;
!           break;
!         }
!       }
!       if ( !match ) neg.add( nEntries[i] );
!     }
!     setNegativeEntries( (ACL.Entry[])neg.toArray(new ACL.Entry[neg.size()]) );
    }
  
  
!   /*--------------------------------------------------------------------------*/
!   /* Private Methods                                                          */
!   /*--------------------------------------------------------------------------*/
! 
    /**
!    * Returns a resized array containing only valid (non-empty) ACL entries.
!    *
!    * @param  entries Original array of entries, possibly containing empty 
!    *                 entries.
!    * @return         All non-empty ACL entries
     */
!   private ACL.Entry[] getNonEmptyEntries( ACL.Entry[] entries )
    {
!     if ( entries == null ) return new ACL.Entry[0];
!     ArrayList list = new ArrayList( entries.length );
      for (int i = 0; i < entries.length; i++)
      {
        boolean isNonEmpty = entries[i].canRead()   ||
--- 33,269 ----
   * This class is an extension of the standard Java File class with file-based 
   * manipulation methods overridden by integrated AFS native methods.
   *
   * @version 2.0, 04/18/2001 - Completely revised class for efficiency.
   */
  
  public class ACL implements Serializable, Comparable
  {
!    protected ACL.Entry[] positiveEntries;
!    protected ACL.Entry[] negativeEntries;
!    protected String path;
   
!   public ACL(String path) throws AFSException
    {
!   	this(path,true);
!  }
    
! public ACL(String path, boolean init) throws AFSException {
! 	int numberPositiveEntries = 0;
! 	int numberNegativeEntries = 0;
! 	ACL.Entry aclEntry;
! 	String buffer;
! 	this.path = path;
! 
! 	if (init) {
! 
! 		StringTokenizer st = new StringTokenizer(getACLString(path), "\n\t");
! 
! 		buffer = st.nextToken();
! 		numberPositiveEntries = new Integer(buffer).intValue();
! 		positiveEntries = new ACL.Entry[numberPositiveEntries];
! 
! 		buffer = st.nextToken();
! 		numberNegativeEntries = new Integer(buffer).intValue();
! 		negativeEntries = new ACL.Entry[numberNegativeEntries];
! 
! 		for (int i = 0; i < numberPositiveEntries; i++) {
! 			aclEntry = new ACL.Entry();
! 			aclEntry.setUser(st.nextToken());
! 			aclEntry.setPermissions(new Integer(st.nextToken()).intValue());
! 			positiveEntries[i] = aclEntry;
! 		}
! 
! 		for (int i = 0; i < numberNegativeEntries; i++) {
! 			aclEntry = new ACL.Entry();
! 			aclEntry.setUser(st.nextToken());
! 			aclEntry.setPermissions(new Integer(st.nextToken()).intValue());
! 			negativeEntries[i] = aclEntry;
! 		}
! 	}else{
! 		positiveEntries = new ACL.Entry[numberPositiveEntries];
! 		negativeEntries = new ACL.Entry[numberNegativeEntries];
! 	}
! }
    public int getEntryCount()
    {
!     return positiveEntries.length + positiveEntries.length;
    }
    public String getPath()
    {
      return path;
    }
!   public void setPath(String path)
    {
! 	this.path= path;
    }
    public ACL.Entry[] getPositiveEntries()
    {
!     return positiveEntries;
    }
!   public void addPositiveEntry(ACL.Entry entry) throws AFSException
    {
!     int n = positiveEntries.length;
      ACL.Entry[] e = new ACL.Entry[n + 1];
      System.arraycopy(positiveEntries, 0, e, 0, n);
!     e[n] = entry;
      positiveEntries = e;
!     setACLString(path, getFormattedString());
    }
!   public void setPositiveEntries(ACL.Entry[] entries) throws AFSException
    {
      this.positiveEntries = entries;
!     setACLString(path, getFormattedString());
    }
    public ACL.Entry[] getNegativeEntries()
    {
!     return negativeEntries;
    }
!   public void addNegativeEntry(ACL.Entry entry) throws AFSException
    {
!     int n = negativeEntries.length;
      ACL.Entry[] e = new ACL.Entry[n + 1];
!     System.arraycopy(negativeEntries, 0, e, 0, n);
      e[n] = entry;
      negativeEntries = e;
!     setACLString(path, getFormattedString());
    }
!   
!   public void addAllNegativeEntrys(ACL.Entry[] entry) throws AFSException
    {
! 	int n = negativeEntries.length;
! 	ACL.Entry[] e = new ACL.Entry[n + entry.length];
! 	System.arraycopy(negativeEntries, 0, e, 0, n);
! 	System.arraycopy(entry,0,e,n,entry.length);
! 	
! 	negativeEntries = e;
! 	setACLString(path, getFormattedString());
!  
    }
!   
!   public void addAllPositiveEntrys(ACL.Entry[] entry) throws AFSException
    {
! 	int n = positiveEntries.length;
! 	ACL.Entry[] e = new ACL.Entry[n + entry.length];
! 	System.arraycopy(positiveEntries, 0, e, 0, n);
! 	System.arraycopy(entry,0,e,n,entry.length);
! 	
! 	positiveEntries = e;
! 	setACLString(path, getFormattedString());
!   
    }
!   public void setNegativeEntries(ACL.Entry[] entries) throws AFSException
    {
      this.negativeEntries = entries;
!     setACLString(path, getFormattedString());
    }
  
!  /**
!  * Needs a AFS Connection
!  */
!   public void flush() throws AFSException
    {
!     setACLString(path, getFormattedString());
    }
    
    /**
!    * removes a ACL Entry from acl
     */
!   public void removeNegativeEntry(Entry entry) throws AFSException {
! 			
! 	  ArrayList arr = new ArrayList();
! 		
! 	  for (int i = 0; i < negativeEntries.length; i++) {
! 					
! 		  if(!negativeEntries[i].equals(entry)){
! 			  arr.add(negativeEntries[i]);
! 		  }
! 	  }
! 	  negativeEntries = (ACL.Entry[]) arr.toArray(new ACL.Entry[arr.size()]);
! 	
! 	setACLString(path, getFormattedString());
    }
    
    /**
!    * removes all ACL Entrys from acl
     */
!   public void removeAllNegativeEntrys() throws AFSException {
! 	negativeEntries = new Entry[0];
! 	setACLString(path, getFormattedString());
    }
!   
    /**
!    * removes all ACL Entrys from acl
     */
!   public void removeAllPositiveEntrys() throws AFSException {
! 	positiveEntries = new Entry[0];
! 	setACLString(path, getFormattedString());
    }
+   
+   
+   public boolean containsNegative(Entry entry) {
+   	
+ 	for (int i = 0; i < negativeEntries.length; i++) {
+ 					
+ 			 if(negativeEntries[i].equals(entry)){
+ 				 return true;
+ 			 }
+ 		 }
+ 	return false;
+   }
+   
+   
+ 	public Entry getNegative(String entryname) {
  
+ 	  for (int i = 0; i < negativeEntries.length; i++) {
  
! 			   if(negativeEntries[i].getUser().equalsIgnoreCase(entryname)){
! 				   return negativeEntries[i];
! 			   }
! 		   }
! 	  return null;
! 	}
! 	
! 	public Entry getPositive(String entryname) {
! 
! 	  for (int i = 0; i < positiveEntries.length; i++) {
! 
! 			   if(positiveEntries[i].getUser().equalsIgnoreCase(entryname)){
! 				   return positiveEntries[i];
! 			   }
! 		   }
! 	  return null;
! 	}
!   public boolean containsPositive(Entry entry) {
!   	
! 	for (int i = 0; i < positiveEntries.length; i++) {
! 					
! 			 if(positiveEntries[i].equals(entry)){
! 				 return true;
! 			 }
! 		 }
! 	return false;
!   }
!   
    /**
!    * removes a ACL Entry from acl
     */
!   public void removePositiveEntry(Entry entry) throws AFSException {
! 			
! 	  ArrayList arr = new ArrayList();
! 		
! 	  for (int i = 0; i < positiveEntries.length; i++) {
! 					
! 		  if(!positiveEntries[i].equals(entry)){
! 			  arr.add(positiveEntries[i]);
! 		  }
! 	  }
! 	  positiveEntries = (ACL.Entry[]) arr.toArray(new ACL.Entry[arr.size()]);
! 	setACLString(path, getFormattedString());
!   }
! 
!   private ACL.Entry[] getNonEmptyEntries(ACL.Entry[] entries)
    {
!     ArrayList response = new ArrayList(entries.length);
      for (int i = 0; i < entries.length; i++)
      {
        boolean isNonEmpty = entries[i].canRead()   ||
***************
*** 633,660 ****
                             entries[i].canDelete() ||
                             entries[i].canLock()   ||
                             entries[i].canAdmin();
!       if (isNonEmpty) list.add(entries[i]);
      }
!     if (list.size() == entries.length) return entries;
!     return (ACL.Entry[])list.toArray(new ACL.Entry[list.size()]);
    }
  
!   private void entriesToString( ACL.Entry[] entries, StringBuffer buffer )
    {
      for (int i = 0; i < entries.length; i++)
      {
!       this.entryToString((ACL.Entry)entries[i], buffer);
      }
    }
  
!   private void entryToString( ACL.Entry entry, StringBuffer buffer )
    {
!     buffer.append(entry.getUser() + '\t' + entry.getPermissionsMask() + '\n');
!   }
! 
!   private void update() throws AFSException
!   {
!     if ( path != null ) setACLString(path, getFormattedString());
    }
  
    /**
--- 273,295 ----
                             entries[i].canDelete() ||
                             entries[i].canLock()   ||
                             entries[i].canAdmin();
!       if (isNonEmpty) response.add(entries[i]);
      }
!     if (response.size() == entries.length) return entries;
!     return (ACL.Entry[])response.toArray(new ACL.Entry[response.size()]);
    }
  
!   private void entriesToString(ACL.Entry[] entries, StringBuffer response)
    {
      for (int i = 0; i < entries.length; i++)
      {
!       this.entryToString((ACL.Entry)entries[i], response);
      }
    }
  
!   private void entryToString(ACL.Entry entry, StringBuffer response)
    {
!     response.append(entry.getUser() + '\t' + entry.getPermissionsMask() + '\n');
    }
  
    /**
***************
*** 677,686 ****
      return out.toString();
    }
  
! 
!   /*--------------------------------------------------------------------------*/
!   /* Custom Override Methods                                                  */
!   /*--------------------------------------------------------------------------*/
  
    /**
     * Compares two ACL objects respective to their paths and does not
--- 312,318 ----
      return out.toString();
    }
  
!   /////////////// custom override methods ////////////////////
  
    /**
     * Compares two ACL objects respective to their paths and does not
***************
*** 735,748 ****
      ACL.Entry[] nonEmptyPos = this.getNonEmptyEntries(this.getPositiveEntries());
      ACL.Entry[] nonEmptyNeg = this.getNonEmptyEntries(this.getNegativeEntries());
  
!     StringBuffer out = new StringBuffer();
!     if ( path == null ) {
!       out.append("Delta ACL\n");
!     } else {
!       out.append("ACL for ");
!       out.append(path);
!       out.append("\n");
!     }
      out.append("Positive Entries:\n");
      for (int i = 0; i < nonEmptyPos.length; i++) {
        out.append("  ");
--- 367,375 ----
      ACL.Entry[] nonEmptyPos = this.getNonEmptyEntries(this.getPositiveEntries());
      ACL.Entry[] nonEmptyNeg = this.getNonEmptyEntries(this.getNegativeEntries());
  
!     StringBuffer out = new StringBuffer("ACL for ");
!     out.append(path);
!     out.append("\n");
      out.append("Positive Entries:\n");
      for (int i = 0; i < nonEmptyPos.length; i++) {
        out.append("  ");
***************
*** 756,788 ****
        }
      }
  
-     // Check to see if this is a Delta ACL
-     if ( path == null ) {
-       nonEmptyPos = this.getNonEmptyEntries(this.getPositiveExpungeEntries());
-       nonEmptyNeg = this.getNonEmptyEntries(this.getNegativeExpungeEntries());
- 
-       if (nonEmptyPos.length > 0) {
-         out.append("Positive Entries to Delete:\n");
-         for (int i = 0; i < nonEmptyPos.length; i++) {
-           out.append("  ");
-           out.append(nonEmptyPos[i].toString());
-         }
-       }
-       if (nonEmptyNeg.length > 0) {
-         out.append("Negative Entries to Delete:\n");
-         for (int i = 0; i < nonEmptyNeg.length; i++) {
-           out.append("  ");
-           out.append(nonEmptyNeg[i].toString());
-         }
-       }
-     }
- 
      return out.toString();
    }
  
!   /*--------------------------------------------------------------------------*/
!   /* Native Methods                                                           */
!   /*--------------------------------------------------------------------------*/
  
    /**
     * Returns a formatted String representing the ACL for the specified path.
--- 383,392 ----
        }
      }
  
      return out.toString();
    }
  
!   /////////////// native methods ////////////////////
  
    /**
     * Returns a formatted String representing the ACL for the specified path.
***************
*** 807,813 ****
    private native void setACLString(String path, String aclString) throws AFSException;
  
    /*====================================================================*/
!   /* INNER CLASSES                                                      */
    /*====================================================================*/
  
    /**
--- 411,417 ----
    private native void setACLString(String path, String aclString) throws AFSException;
  
    /*====================================================================*/
!   /* INNER CLASSES  */
    /*====================================================================*/
  
    /**
***************
*** 985,997 ****
        username = user;
      }
      /** 
!      * <IMG SRC="file.gif" ALT="File Permission" WIDTH="16" HEIGHT="16" BORDER="0"> Tests whether the ACL permits <code>read</code> access.
       *
       * <p> This permission enables a user to read the contents of files in the directory 
       * and to obtain complete status information for the files (read/retrieve the file 
       * attributes).
       *
!      * <p><FONT COLOR="666699"><IMG SRC="file.gif" ALT="File Permission" WIDTH="16" HEIGHT="16" BORDER="0"> <U><B>File Permission</B></U></FONT><BR>
       * This permission is meaningful with respect to files in 
       * a directory, rather than the directory itself or its subdirectories. 
       *
--- 589,601 ----
        username = user;
      }
      /** 
!      * <IMG SRC="file.gif" ALT="File Permission" WIDTH="15" HEIGHT="15" BORDER="0"> Tests whether the ACL permits <code>read</code> access.
       *
       * <p> This permission enables a user to read the contents of files in the directory 
       * and to obtain complete status information for the files (read/retrieve the file 
       * attributes).
       *
!      * <p><FONT COLOR="666699"><IMG SRC="file.gif" ALT="File Permission" WIDTH="15" HEIGHT="15" BORDER="0"> <U><B>File Permission</B></U></FONT><BR>
       * This permission is meaningful with respect to files in 
       * a directory, rather than the directory itself or its subdirectories. 
       *
***************
*** 1016,1022 ****
        r = flag;
      }
      /** 
!      * <IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="16" HEIGHT="16" BORDER="0"> Tests whether the ACL permits lookup access.
       *
       * <p> This permission functions as something of a gate keeper for access to the directory 
       * and its files, because a user must have it in order to exercise any other permissions. 
--- 620,626 ----
        r = flag;
      }
      /** 
!      * <IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="15" HEIGHT="15" BORDER="0"> Tests whether the ACL permits lookup access.
       *
       * <p> This permission functions as something of a gate keeper for access to the directory 
       * and its files, because a user must have it in order to exercise any other permissions. 
***************
*** 1036,1042 ****
       * the directory. Those operations require the <code>lookup</code> permission on the ACL
       * of the subdirectory itself.
       *
!      * <p><FONT COLOR="666699"><IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="16" HEIGHT="16" BORDER="0"> <U><B>Directory Permission</B></U></FONT><BR>
       * This permission is meaningful with respect to the 
       * directory itself. For example, the <code>insert</code> permission (see: {@link #canInsert})
       * does not control addition of data to a file, but rather creation of a new file or 
--- 640,646 ----
       * the directory. Those operations require the <code>lookup</code> permission on the ACL
       * of the subdirectory itself.
       *
!      * <p><FONT COLOR="666699"><IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="15" HEIGHT="15" BORDER="0"> <U><B>Directory Permission</B></U></FONT><BR>
       * This permission is meaningful with respect to the 
       * directory itself. For example, the <code>insert</code> permission (see: {@link #canInsert})
       * does not control addition of data to a file, but rather creation of a new file or 
***************
*** 1063,1075 ****
        l = flag;
      }
      /** 
!      * <IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="16" HEIGHT="16" BORDER="0"> Tests whether the ACL permits <code>insert</code> access.
       *
       * <p> This permission enables a user to add new files to the directory, either by creating 
       * or copying, and to create new subdirectories. It does not extend into any subdirectories,
       * which are protected by their own ACLs.
       *
!      * <p><FONT COLOR="666699"><IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="16" HEIGHT="16" BORDER="0"> <U><B>Directory Permission</B></U></FONT><BR>
       * This permission is meaningful with respect to the 
       * directory itself. For example, the <code>insert</code> permission (see: {@link #canInsert})
       * does not control addition of data to a file, but rather creation of a new file or 
--- 667,679 ----
        l = flag;
      }
      /** 
!      * <IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="15" HEIGHT="15" BORDER="0"> Tests whether the ACL permits <code>insert</code> access.
       *
       * <p> This permission enables a user to add new files to the directory, either by creating 
       * or copying, and to create new subdirectories. It does not extend into any subdirectories,
       * which are protected by their own ACLs.
       *
!      * <p><FONT COLOR="666699"><IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="15" HEIGHT="15" BORDER="0"> <U><B>Directory Permission</B></U></FONT><BR>
       * This permission is meaningful with respect to the 
       * directory itself. For example, the <code>insert</code> permission (see: {@link #canInsert})
       * does not control addition of data to a file, but rather creation of a new file or 
***************
*** 1096,1108 ****
        i = flag;
      }
      /** 
!      * <IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="16" HEIGHT="16" BORDER="0"> Tests whether the ACL permits <code>delete</code> access.
       *
       * <p> This permission enables a user to remove files and subdirectories from the directory 
       * or move them into other directories (assuming that the user has the <code>insert</code>
       * (see: {@link #canInsert}) permission on the ACL of the other directories).
       *
!      * <p><FONT COLOR="666699"><IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="16" HEIGHT="16" BORDER="0"> <U><B>Directory Permission</B></U></FONT><BR>
       * This permission is meaningful with respect to the 
       * directory itself. For example, the <code>insert</code> permission (see: {@link #canInsert})
       * does not control addition of data to a file, but rather creation of a new file or 
--- 700,712 ----
        i = flag;
      }
      /** 
!      * <IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="15" HEIGHT="15" BORDER="0"> Tests whether the ACL permits <code>delete</code> access.
       *
       * <p> This permission enables a user to remove files and subdirectories from the directory 
       * or move them into other directories (assuming that the user has the <code>insert</code>
       * (see: {@link #canInsert}) permission on the ACL of the other directories).
       *
!      * <p><FONT COLOR="666699"><IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="15" HEIGHT="15" BORDER="0"> <U><B>Directory Permission</B></U></FONT><BR>
       * This permission is meaningful with respect to the 
       * directory itself. For example, the <code>insert</code> permission (see: {@link #canInsert})
       * does not control addition of data to a file, but rather creation of a new file or 
***************
*** 1129,1140 ****
        d = flag;
      }
      /** 
!      * <IMG SRC="file.gif" ALT="File Permission" WIDTH="16" HEIGHT="16" BORDER="0"> Tests whether the ACL permits <code>write</code> access.
       *
       * <p> This permission enables a user to modify the contents of files in the directory 
       * and to change their operating system specific mode bits. 
       *
!      * <p><FONT COLOR="666699"><IMG SRC="file.gif" ALT="File Permission" WIDTH="16" HEIGHT="16" BORDER="0"> <U><B>File Permission</B></U></FONT><BR>
       * This permission is meaningful with respect to files in 
       * a directory, rather than the directory itself or its subdirectories. 
       *
--- 733,744 ----
        d = flag;
      }
      /** 
!      * <IMG SRC="file.gif" ALT="File Permission" WIDTH="15" HEIGHT="15" BORDER="0"> Tests whether the ACL permits <code>write</code> access.
       *
       * <p> This permission enables a user to modify the contents of files in the directory 
       * and to change their operating system specific mode bits. 
       *
!      * <p><FONT COLOR="666699"><IMG SRC="file.gif" ALT="File Permission" WIDTH="15" HEIGHT="15" BORDER="0"> <U><B>File Permission</B></U></FONT><BR>
       * This permission is meaningful with respect to files in 
       * a directory, rather than the directory itself or its subdirectories. 
       *
***************
*** 1159,1170 ****
        w = flag;
      }
      /** 
!      * <IMG SRC="file.gif" ALT="File Permission" WIDTH="16" HEIGHT="16" BORDER="0"> Tests whether the ACL permits the <code>lock</code> authority.
       *
       * <p> This permission enables the user to run programs that issue system calls to 
       * lock files in the directory. 
       *
!      * <p><FONT COLOR="666699"><IMG SRC="file.gif" ALT="File Permission" WIDTH="16" HEIGHT="16" BORDER="0"> <U><B>File Permission</B></U></FONT><BR>
       * This permission is meaningful with respect to files in 
       * a directory, rather than the directory itself or its subdirectories. 
       *
--- 763,774 ----
        w = flag;
      }
      /** 
!      * <IMG SRC="file.gif" ALT="File Permission" WIDTH="15" HEIGHT="15" BORDER="0"> Tests whether the ACL permits the <code>lock</code> authority.
       *
       * <p> This permission enables the user to run programs that issue system calls to 
       * lock files in the directory. 
       *
!      * <p><FONT COLOR="666699"><IMG SRC="file.gif" ALT="File Permission" WIDTH="15" HEIGHT="15" BORDER="0"> <U><B>File Permission</B></U></FONT><BR>
       * This permission is meaningful with respect to files in 
       * a directory, rather than the directory itself or its subdirectories. 
       *
***************
*** 1189,1195 ****
        k = flag;
      }
      /** 
!      * <IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="16" HEIGHT="16" BORDER="0"> Tests whether the ACL permits <code>administer</code> access.
       *
       * <p> This permission enables a user to change the directory's ACL. Members of the 
       * <code>system:administrators</code> group implicitly have this permission on every 
--- 793,799 ----
        k = flag;
      }
      /** 
!      * <IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="15" HEIGHT="15" BORDER="0"> Tests whether the ACL permits <code>administer</code> access.
       *
       * <p> This permission enables a user to change the directory's ACL. Members of the 
       * <code>system:administrators</code> group implicitly have this permission on every 
***************
*** 1197,1203 ****
       * owner of a directory implicitly has this permission on its ACL and those of all 
       * directories below it that he or she owns. 
       *
!      * <p><FONT COLOR="666699"><IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="16" HEIGHT="16" BORDER="0"> <U><B>Directory Permission</B></U></FONT><BR>
       * This permission is meaningful with respect to the 
       * directory itself. For example, the <code>insert</code> permission (see: {@link #canInsert})
       * does not control addition of data to a file, but rather creation of a new file or 
--- 801,807 ----
       * owner of a directory implicitly has this permission on its ACL and those of all 
       * directories below it that he or she owns. 
       *
!      * <p><FONT COLOR="666699"><IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="15" HEIGHT="15" BORDER="0"> <U><B>Directory Permission</B></U></FONT><BR>
       * This permission is meaningful with respect to the 
       * directory itself. For example, the <code>insert</code> permission (see: {@link #canInsert})
       * does not control addition of data to a file, but rather creation of a new file or 
***************
*** 1261,1263 ****
--- 865,876 ----
  
    }
  }
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
Index: openafs/src/JAVA/classes/org/openafs/jafs/AFSException.java
diff -c openafs/src/JAVA/classes/org/openafs/jafs/AFSException.java:1.2 openafs/src/JAVA/classes/org/openafs/jafs/AFSException.java:1.2.2.1
*** openafs/src/JAVA/classes/org/openafs/jafs/AFSException.java:1.2	Thu Jun 19 12:53:14 2003
--- openafs/src/JAVA/classes/org/openafs/jafs/AFSException.java	Fri Oct 14 22:14:09 2005
***************
*** 187,189 ****
--- 187,204 ----
    }
    /*-----------------------------------------------------------------------*/
  }
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
Index: openafs/src/JAVA/classes/org/openafs/jafs/AFSSecurityException.java
diff -c openafs/src/JAVA/classes/org/openafs/jafs/AFSSecurityException.java:1.2 openafs/src/JAVA/classes/org/openafs/jafs/AFSSecurityException.java:1.2.2.1
*** openafs/src/JAVA/classes/org/openafs/jafs/AFSSecurityException.java:1.2	Thu Jun 19 12:53:14 2003
--- openafs/src/JAVA/classes/org/openafs/jafs/AFSSecurityException.java	Fri Oct 14 22:14:09 2005
***************
*** 185,187 ****
--- 185,202 ----
    }
    /*-----------------------------------------------------------------------*/
  }
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
Index: openafs/src/JAVA/classes/org/openafs/jafs/Cell.java
diff -c openafs/src/JAVA/classes/org/openafs/jafs/Cell.java:1.2 openafs/src/JAVA/classes/org/openafs/jafs/Cell.java:1.2.2.1
*** openafs/src/JAVA/classes/org/openafs/jafs/Cell.java:1.2	Thu Jun 19 12:53:14 2003
--- openafs/src/JAVA/classes/org/openafs/jafs/Cell.java	Fri Oct 14 22:14:09 2005
***************
*** 115,121 ****
    protected ArrayList serverNames;
  
    protected String name;
!   protected int cellHandle;
    protected Token token;
  
    protected int maxGroupID;
--- 115,121 ----
    protected ArrayList serverNames;
  
    protected String name;
!   protected long cellHandle;
    protected Token token;
  
    protected int maxGroupID;
***************
*** 142,148 ****
      this.name  = token.getCellName();
  
      cellHandle = getCellHandle( name, token.getHandle() );
! 
      users = null;
      userNames = null;
      groups = null;
--- 142,148 ----
      this.name  = token.getCellName();
  
      cellHandle = getCellHandle( name, token.getHandle() );
! //System.out.println("cellHandle: " + cellHandle);
      users = null;
      userNames = null;
      groups = null;
***************
*** 270,276 ****
  
    /**
     * Sets all the information fields of this <code>Cell</code> object, 
!    * such as max group and user ids, to their most current values.
     *
     * @exception AFSException  If an error occurs in the native code     
     */
--- 270,276 ----
  
    /**
     * Sets all the information fields of this <code>Cell</code> object, 
!    * such as max group and user ids, to trheir most current values.
     *
     * @exception AFSException  If an error occurs in the native code     
     */
***************
*** 293,299 ****
      users = new ArrayList();
  
      // get kas entries
!     int iterationId = getKasUsersBegin( cellHandle );
  
      currUser = new User( this );
      boolean authorized = false;
--- 293,299 ----
      users = new ArrayList();
  
      // get kas entries
!     long iterationId = getKasUsersBegin( cellHandle );
  
      currUser = new User( this );
      boolean authorized = false;
***************
*** 310,322 ****
          System.err.println("ERROR Cell::refreshUsers():kas (User: " 
  			   + currUser.getName() + ") -> " + e.getMessage());
          authorized = false;
!         if (org.openafs.jafs.ErrorTable.isPermissionDenied(e.getErrorCode())) {
! 	  // Check to see if the user has failed more than 25 times,
! 	  // if so it is most likely because they are not appropriately
! 	  // authorized to list or examine users.  May want to check for
! 	  // KAS admin attribute.
! 	  if ( r++ > 25 ) r = 0;
! 	}
        }
      } 
      getKasUsersDone( iterationId );
--- 310,317 ----
          System.err.println("ERROR Cell::refreshUsers():kas (User: " 
  			   + currUser.getName() + ") -> " + e.getMessage());
          authorized = false;
!         //if (org.openafs.jafs.ErrorCodes.isPermissionDenied(e.getErrorCode())) 
! 	//r = 0;
        }
      } 
      getKasUsersDone( iterationId );
***************
*** 339,351 ****
          System.err.println("ERROR Cell::refreshUsers():pts (User: " 
  			   + currUser.getName() + ") -> " + e.getMessage());
          authorized = false;
!         if (org.openafs.jafs.ErrorTable.isPermissionDenied(e.getErrorCode())) {
! 	  // Check to see if the user has failed more than 25 times,
! 	  // if so it is most likely because they are not appropriately
! 	  // authorized to list or examine users.  May want to check for
! 	  // KAS admin attribute.
! 	  if ( r++ > 25 ) r = 0;
! 	}
        }
      } 
      getPtsUsersDone( iterationId );
--- 334,341 ----
          System.err.println("ERROR Cell::refreshUsers():pts (User: " 
  			   + currUser.getName() + ") -> " + e.getMessage());
          authorized = false;
!         //if (org.openafs.jafs.ErrorCodes.isPermissionDenied(e.getErrorCode())) 
! 	// r = 0;
        }
      } 
      getPtsUsersDone( iterationId );
***************
*** 364,370 ****
      userNames = new ArrayList();
  
      // get kas entries
!     int iterationId = getKasUsersBegin( cellHandle );
      while( ( currName = getKasUsersNextString( iterationId )) != null ) {
        userNames.add( currName );
      } 
--- 354,360 ----
      userNames = new ArrayList();
  
      // get kas entries
!     long iterationId = getKasUsersBegin( cellHandle );
      while( ( currName = getKasUsersNextString( iterationId )) != null ) {
        userNames.add( currName );
      } 
***************
*** 391,397 ****
    {
      Group currGroup;
  
!     int iterationId = getGroupsBegin( cellHandle );
      
      groups = new ArrayList();
      
--- 381,387 ----
    {
      Group currGroup;
  
!     long iterationId = getGroupsBegin( cellHandle );
      
      groups = new ArrayList();
      
***************
*** 407,419 ****
          r = getGroupsNext( cellHandle, iterationId, currGroup );
          authorized = true;
        } catch (AFSException e) {
!         System.err.println("ERROR Cell::refreshGroups() (Group: " 
! 			   + currGroup.getName() + ") -> " + e.getMessage());
!         authorized = false;
!         if (org.openafs.jafs.ErrorTable.isPermissionDenied(e.getErrorCode())) {
! 	  if ( r++ > 25 ) r = 0;
! 	}
  
        }
      } 
      Cell.getGroupsDone( iterationId );
--- 397,409 ----
          r = getGroupsNext( cellHandle, iterationId, currGroup );
          authorized = true;
        } catch (AFSException e) {
! 	e.printStackTrace();
  
+ //        System.err.println("ERROR Cell::refreshGroups() (Group: " 
+ //			   + currGroup.getName() + ") -> " + e.getMessage());
+         authorized = false;
+         //if (org.openafs.jafs.ErrorCodes.isPermissionDenied(e.getErrorCode())) 
+ 	// r = 0;
        }
      } 
      Cell.getGroupsDone( iterationId );
***************
*** 428,434 ****
    {
      String currName;
  
!     int iterationId = getGroupsBegin( cellHandle );
      
      groupNames = new ArrayList();
      while( ( currName = getGroupsNextString( iterationId ) ) != null ) {
--- 418,424 ----
    {
      String currName;
  
!     long iterationId = getGroupsBegin( cellHandle );
      
      groupNames = new ArrayList();
      while( ( currName = getGroupsNextString( iterationId ) ) != null ) {
***************
*** 446,452 ****
    {
      Server currServer;
  
!     int iterationId = getServersBegin( cellHandle );
     
      servers = new ArrayList();
      
--- 436,442 ----
    {
      Server currServer;
  
!     long iterationId = getServersBegin( cellHandle );
     
      servers = new ArrayList();
      
***************
*** 456,476 ****
      while( r != 0 ) {
        try {
          if (authorized) {
!           System.out.println("[Java] Cell::refreshServers() -> adding server: " 
! 			     + currServer.getName());
            servers.add( currServer );
            currServer = new Server( this );
          }
          r = getServersNext( cellHandle, iterationId, currServer );
! System.out.println("[Java] Cell::refreshServers() -> r: " + r);
          authorized = true;
        } catch (AFSException e) {
          System.err.println("ERROR Cell::refreshServers() (Server: " 
  			   + currServer.getName() + ") -> " + e.getMessage());
          authorized = false;
!         if (org.openafs.jafs.ErrorTable.isPermissionDenied(e.getErrorCode())) {
! 	  if ( r++ > 25 ) r = 0;
! 	}
        }
      } 
      getServersDone( iterationId );
--- 446,465 ----
      while( r != 0 ) {
        try {
          if (authorized) {
!           //System.out.println("[Java] Cell::refreshServers() -> adding server: " 
! 		//	     + currServer.getName());
            servers.add( currServer );
            currServer = new Server( this );
          }
          r = getServersNext( cellHandle, iterationId, currServer );
! //System.out.println("[Java] Cell::refreshServers() -> r: " + r);
          authorized = true;
        } catch (AFSException e) {
          System.err.println("ERROR Cell::refreshServers() (Server: " 
  			   + currServer.getName() + ") -> " + e.getMessage());
          authorized = false;
!         //if (e.getErrorCode() == org.openafs.jafs.ErrorCodes.PERMISSION_DENIED) 
!         // r = 0;
        }
      } 
      getServersDone( iterationId );
***************
*** 486,492 ****
    {
      String currName;
  
!     int iterationId = getServersBegin( cellHandle );
  
      serverNames = new ArrayList();
      while( ( currName = getServersNextString( iterationId ) ) != null ) {
--- 475,481 ----
    {
      String currName;
  
!     long iterationId = getServersBegin( cellHandle );
  
      serverNames = new ArrayList();
      while( ( currName = getServersNextString( iterationId ) ) != null ) {
***************
*** 658,664 ****
      User[] users  = new User[length];
      User currUser = new User( this );
      int ptsOnlyCount = getPtsOnlyUserCount(cellHandle);
!     int iterationID = 0;
      int indexPTS = 0;
      int indexKAS = 0;
  
--- 647,653 ----
      User[] users  = new User[length];
      User currUser = new User( this );
      int ptsOnlyCount = getPtsOnlyUserCount(cellHandle);
!     long iterationID = 0;
      int indexPTS = 0;
      int indexKAS = 0;
  
***************
*** 800,806 ****
      String[] users  = new String[length];
      String currUser;
      int ptsOnlyCount = getPtsOnlyUserCount(cellHandle);
!     int iterationID = 0;
      int indexPTS = 0;
      int indexKAS = 0;
  
--- 789,795 ----
      String[] users  = new String[length];
      String currUser;
      int ptsOnlyCount = getPtsOnlyUserCount(cellHandle);
!     long iterationID = 0;
      int indexPTS = 0;
      int indexKAS = 0;
  
***************
*** 968,974 ****
      Group currGroup = new Group( this );
      int i = 0;
  
!     int iterationID = getGroupsBeginAt( cellHandle, startIndex );
  
      while( getGroupsNext( cellHandle, iterationID, currGroup ) != 0 
  	   && i < length ) {
--- 957,963 ----
      Group currGroup = new Group( this );
      int i = 0;
  
!     long iterationID = getGroupsBeginAt( cellHandle, startIndex );
  
      while( getGroupsNext( cellHandle, iterationID, currGroup ) != 0 
  	   && i < length ) {
***************
*** 1065,1071 ****
      String currGroup;
      int i = 0;
  
!     int iterationID = getGroupsBeginAt( cellHandle, startIndex );
  
      while( (currGroup = getGroupsNextString( iterationID )) != null &&
              i < length )
--- 1054,1060 ----
      String currGroup;
      int i = 0;
  
!     long iterationID = getGroupsBeginAt( cellHandle, startIndex );
  
      while( (currGroup = getGroupsNextString( iterationID )) != null &&
              i < length )
***************
*** 1216,1222 ****
     * @return the cell handle
     * @exception AFSException  If an error occurs in the native code
     */
!   public int getCellHandle() throws AFSException
    {
      return cellHandle;
    }
--- 1205,1211 ----
     * @return the cell handle
     * @exception AFSException  If an error occurs in the native code
     */
!   public long getCellHandle() throws AFSException
    {
      return cellHandle;
    }
***************
*** 1266,1272 ****
     *
     * @return    a <code>String</code> representation of this <code>Cell</code>
     */
!   protected String getInfo()
    {
      String r = "Cell: " + name + "\n\n";
      try {
--- 1255,1261 ----
     *
     * @return    a <code>String</code> representation of this <code>Cell</code>
     */
!   public String getInfo()
    {
      String r = "Cell: " + name + "\n\n";
      try {
***************
*** 1320,1326 ****
     * @return    a <code>String</code> representation of the users
     * @see       User#getInfo
     */
!   protected String getInfoUsers() throws AFSException
    {
      String r;
  
--- 1309,1315 ----
     * @return    a <code>String</code> representation of the users
     * @see       User#getInfo
     */
!   public String getInfoUsers() throws AFSException
    {
      String r;
  
***************
*** 1342,1348 ****
     * @return    a <code>String</code> representation of the groups
     * @see       Group#getInfo
     */
!   protected String getInfoGroups() throws AFSException
    {
      String r;
  
--- 1331,1337 ----
     * @return    a <code>String</code> representation of the groups
     * @see       Group#getInfo
     */
!   public String getInfoGroups() throws AFSException
    {
      String r;
  
***************
*** 1363,1369 ****
     * @return    a <code>String</code> representation of the servers
     * @see       Server#getInfo
     */
!   protected String getInfoServers() 
        throws AFSException
    {
      String r;
--- 1352,1358 ----
     * @return    a <code>String</code> representation of the servers
     * @see       Server#getInfo
     */
!   public String getInfoServers() 
        throws AFSException
    {
      String r;
***************
*** 1412,1418 ****
     * @exception AFSException  If an error occurs in the native code
     * @see Cell#getCellHandle
     */
!   protected static native int getKasUserCount( int cellHandle )
      throws AFSException;
  
    /**
--- 1401,1407 ----
     * @exception AFSException  If an error occurs in the native code
     * @see Cell#getCellHandle
     */
!   protected static native int getKasUserCount( long cellHandle )
      throws AFSException;
  
    /**
***************
*** 1426,1432 ****
     * @return an iteration ID
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getKasUsersBegin( int cellHandle )
      throws AFSException;
  
    /**
--- 1415,1421 ----
     * @return an iteration ID
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native long getKasUsersBegin( long cellHandle )
      throws AFSException;
  
    /**
***************
*** 1442,1448 ****
     * @exception AFSException  If an error occurs in the native code
     * @see Cell#getCellHandle
     */
!   protected static native int getKasUsersBeginAt( int cellHandle,
                                                    int startIndex )
      throws AFSException;
  
--- 1431,1437 ----
     * @exception AFSException  If an error occurs in the native code
     * @see Cell#getCellHandle
     */
!   protected static native long getKasUsersBeginAt( long cellHandle,
                                                    int startIndex )
      throws AFSException;
  
***************
*** 1456,1462 ****
     * @return the name of the next user of the cell
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native String getKasUsersNextString( int iterationId )
      throws AFSException;
  
    /**
--- 1445,1451 ----
     * @return the name of the next user of the cell
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native String getKasUsersNextString( long iterationId )
      throws AFSException;
  
    /**
***************
*** 1472,1479 ****
     * @return 0 if there are no more users, != 0 otherwise
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getKasUsersNext( int cellHandle,  
! 					       int iterationId, 
  					       User theUser )
      throws AFSException;
  
--- 1461,1468 ----
     * @return 0 if there are no more users, != 0 otherwise
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getKasUsersNext( long cellHandle,  
! 					       long iterationId, 
  					       User theUser )
      throws AFSException;
  
***************
*** 1484,1490 ****
     * @see Cell#getKasUsersBegin
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void getKasUsersDone( int iterationId )
      throws AFSException;
  
    /**
--- 1473,1479 ----
     * @see Cell#getKasUsersBegin
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void getKasUsersDone( long iterationId )
      throws AFSException;
  
    /**
***************
*** 1496,1502 ****
     * @exception AFSException  If an error occurs in the native code
     * @see Cell#getCellHandle
     */
!   protected static native int getPtsUserCount( int cellHandle )
      throws AFSException;
  
    /**
--- 1485,1491 ----
     * @exception AFSException  If an error occurs in the native code
     * @see Cell#getCellHandle
     */
!   protected static native int getPtsUserCount( long cellHandle )
      throws AFSException;
  
    /**
***************
*** 1508,1514 ****
     * @exception AFSException  If an error occurs in the native code
     * @see Cell#getCellHandle
     */
!   protected static native int getPtsOnlyUserCount( int cellHandle )
      throws AFSException;
  
    /**
--- 1497,1503 ----
     * @exception AFSException  If an error occurs in the native code
     * @see Cell#getCellHandle
     */
!   protected static native int getPtsOnlyUserCount( long cellHandle )
      throws AFSException;
  
    /**
***************
*** 1522,1528 ****
     * @return an iteration ID
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getPtsUsersBegin( int cellHandle )
      throws AFSException;
  
    /**
--- 1511,1517 ----
     * @return an iteration ID
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native long getPtsUsersBegin( long cellHandle )
      throws AFSException;
  
    /**
***************
*** 1534,1540 ****
     * @return the name of the next user of the cell
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native String getPtsUsersNextString( int iterationId )
      throws AFSException;
  
    /**
--- 1523,1529 ----
     * @return the name of the next user of the cell
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native String getPtsUsersNextString( long iterationId )
      throws AFSException;
  
    /**
***************
*** 1547,1554 ****
     * @return the name of the next pts user (not kas user) of the cell
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native String getPtsOnlyUsersNextString( int iterationId, 
! 							    int cellHandle )
      throws AFSException;
  
    /**
--- 1536,1543 ----
     * @return the name of the next pts user (not kas user) of the cell
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native String getPtsOnlyUsersNextString( long iterationId, 
! 							    long cellHandle )
      throws AFSException;
  
    /**
***************
*** 1564,1570 ****
     * @return 0 if there are no more users, != 0 otherwise
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getPtsUsersNext( int cellHandle, int iterationId,
  					       User theUser )
      throws AFSException;
  
--- 1553,1559 ----
     * @return 0 if there are no more users, != 0 otherwise
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getPtsUsersNext( long cellHandle, long iterationId,
  					       User theUser )
      throws AFSException;
  
***************
*** 1581,1588 ****
     * @return 0 if there are no more users, != 0 otherwise
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getPtsOnlyUsersNext( int cellHandle, 
! 						   int iterationId, 
  						   User theUser )
      throws AFSException;
  
--- 1570,1577 ----
     * @return 0 if there are no more users, != 0 otherwise
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getPtsOnlyUsersNext( long cellHandle, 
! 						   long iterationId, 
  						   User theUser )
      throws AFSException;
  
***************
*** 1593,1599 ****
     * @see Cell#getPtsUsersBegin
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void getPtsUsersDone( int iterationId )
      throws AFSException;
  
    /**
--- 1582,1588 ----
     * @see Cell#getPtsUsersBegin
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void getPtsUsersDone( long iterationId )
      throws AFSException;
  
    /**
***************
*** 1605,1611 ****
     * @exception AFSException  If an error occurs in the native code
     * @see Cell#getCellHandle
     */
!   protected static native int getGroupCount( int cellHandle )
      throws AFSException;
  
    /**
--- 1594,1600 ----
     * @exception AFSException  If an error occurs in the native code
     * @see Cell#getCellHandle
     */
!   protected static native int getGroupCount( long cellHandle )
      throws AFSException;
  
    /**
***************
*** 1619,1625 ****
     * @return an iteration ID
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getGroupsBegin( int cellHandle )
      throws AFSException;
  
    /**
--- 1608,1614 ----
     * @return an iteration ID
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native long getGroupsBegin( long cellHandle )
      throws AFSException;
  
    /**
***************
*** 1634,1640 ****
     * @exception AFSException  If an error occurs in the native code
     * @see Cell#getCellHandle
     */
!   protected static native int getGroupsBeginAt( int cellHandle, 
                                                  int startIndex )
      throws AFSException;
  
--- 1623,1629 ----
     * @exception AFSException  If an error occurs in the native code
     * @see Cell#getCellHandle
     */
!   protected static native long getGroupsBeginAt( long cellHandle, 
                                                  int startIndex )
      throws AFSException;
  
***************
*** 1647,1653 ****
     * @return the name of the next user of the cell
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native String getGroupsNextString( int iterationId )
      throws AFSException;
  
    /**
--- 1636,1642 ----
     * @return the name of the next user of the cell
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native String getGroupsNextString( long iterationId )
      throws AFSException;
  
    /**
***************
*** 1663,1669 ****
     * @return 0 if there are no more users, != 0 otherwise
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getGroupsNext( int cellHandle, int iterationId, 
  					     Group theGroup )
      throws AFSException;
  
--- 1652,1658 ----
     * @return 0 if there are no more users, != 0 otherwise
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getGroupsNext( long cellHandle, long iterationId, 
  					     Group theGroup )
      throws AFSException;
  
***************
*** 1674,1680 ****
     * @see Cell#getGroupsBegin
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void getGroupsDone( int iterationId )
      throws AFSException;
  
    /**
--- 1663,1669 ----
     * @see Cell#getGroupsBegin
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void getGroupsDone( long iterationId )
      throws AFSException;
  
    /**
***************
*** 1686,1692 ****
     * @exception AFSException  If an error occurs in the native code
     * @see Cell#getCellHandle
     */
!   protected static native int getServerCount( int cellHandle )
      throws AFSException;
  
    /**
--- 1675,1681 ----
     * @exception AFSException  If an error occurs in the native code
     * @see Cell#getCellHandle
     */
!   protected static native int getServerCount( long cellHandle )
      throws AFSException;
  
    /**
***************
*** 1699,1705 ****
     * @return an iteration ID
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getServersBegin( int cellHandle )
      throws AFSException;
  
    /**
--- 1688,1694 ----
     * @return an iteration ID
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native long getServersBegin( long cellHandle )
      throws AFSException;
  
    /**
***************
*** 1711,1717 ****
     * @return the name of the next server of the cell
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native String getServersNextString( int iterationId )
      throws AFSException;
  
    /**
--- 1700,1706 ----
     * @return the name of the next server of the cell
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native String getServersNextString( long iterationId )
      throws AFSException;
  
    /**
***************
*** 1727,1733 ****
     * @return 0 if there are no more servers, != 0 otherwise
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getServersNext( int cellHandle, int iterationId, 
  					      Server theServer )
      throws AFSException;
  
--- 1716,1722 ----
     * @return 0 if there are no more servers, != 0 otherwise
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getServersNext( long cellHandle, long iterationId, 
  					      Server theServer )
      throws AFSException;
  
***************
*** 1738,1744 ****
     * @see Cell#getServersBegin
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void getServersDone( int iterationId )
      throws AFSException;
  
    /**
--- 1727,1733 ----
     * @see Cell#getServersBegin
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void getServersDone( long iterationId )
      throws AFSException;
  
    /**
***************
*** 1749,1755 ****
     * @return the name of the cell
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native String getCellName( int cellHandle )
      throws AFSException;
  
    /**
--- 1738,1744 ----
     * @return the name of the cell
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native String getCellName( long cellHandle )
      throws AFSException;
  
    /**
***************
*** 1764,1770 ****
     * @param forceCheck  whether or not to check if this volume name exists
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void createMountPoint( int cellHandle, 
  						 String directory, 
  						 String volumeName, 
  						 boolean readWrite, 
--- 1753,1759 ----
     * @param forceCheck  whether or not to check if this volume name exists
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void createMountPoint( long cellHandle, 
  						 String directory, 
  						 String volumeName, 
  						 boolean readWrite, 
***************
*** 1803,1809 ****
     * @return an integer reresenting the max group id in a cell
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getMaxGroupID( int cellHandle )
      throws AFSException;
  
    /**
--- 1792,1798 ----
     * @return an integer reresenting the max group id in a cell
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getMaxGroupID( long cellHandle )
      throws AFSException;
  
    /**
***************
*** 1815,1821 ****
     * @param maxID an integer reresenting the new max group id in a cell
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void setMaxGroupID( int cellHandle, int maxID )
      throws AFSException;
  
    /**
--- 1804,1810 ----
     * @param maxID an integer reresenting the new max group id in a cell
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void setMaxGroupID( long cellHandle, int maxID )
      throws AFSException;
  
    /**
***************
*** 1828,1834 ****
     * @return an integer reresenting the max user id in a cell
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getMaxUserID( int cellHandle )
      throws AFSException;
  
    /**
--- 1817,1823 ----
     * @return an integer reresenting the max user id in a cell
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getMaxUserID( long cellHandle )
      throws AFSException;
  
    /**
***************
*** 1840,1846 ****
     * @param maxID an integer reresenting the new max user id in a cell
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void setMaxUserID( int cellHandle, int maxID )
      throws AFSException;
  
    /**
--- 1829,1835 ----
     * @param maxID an integer reresenting the new max user id in a cell
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void setMaxUserID( long cellHandle, int maxID )
      throws AFSException;
  
    /**
***************
*** 1865,1871 ****
     * @exception AFSException  If an error occurs in the native code
     * @see Token#getHandle
     */
!   protected static native int getCellHandle( String cellName, int tokenHandle )
  	throws AFSException;
   
    /**
--- 1854,1860 ----
     * @exception AFSException  If an error occurs in the native code
     * @see Token#getHandle
     */
!   protected static native long getCellHandle( String cellName, long tokenHandle )
  	throws AFSException;
   
    /**
***************
*** 1874,1879 ****
     * @param cellHandle   the cell handle to close
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void closeCell( int cellHandle ) 
  	throws AFSException;
  }
--- 1863,1876 ----
     * @param cellHandle   the cell handle to close
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void closeCell( long cellHandle ) 
  	throws AFSException;
  }
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
Index: openafs/src/JAVA/classes/org/openafs/jafs/Group.java
diff -c openafs/src/JAVA/classes/org/openafs/jafs/Group.java:1.2 openafs/src/JAVA/classes/org/openafs/jafs/Group.java:1.2.2.1
*** openafs/src/JAVA/classes/org/openafs/jafs/Group.java:1.2	Thu Jun 19 12:53:14 2003
--- openafs/src/JAVA/classes/org/openafs/jafs/Group.java	Fri Oct 14 22:14:10 2005
***************
*** 111,117 ****
    public static final int GROUP_ANYUSER_ACCESS = 2;
  
    protected Cell cell;
!   protected int cellHandle;
    protected String name;
    
    protected int membershipCount;
--- 111,117 ----
    public static final int GROUP_ANYUSER_ACCESS = 2;
  
    protected Cell cell;
!   protected long cellHandle;
    protected String name;
    
    protected int membershipCount;
***************
*** 487,493 ****
    {
      User currUser;
  
!     int iterationID = Group.getGroupMembersBegin( cell.getCellHandle(), name );
  
      members = new ArrayList();
  
--- 487,493 ----
    {
      User currUser;
  
!     long iterationID = Group.getGroupMembersBegin( cell.getCellHandle(), name );
  
      members = new ArrayList();
  
***************
*** 511,517 ****
    protected void refreshMemberNames() throws AFSException
    {
      String currName;
!     int iterationID = Group.getGroupMembersBegin( cell.getCellHandle(), name );
  
      memberNames = new ArrayList();
  
--- 511,517 ----
    protected void refreshMemberNames() throws AFSException
    {
      String currName;
!     long iterationID = Group.getGroupMembersBegin( cell.getCellHandle(), name );
  
      memberNames = new ArrayList();
  
***************
*** 533,539 ****
    {
      Group currGroup;
  
!     int iterationID = User.getGroupsOwnedBegin( cell.getCellHandle(), name );
  
      groupsOwned = new ArrayList();
  
--- 533,539 ----
    {
      Group currGroup;
  
!     long iterationID = User.getGroupsOwnedBegin( cell.getCellHandle(), name );
  
      groupsOwned = new ArrayList();
  
***************
*** 557,563 ****
    {
      String currName;
  
!     int iterationID = User.getGroupsOwnedBegin( cell.getCellHandle(), name );
  
      groupsOwnedNames = new ArrayList();
      while( ( currName = User.getGroupsOwnedNextString( iterationID ) ) 
--- 557,563 ----
    {
      String currName;
  
!     long iterationID = User.getGroupsOwnedBegin( cell.getCellHandle(), name );
  
      groupsOwnedNames = new ArrayList();
      while( ( currName = User.getGroupsOwnedNextString( iterationID ) ) 
***************
*** 1010,1016 ****
     *
     * @return a <code>String</code> representation of the <code>Group</code>
     */
!   protected String getInfo()
    {
      String r;
      try {
--- 1010,1016 ----
     *
     * @return a <code>String</code> representation of the <code>Group</code>
     */
!   public String getInfo()
    {
      String r;
      try {
***************
*** 1108,1114 ****
     *                automatically assigned)
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void create( int cellHandle, String groupName, 
  				       String ownerName, int gid )
  	throws AFSException;
  
--- 1108,1114 ----
     *                automatically assigned)
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void create( long cellHandle, String groupName, 
  				       String ownerName, int gid )
  	throws AFSException;
  
***************
*** 1122,1128 ****
     * @param groupName      the name of the group to delete
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void delete( int cellHandle, String groupName )
  	throws AFSException;
  
    /**
--- 1122,1128 ----
     * @param groupName      the name of the group to delete
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void delete( long cellHandle, String groupName )
  	throws AFSException;
  
    /**
***************
*** 1137,1143 ****
     * @see Group
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void getGroupInfo( int cellHandle, String name, 
  					     Group group ) 
  	throws AFSException;
  
--- 1137,1143 ----
     * @see Group
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void getGroupInfo( long cellHandle, String name, 
  					     Group group ) 
  	throws AFSException;
  
***************
*** 1150,1156 ****
     * @param theGroup   the group object containing the desired information
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void setGroupInfo( int cellHandle, String name, 
  					     Group theGroup ) 
  	throws AFSException;
  
--- 1150,1156 ----
     * @param theGroup   the group object containing the desired information
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void setGroupInfo( long cellHandle, String name, 
  					     Group theGroup ) 
  	throws AFSException;
  
***************
*** 1165,1171 ****
     * @return an iteration ID
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native int getGroupMembersBegin( int cellHandle, 
  						    String name )
  	throws AFSException;
  
--- 1165,1171 ----
     * @return an iteration ID
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native long getGroupMembersBegin( long cellHandle, 
  						    String name )
  	throws AFSException;
  
***************
*** 1174,1184 ****
     * <code>null</code> if there are no more members.
     *
     * @param iterationId   the iteration ID of this iteration
!    * @see #getGroupMembersBegin
     * @return the name of the next member
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native String getGroupMembersNextString( int iterationId ) 
  	throws AFSException;
  
    /**
--- 1174,1184 ----
     * <code>null</code> if there are no more members.
     *
     * @param iterationId   the iteration ID of this iteration
!    * @see getGroupMembersBegin
     * @return the name of the next member
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native String getGroupMembersNextString( long iterationId ) 
  	throws AFSException;
  
    /**
***************
*** 1188,1201 ****
     * @param cellHandle    the handle of the cell to which the users belong
     * @see Cell#getCellHandle
     * @param iterationId   the iteration ID of this iteration
!    * @see #getGroupMembersBegin
     * @param theUser   a User object to be populated with the values of the 
     *                  next user
     * @return 0 if there are no more users, != 0 otherwise
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getGroupMembersNext( int cellHandle, 
! 						   int iterationId, 
  						   User theUser )
      throws AFSException;
  
--- 1188,1201 ----
     * @param cellHandle    the handle of the cell to which the users belong
     * @see Cell#getCellHandle
     * @param iterationId   the iteration ID of this iteration
!    * @see getGroupMembersBegin
     * @param theUser   a User object to be populated with the values of the 
     *                  next user
     * @return 0 if there are no more users, != 0 otherwise
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getGroupMembersNext( long cellHandle, 
! 						   long iterationId, 
  						   User theUser )
      throws AFSException;
  
***************
*** 1203,1212 ****
     * Signals that the iteration is complete and will not be accessed anymore.
     *
     * @param iterationId   the iteration ID of this iteration
!    * @see #getGroupMembersBegin
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void getGroupMembersDone( int iterationId )
  	throws AFSException;
  
    /**
--- 1203,1212 ----
     * Signals that the iteration is complete and will not be accessed anymore.
     *
     * @param iterationId   the iteration ID of this iteration
!    * @see getGroupMembersBegin
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void getGroupMembersDone( long iterationId )
  	throws AFSException;
  
    /**
***************
*** 1218,1224 ****
     * @param userName      the name of the user to add
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void addMember( int cellHandle, String groupName, 
  					  String userName )
  	throws AFSException;
  
--- 1218,1224 ----
     * @param userName      the name of the user to add
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void addMember( long cellHandle, String groupName, 
  					  String userName )
  	throws AFSException;
  
***************
*** 1232,1238 ****
     * @param userName      the name of the user to remove
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void removeMember( int cellHandle, String groupName, 
  					     String userName )
  	throws AFSException;
  
--- 1232,1238 ----
     * @param userName      the name of the user to remove
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void removeMember( long cellHandle, String groupName, 
  					     String userName )
  	throws AFSException;
  
***************
*** 1246,1252 ****
     * @param ownerName      the name of the new owner
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void changeOwner( int cellHandle, String groupName, 
  					    String ownerName )
  	throws AFSException;
  
--- 1246,1252 ----
     * @param ownerName      the name of the new owner
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void changeOwner( long cellHandle, String groupName, 
  					    String ownerName )
  	throws AFSException;
  
***************
*** 1259,1265 ****
     * @param newGroupName      the new name for the group
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void rename( int cellHandle, String oldGroupName, 
  				       String newGroupName )
  	throws AFSException;
  
--- 1259,1265 ----
     * @param newGroupName      the new name for the group
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void rename( long cellHandle, String oldGroupName, 
  				       String newGroupName )
  	throws AFSException;
  
Index: openafs/src/JAVA/classes/org/openafs/jafs/Key.java
diff -c openafs/src/JAVA/classes/org/openafs/jafs/Key.java:1.2 openafs/src/JAVA/classes/org/openafs/jafs/Key.java:1.2.2.1
*** openafs/src/JAVA/classes/org/openafs/jafs/Key.java:1.2	Thu Jun 19 12:53:14 2003
--- openafs/src/JAVA/classes/org/openafs/jafs/Key.java	Fri Oct 14 22:14:10 2005
***************
*** 329,335 ****
     *
     * @return a <code>String</code> representation of the <code>Key</code>
     */
!   protected String getInfo()
    {
      String r;
      try {
--- 329,335 ----
     *
     * @return a <code>String</code> representation of the <code>Key</code>
     */
!   public String getInfo()
    {
      String r;
      try {
***************
*** 417,423 ****
     * @see Server
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void getKeyInfo( int serverHandle, int version, 
  					   Key key ) 
  	throws AFSException;
  
--- 417,423 ----
     * @see Server
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void getKeyInfo( long serverHandle, int version, 
  					   Key key ) 
  	throws AFSException;
  
***************
*** 434,440 ****
     *                      be encrypted
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void create( int cellHandle, int serverHandle, int versionNumber, String keyString )
      throws AFSException;
  
    /**
--- 434,440 ----
     *                      be encrypted
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void create( long cellHandle, long serverHandle, int versionNumber, String keyString )
      throws AFSException;
  
    /**
***************
*** 445,451 ****
     * @param versionNumber   the version number of the key to remove (0 to 255)
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void delete( int serverHandle, int versionNumber )
      throws AFSException;
  
    /**
--- 445,451 ----
     * @param versionNumber   the version number of the key to remove (0 to 255)
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void delete( long serverHandle, int versionNumber )
      throws AFSException;
  
    /**
***************
*** 457,459 ****
--- 457,467 ----
    protected static native void reclaimKeyMemory();
  
  }
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
Index: openafs/src/JAVA/classes/org/openafs/jafs/Partition.java
diff -c openafs/src/JAVA/classes/org/openafs/jafs/Partition.java:1.2 openafs/src/JAVA/classes/org/openafs/jafs/Partition.java:1.2.2.1
*** openafs/src/JAVA/classes/org/openafs/jafs/Partition.java:1.2	Thu Jun 19 12:53:14 2003
--- openafs/src/JAVA/classes/org/openafs/jafs/Partition.java	Fri Oct 14 22:14:10 2005
***************
*** 266,272 ****
    {
      Volume currVolume;
  
!     int iterationID = getVolumesBegin( cell.getCellHandle(), 
  				       server.getVosHandle(), getID() );
  
      volumes = new ArrayList();
--- 266,272 ----
    {
      Volume currVolume;
  
!     long iterationID = getVolumesBegin( cell.getCellHandle(), 
  				       server.getVosHandle(), getID() );
  
      volumes = new ArrayList();
***************
*** 288,294 ****
    {
      String currName;
  
!     int iterationID = getVolumesBegin( cell.getCellHandle(), 
  				       server.getVosHandle(), getID() );
  	
      volumeNames = new ArrayList();
--- 288,294 ----
    {
      String currName;
  
!     long iterationID = getVolumesBegin( cell.getCellHandle(), 
  				       server.getVosHandle(), getID() );
  	
      volumeNames = new ArrayList();
***************
*** 486,492 ****
      Volume currVolume = new Volume( this );
      int i = 0;
  
!     int iterationID = getVolumesBeginAt( cell.getCellHandle(), 
  				       server.getVosHandle(), getID(), startIndex );
  
      while( getVolumesNext( iterationID, currVolume ) != 0 && i < length ) {
--- 486,492 ----
      Volume currVolume = new Volume( this );
      int i = 0;
  
!     long iterationID = getVolumesBeginAt( cell.getCellHandle(), 
  				       server.getVosHandle(), getID(), startIndex );
  
      while( getVolumesNext( iterationID, currVolume ) != 0 && i < length ) {
***************
*** 583,589 ****
      String currName;
      int i = 0;
  
!     int iterationID = getVolumesBeginAt( cell.getCellHandle(), 
  				       server.getVosHandle(), getID(), startIndex );
  
      while( ( currName = getVolumesNextString( iterationID ) ) != null && i < length ) {
--- 583,589 ----
      String currName;
      int i = 0;
  
!     long iterationID = getVolumesBeginAt( cell.getCellHandle(), 
  				       server.getVosHandle(), getID(), startIndex );
  
      while( ( currName = getVolumesNextString( iterationID ) ) != null && i < length ) {
***************
*** 778,784 ****
     *
     * @return a <code>String</code> representation of the <code>Partition</code>
     */
!   protected String getInfo()
    {
      String r;
      
--- 778,784 ----
     *
     * @return a <code>String</code> representation of the <code>Partition</code>
     */
!   public String getInfo()
    {
      String r;
      
***************
*** 812,818 ****
     * @return    a <code>String</code> representation of the volumes
     * @see       Volume#getInfo
     */
!   protected String getInfoVolumes() throws AFSException
    {
  	String r;
  
--- 812,818 ----
     * @return    a <code>String</code> representation of the volumes
     * @see       Volume#getInfo
     */
!   public String getInfoVolumes() throws AFSException
    {
  	String r;
  
***************
*** 896,903 ****
     *                       fill in the information
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void getPartitionInfo( int cellHandle, 
! 						 int serverHandle, 
  						 int partition, 
  						 Partition thePartition ) 
      throws AFSException;
--- 896,903 ----
     *                       fill in the information
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void getPartitionInfo( long cellHandle, 
! 						 long serverHandle, 
  						 int partition, 
  						 Partition thePartition ) 
      throws AFSException;
***************
*** 915,922 ****
     * @see Cell#getCellHandle
     * @see Server#getVosServerHandle
     */
!   protected static native int getVolumeCount( int cellHandle, 
! 					       int serverHandle, 
  					       int partition )
      throws AFSException;
  
--- 915,922 ----
     * @see Cell#getCellHandle
     * @see Server#getVosServerHandle
     */
!   protected static native int getVolumeCount( long cellHandle, 
! 					       long serverHandle, 
  					       int partition )
      throws AFSException;
  
***************
*** 935,942 ****
     * @return an iteration ID
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getVolumesBegin( int cellHandle, 
! 					       int serverHandle, 
  					       int partition )
      throws AFSException;
  
--- 935,942 ----
     * @return an iteration ID
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native long getVolumesBegin( long cellHandle, 
! 					       long serverHandle, 
  					       int partition )
      throws AFSException;
  
***************
*** 955,962 ****
     * @return an iteration ID
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getVolumesBeginAt( int cellHandle, 
! 						 int serverHandle, 
  						 int partition, int index )
      throws AFSException;
  
--- 955,962 ----
     * @return an iteration ID
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native long getVolumesBeginAt( long cellHandle, 
! 						 long serverHandle, 
  						 int partition, int index )
      throws AFSException;
  
***************
*** 969,975 ****
     * @return the name of the next volume of the server
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native String getVolumesNextString( int iterationId )
      throws AFSException;
  
    /**
--- 969,975 ----
     * @return the name of the next volume of the server
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native String getVolumesNextString( long iterationId )
      throws AFSException;
  
    /**
***************
*** 983,989 ****
     * @return 0 if there are no more volumes, != 0 otherwise
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getVolumesNext( int iterationId, 
  					      Volume theVolume )
      throws AFSException;
  
--- 983,989 ----
     * @return 0 if there are no more volumes, != 0 otherwise
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getVolumesNext( long iterationId, 
  					      Volume theVolume )
      throws AFSException;
  
***************
*** 998,1004 ****
     * @return 0 if there are no more volumes, != 0 otherwise
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getVolumesAdvanceTo( int iterationId, 
  						   Volume theVolume, 
  						   int advanceCount )
      throws AFSException;
--- 998,1004 ----
     * @return 0 if there are no more volumes, != 0 otherwise
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getVolumesAdvanceTo( long iterationId, 
  						   Volume theVolume, 
  						   int advanceCount )
      throws AFSException;
***************
*** 1010,1016 ****
     * @see #getVolumesBegin
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void getVolumesDone( int iterationId )
      throws AFSException;
  
    /**
--- 1010,1016 ----
     * @see #getVolumesBegin
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void getVolumesDone( long iterationId )
      throws AFSException;
  
    /**
***************
*** 1041,1043 ****
--- 1041,1052 ----
     */
    protected static native void reclaimPartitionMemory();
  }
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
Index: openafs/src/JAVA/classes/org/openafs/jafs/Process.java
diff -c openafs/src/JAVA/classes/org/openafs/jafs/Process.java:1.1 openafs/src/JAVA/classes/org/openafs/jafs/Process.java:1.1.8.1
*** openafs/src/JAVA/classes/org/openafs/jafs/Process.java:1.1	Fri Jul 26 01:34:06 2002
--- openafs/src/JAVA/classes/org/openafs/jafs/Process.java	Fri Oct 14 22:14:10 2005
***************
*** 128,134 ****
  
    protected String name;
    protected Server server;
!   protected int serverHandle;
  
    protected int type;
    protected int state;
--- 128,134 ----
  
    protected String name;
    protected Server server;
!   protected long serverHandle;
  
    protected int type;
    protected int state;
***************
*** 687,693 ****
     *
     * @return a <code>String</code> representation of the <code>Process</code>
     */
!   protected String getInfo()
    {
      String r;
      try {
--- 687,693 ----
     *
     * @return a <code>String</code> representation of the <code>Process</code>
     */
!   public String getInfo()
    {
      String r;
      try {
***************
*** 853,859 ****
     *                       in the information
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void getProcessInfo( int cellHandle, 
  					       String processName, 
  					       Process theProcess ) 
  	throws AFSException;
--- 853,859 ----
     *                       in the information
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void getProcessInfo( long cellHandle, 
  					       String processName, 
  					       Process theProcess ) 
  	throws AFSException;
***************
*** 884,890 ****
     *                   <code>null</code>
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void create( int serverHandle, String processName, 
  				       int processType, String executionPath, 
  				       String cronTime, String notifier )
      throws AFSException;
--- 884,890 ----
     *                   <code>null</code>
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void create( long serverHandle, String processName, 
  				       int processType, String executionPath, 
  				       String cronTime, String notifier )
      throws AFSException;
***************
*** 898,904 ****
     * @param processName   the name of the process to remove
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void delete( int serverHandle, String processName )
      throws AFSException;
  
    /**
--- 898,904 ----
     * @param processName   the name of the process to remove
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void delete( long serverHandle, String processName )
      throws AFSException;
  
    /**
***************
*** 910,916 ****
     * @param processName   the name of the process to start
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void start( int serverHandle, String processName )
      throws AFSException;
  
    /**
--- 910,916 ----
     * @param processName   the name of the process to start
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void start( long serverHandle, String processName )
      throws AFSException;
  
    /**
***************
*** 922,928 ****
     * @param processName   the name of the process to restart
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void restart( int serverHandle, String processName )
      throws AFSException;
  
    /**
--- 922,928 ----
     * @param processName   the name of the process to restart
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void restart( long serverHandle, String processName )
      throws AFSException;
  
    /**
***************
*** 934,940 ****
     * @param processName   the name of the process to stop
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void stop( int serverHandle, String processName )
      throws AFSException;
  
    /**
--- 934,940 ----
     * @param processName   the name of the process to stop
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void stop( long serverHandle, String processName )
      throws AFSException;
  
    /**
Index: openafs/src/JAVA/classes/org/openafs/jafs/Server.java
diff -c openafs/src/JAVA/classes/org/openafs/jafs/Server.java:1.2 openafs/src/JAVA/classes/org/openafs/jafs/Server.java:1.2.2.1
*** openafs/src/JAVA/classes/org/openafs/jafs/Server.java:1.2	Thu Jun 19 12:53:14 2003
--- openafs/src/JAVA/classes/org/openafs/jafs/Server.java	Fri Oct 14 22:14:10 2005
***************
*** 108,115 ****
    protected String name;
    protected Cell cell;
  
!   protected int vosHandle;
!   protected int bosHandle;
  
    protected boolean database;
    protected boolean fileServer;
--- 108,115 ----
    protected String name;
    protected Cell cell;
  
!   protected long vosHandle;
!   protected long bosHandle;
  
    protected boolean database;
    protected boolean fileServer;
***************
*** 353,359 ****
  
      Partition currPartition;
  
!     int iterationID = getPartitionsBegin( cell.getCellHandle(), 
  					  getVosHandle() );
      
      partitions = new ArrayList();
--- 353,359 ----
  
      Partition currPartition;
  
!     long iterationID = getPartitionsBegin( cell.getCellHandle(), 
  					  getVosHandle() );
      
      partitions = new ArrayList();
***************
*** 384,390 ****
  
      String currName;
  
!     int iterationID = getPartitionsBegin( cell.getCellHandle(), 
  					  getVosHandle() );
      
      partitionNames = new ArrayList();
--- 384,390 ----
  
      String currName;
  
!     long iterationID = getPartitionsBegin( cell.getCellHandle(), 
  					  getVosHandle() );
      
      partitionNames = new ArrayList();
***************
*** 404,410 ****
    {
      String currName;
  
!     int iterationID = getBosAdminsBegin( getBosHandle() );
      
      adminNames = new ArrayList();
      
--- 404,410 ----
    {
      String currName;
  
!     long iterationID = getBosAdminsBegin( getBosHandle() );
      
      adminNames = new ArrayList();
      
***************
*** 424,430 ****
    {
      User currUser;
  
!     int iterationID = getBosAdminsBegin( getBosHandle() );
  	
      admins = new ArrayList();
  	
--- 424,430 ----
    {
      User currUser;
  
!     long iterationID = getBosAdminsBegin( getBosHandle() );
  	
      admins = new ArrayList();
  	
***************
*** 446,452 ****
    {
      Key currKey;
  
!     int iterationID = getKeysBegin( getBosHandle() );
      
      keys = new ArrayList();
      
--- 446,452 ----
    {
      Key currKey;
  
!     long iterationID = getKeysBegin( getBosHandle() );
      
      keys = new ArrayList();
      
***************
*** 467,473 ****
    {
      String currName;
  
!     int iterationID = getProcessesBegin( getBosHandle() );
      
      processNames = new ArrayList();
      
--- 467,473 ----
    {
      String currName;
  
!     long iterationID = getProcessesBegin( getBosHandle() );
      
      processNames = new ArrayList();
      
***************
*** 487,493 ****
    {
      Process currProcess;
  
!     int iterationID = getProcessesBegin( getBosHandle() );
      
      processes = new ArrayList();
      
--- 487,493 ----
    {
      Process currProcess;
  
!     long iterationID = getProcessesBegin( getBosHandle() );
      
      processes = new ArrayList();
      
***************
*** 814,821 ****
    public Partition[] getPartitions() throws AFSException
    {
      if ( partitions == null ) refreshPartitions();
!     return (Partition []) 
! 	partitions.toArray( new Partition[partitions.size()] );
    }
  
    /**
--- 814,824 ----
    public Partition[] getPartitions() throws AFSException
    {
      if ( partitions == null ) refreshPartitions();
!     if ( partitions != null) {
!     	return (Partition []) partitions.toArray( new Partition[partitions.size()] );
!     } else {
!     	return null;
!     }
    }
  
    /**
***************
*** 977,983 ****
    public Process[] getProcesses() throws AFSException
    {
      if ( processes == null ) refreshProcesses();
!     return (Process[]) processes.toArray( new Process[processes.size()] );
    }
  
    /**
--- 980,989 ----
    public Process[] getProcesses() throws AFSException
    {
      if ( processes == null ) refreshProcesses();
!     if ( processes != null) {
!     	return (Process[]) processes.toArray( new Process[processes.size()] );
!     }
!     return null;
    }
  
    /**
***************
*** 1197,1203 ****
     * @return this server's vos handle
     * @exception AFSException  If an error occurs in the native code
     */
!   protected int getVosHandle() throws AFSException
    {
      if ( vosHandle == 0 ) {
        vosHandle = getVosServerHandle( cell.getCellHandle(), name );
--- 1203,1209 ----
     * @return this server's vos handle
     * @exception AFSException  If an error occurs in the native code
     */
!   protected long getVosHandle() throws AFSException
    {
      if ( vosHandle == 0 ) {
        vosHandle = getVosServerHandle( cell.getCellHandle(), name );
***************
*** 1211,1217 ****
     * @return this server's bos handle
     * @exception AFSException  If an error occurs in the native code
     */
!   protected int getBosHandle() throws AFSException
    {
      if ( bosHandle == 0 ) {
        bosHandle = getBosServerHandle( cell.getCellHandle(), name );
--- 1217,1223 ----
     * @return this server's bos handle
     * @exception AFSException  If an error occurs in the native code
     */
!   protected long getBosHandle() throws AFSException
    {
      if ( bosHandle == 0 ) {
        bosHandle = getBosServerHandle( cell.getCellHandle(), name );
***************
*** 1260,1266 ****
     *
     * @return a <code>String</code> representation of the <code>Server</code>
     */
!   protected String getInfo()
    {
      String r;
      try {
--- 1266,1272 ----
     *
     * @return a <code>String</code> representation of the <code>Server</code>
     */
!   public String getInfo()
    {
      String r;
      try {
***************
*** 1322,1328 ****
     * @return    a <code>String</code> representation of the partitions
     * @see       Partition#getInfo
     */
!   protected String getInfoPartitions() throws AFSException
    {
      String r;
      r = "Server: " + name + "\n\n";
--- 1328,1334 ----
     * @return    a <code>String</code> representation of the partitions
     * @see       Partition#getInfo
     */
!   public String getInfoPartitions() throws AFSException
    {
      String r;
      r = "Server: " + name + "\n\n";
***************
*** 1343,1349 ****
     * @return    a <code>String</code> representation of the keys
     * @see       Key#getInfo
     */
!   protected String getInfoKeys() throws AFSException
    {
      String r;
  
--- 1349,1355 ----
     * @return    a <code>String</code> representation of the keys
     * @see       Key#getInfo
     */
!   public String getInfoKeys() throws AFSException
    {
      String r;
  
***************
*** 1366,1372 ****
     * @return    a <code>String</code> representation of the processes
     * @see       Process#getInfo
     */
!   protected String getInfoProcesses() throws AFSException
    {
      String r;
  
--- 1372,1378 ----
     * @return    a <code>String</code> representation of the processes
     * @see       Process#getInfo
     */
!   public String getInfoProcesses() throws AFSException
    {
      String r;
  
***************
*** 1443,1456 ****
     * methods as a means of identification.
     *
     * @param cellHandle    a cell handle previously returned by 
!    *                      a call to {@link Cell#getCellHandle}
     * @param serverName    the name of the server for which to retrieve 
     *                      a vos handle
     * @return a vos handle to the server
     * @exception AFSException  If an error occurs in the native code
!    * @see Cell#getCellHandle
     */
!   protected static native int getVosServerHandle( int cellHandle, 
  						  String serverName )
  	throws AFSException;
  
--- 1449,1462 ----
     * methods as a means of identification.
     *
     * @param cellHandle    a cell handle previously returned by 
!    *                      a call to {@link #getCellHandle}
     * @param serverName    the name of the server for which to retrieve 
     *                      a vos handle
     * @return a vos handle to the server
     * @exception AFSException  If an error occurs in the native code
!    * @see #getCellHandle
     */
!   protected static native long getVosServerHandle( long cellHandle, 
  						  String serverName )
  	throws AFSException;
  
***************
*** 1460,1466 ****
     * @param vosHandle   the vos server handle to close
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void closeVosServerHandle( int vosHandle ) 
  	throws AFSException; 
  
    /**
--- 1466,1472 ----
     * @param vosHandle   the vos server handle to close
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void closeVosServerHandle( long vosHandle ) 
  	throws AFSException; 
  
    /**
***************
*** 1469,1482 ****
     * as a means of identification.
     *
     * @param cellHandle    a cell handle previously returned by a call 
!    *                      to {@link Cell#getCellHandle}
     * @param serverName    the name of the server for which to retrieve 
     *                      a bos handle
     * @return a bos handle to the server
     * @exception AFSException  If an error occurs in the native code
!    * @see Cell#getCellHandle
     */
!   protected static native int getBosServerHandle( int cellHandle, 
  						  String serverName )
  	throws AFSException;
  
--- 1475,1488 ----
     * as a means of identification.
     *
     * @param cellHandle    a cell handle previously returned by a call 
!    *                      to {@link #getCellHandle}
     * @param serverName    the name of the server for which to retrieve 
     *                      a bos handle
     * @return a bos handle to the server
     * @exception AFSException  If an error occurs in the native code
!    * @see #getCellHandle
     */
!   protected static native long getBosServerHandle( long cellHandle, 
  						  String serverName )
  	throws AFSException;
  
***************
*** 1486,1492 ****
     * @param bosHandle   the bos server handle to close
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void closeBosServerHandle( int bosHandle ) 
  	throws AFSException; 
  
    /**
--- 1492,1498 ----
     * @param bosHandle   the bos server handle to close
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void closeBosServerHandle( long bosHandle ) 
  	throws AFSException; 
  
    /**
***************
*** 1500,1506 ****
     * @see Server
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void getServerInfo( int cellHandle, String name, 
  					      Server server ) 
  	throws AFSException;
  
--- 1506,1512 ----
     * @see Server
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void getServerInfo( long cellHandle, String name, 
  					      Server server ) 
  	throws AFSException;
  
***************
*** 1516,1523 ****
     * @see Cell#getCellHandle
     * @see #getVosServerHandle
     */
!   protected static native int getPartitionCount( int cellHandle, 
! 						  int serverHandle )
      throws AFSException;
  
    /**
--- 1522,1529 ----
     * @see Cell#getCellHandle
     * @see #getVosServerHandle
     */
!   protected static native int getPartitionCount( long cellHandle, 
! 						  long serverHandle )
      throws AFSException;
  
    /**
***************
*** 1533,1540 ****
     * @return an iteration ID
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getPartitionsBegin( int cellHandle, 
! 						  int serverHandle )
      throws AFSException;
  
    /**
--- 1539,1546 ----
     * @return an iteration ID
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native long getPartitionsBegin( long cellHandle, 
! 						  long serverHandle )
      throws AFSException;
  
    /**
***************
*** 1546,1552 ****
     * @return the name of the next partition of the server
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native String getPartitionsNextString( int iterationId )
      throws AFSException;
  
    /**
--- 1552,1558 ----
     * @return the name of the next partition of the server
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native String getPartitionsNextString( long iterationId )
      throws AFSException;
  
    /**
***************
*** 1560,1566 ****
     * @return 0 if there are no more servers, != 0 otherwise
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getPartitionsNext( int iterationId, 
  						 Partition thePartition )
      throws AFSException;
  
--- 1566,1572 ----
     * @return 0 if there are no more servers, != 0 otherwise
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getPartitionsNext( long iterationId, 
  						 Partition thePartition )
      throws AFSException;
  
***************
*** 1571,1577 ****
     * @see #getPartitionsBegin
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void getPartitionsDone( int iterationId )
      throws AFSException;
    
    /**
--- 1577,1583 ----
     * @see #getPartitionsBegin
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void getPartitionsDone( long iterationId )
      throws AFSException;
    
    /**
***************
*** 1584,1590 ****
     * @exception AFSException  If an error occurs in the native code
     * @see #getVosServerHandle
     */
!   protected static native int getProcessCount( int serverHandle )
      throws AFSException;
  
    /**
--- 1590,1596 ----
     * @exception AFSException  If an error occurs in the native code
     * @see #getVosServerHandle
     */
!   protected static native int getProcessCount( long serverHandle )
      throws AFSException;
  
    /**
***************
*** 1598,1604 ****
     * @return an iteration ID
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getProcessesBegin( int serverHandle )
      throws AFSException;
  
    /**
--- 1604,1610 ----
     * @return an iteration ID
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native long getProcessesBegin( long serverHandle )
      throws AFSException;
  
    /**
***************
*** 1610,1616 ****
     * @return the name of the next process of the cell
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native String getProcessesNextString( int iterationId )
      throws AFSException;
  
    /**
--- 1616,1622 ----
     * @return the name of the next process of the cell
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native String getProcessesNextString( long iterationId )
      throws AFSException;
  
    /**
***************
*** 1626,1633 ****
     * @return 0 if there are no more processes, != otherwise
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getProcessesNext( int serverHandle, 
! 						int iterationId, 
  						Process theProcess )
      throws AFSException;
  
--- 1632,1639 ----
     * @return 0 if there are no more processes, != otherwise
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getProcessesNext( long serverHandle, 
! 						long iterationId, 
  						Process theProcess )
      throws AFSException;
  
***************
*** 1638,1644 ****
     * @see #getProcessesBegin
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void getProcessesDone( int iterationId )
      throws AFSException;
  
    /**
--- 1644,1650 ----
     * @see #getProcessesBegin
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void getProcessesDone( long iterationId )
      throws AFSException;
  
    /**
***************
*** 1651,1657 ****
     * @exception AFSException  If an error occurs in the native code
     * @see #getVosServerHandle
     */
!   protected static native int getKeyCount( int serverHandle )
      throws AFSException;
  
    /**
--- 1657,1663 ----
     * @exception AFSException  If an error occurs in the native code
     * @see #getVosServerHandle
     */
!   protected static native int getKeyCount( long serverHandle )
      throws AFSException;
  
    /**
***************
*** 1664,1670 ****
     * @return an iteration ID
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getKeysBegin( int serverHandle )
      throws AFSException;
  
    /**
--- 1670,1676 ----
     * @return an iteration ID
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native long getKeysBegin( long serverHandle )
      throws AFSException;
  
    /**
***************
*** 1678,1684 ****
     * @return 0 if there are no more keys, != 0 otherwise
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getKeysNext( int iterationId, Key theKey )
      throws AFSException;
  
    /**
--- 1684,1690 ----
     * @return 0 if there are no more keys, != 0 otherwise
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getKeysNext( long iterationId, Key theKey )
      throws AFSException;
  
    /**
***************
*** 1688,1694 ****
     * @see #getKeysBegin
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void getKeysDone( int iterationId )
      throws AFSException;
  
    /**
--- 1694,1700 ----
     * @see #getKeysBegin
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void getKeysDone( long iterationId )
      throws AFSException;
  
    /**
***************
*** 1701,1707 ****
     * @exception AFSException  If an error occurs in the native code
     * @see #getVosServerHandle
     */
!   protected static native int getBosAdminCount( int serverHandle )
      throws AFSException;
  
    /**
--- 1707,1713 ----
     * @exception AFSException  If an error occurs in the native code
     * @see #getVosServerHandle
     */
!   protected static native int getBosAdminCount( long serverHandle )
      throws AFSException;
  
    /**
***************
*** 1715,1721 ****
     * @return an iteration ID
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getBosAdminsBegin( int serverHandle )
      throws AFSException;
  
    /**
--- 1721,1727 ----
     * @return an iteration ID
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native long getBosAdminsBegin( long serverHandle )
      throws AFSException;
  
    /**
***************
*** 1727,1733 ****
     * @return the name of the next admin of the server
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native String getBosAdminsNextString( int iterationId )
      throws AFSException;
  
    /**
--- 1733,1739 ----
     * @return the name of the next admin of the server
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native String getBosAdminsNextString( long iterationId )
      throws AFSException;
  
    /**
***************
*** 1735,1749 ****
     * are no more admins, != 0 otherwise.
     *
     * @param cellHandle    the handle of the cell to which these admins belong
!    * @see Cell#getCellHandle
     * @param iterationId   the iteration ID of this iteration
     * @see #getBosAdminsBegin
     * @param theUser   the user object in which to fill the values of this admin
     * @return 0 if no more admins, != 0 otherwise
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getBosAdminsNext( int cellHandle, 
! 						int iterationId, User theUser )
      throws AFSException;
  
    /**
--- 1741,1755 ----
     * are no more admins, != 0 otherwise.
     *
     * @param cellHandle    the handle of the cell to which these admins belong
!    * @see #getCellHandle
     * @param iterationId   the iteration ID of this iteration
     * @see #getBosAdminsBegin
     * @param theUser   the user object in which to fill the values of this admin
     * @return 0 if no more admins, != 0 otherwise
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getBosAdminsNext( long cellHandle, 
! 						long iterationId, User theUser )
      throws AFSException;
  
    /**
***************
*** 1753,1759 ****
     * @see #getBosAdminsBegin
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void getBosAdminsDone( int iterationId )
      throws AFSException;
  
    /**
--- 1759,1765 ----
     * @see #getBosAdminsBegin
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void getBosAdminsDone( long iterationId )
      throws AFSException;
  
    /**
***************
*** 1765,1771 ****
     * @param adminName   the name of the admin to add to the list
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void addBosAdmin( int serverHandle, 
  					    String adminName )
      throws AFSException;
  
--- 1771,1777 ----
     * @param adminName   the name of the admin to add to the list
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void addBosAdmin( long serverHandle, 
  					    String adminName )
      throws AFSException;
  
***************
*** 1779,1785 ****
     * @param adminName   the name of the admin to remove from the list
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void removeBosAdmin( int serverHandle, 
  					       String adminName )
      throws AFSException;
  
--- 1785,1791 ----
     * @param adminName   the name of the admin to remove from the list
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void removeBosAdmin( long serverHandle, 
  					       String adminName )
      throws AFSException;
  
***************
*** 1787,1793 ****
     * Salvages (restores consistency to) a volume, partition, or server
     *
     * @param cellHandle    the handle of the cell to which the volume belongs
!    * @see Cell#getCellHandle
     * @param serverHandle  the bos handle of the server on which the 
     *                      volume resides
     * @see #getBosServerHandle
--- 1793,1799 ----
     * Salvages (restores consistency to) a volume, partition, or server
     *
     * @param cellHandle    the handle of the cell to which the volume belongs
!    * @see #getCellHandle
     * @param serverHandle  the bos handle of the server on which the 
     *                      volume resides
     * @see #getBosServerHandle
***************
*** 1815,1821 ****
     *                          one block at a time and skip badly damaged 
     *                          blocks.  Use if partition has disk errors
     */
!   protected static native void salvage( int cellHandle, int serverHandle, 
  					String partitionName, String volName,
  					int numSalvagers, String tempDir, 
  					String logFile, 
--- 1821,1827 ----
     *                          one block at a time and skip badly damaged 
     *                          blocks.  Use if partition has disk errors
     */
!   protected static native void salvage( long cellHandle, long serverHandle, 
  					String partitionName, String volName,
  					int numSalvagers, String tempDir, 
  					String logFile, 
***************
*** 1831,1844 ****
     *  Synchronizes a particular server with the volume location database.
     *
     * @param cellHandle    the handle of the cell to which the server belongs
!    * @see Cell#getCellHandle
     * @param serverHandle  the vos handle of the server     
     * @see #getVosServerHandle
     * @param partition   the id of the partition to sync, can be -1 to ignore
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void syncServerWithVLDB( int cellHandle, 
! 						   int serverHandle, 
  						   int partition )
      throws AFSException;
  
--- 1837,1850 ----
     *  Synchronizes a particular server with the volume location database.
     *
     * @param cellHandle    the handle of the cell to which the server belongs
!    * @see #getCellHandle
     * @param serverHandle  the vos handle of the server     
     * @see #getVosServerHandle
     * @param partition   the id of the partition to sync, can be -1 to ignore
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void syncServerWithVLDB( long cellHandle, 
! 						   long serverHandle, 
  						   int partition )
      throws AFSException;
  
***************
*** 1846,1860 ****
     *  Synchronizes the volume location database with a particular server.
     *
     * @param cellHandle    the handle of the cell to which the server belongs
!    * @see Cell#getCellHandle
     * @param serverHandle  the vos handle of the server     
     * @see #getVosServerHandle
     * @param partition   the id of the partition to sync, can be -1 to ignore
     * @param forceDeletion   whether or not to force the deletion of bad volumes
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void syncVLDBWithServer( int cellHandle, 
! 						   int serverHandle, 
  						   int partition, 
  						   boolean forceDeletion )
      throws AFSException;
--- 1852,1866 ----
     *  Synchronizes the volume location database with a particular server.
     *
     * @param cellHandle    the handle of the cell to which the server belongs
!    * @see #getCellHandle
     * @param serverHandle  the vos handle of the server     
     * @see #getVosServerHandle
     * @param partition   the id of the partition to sync, can be -1 to ignore
     * @param forceDeletion   whether or not to force the deletion of bad volumes
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void syncVLDBWithServer( long cellHandle, 
! 						   long serverHandle, 
  						   int partition, 
  						   boolean forceDeletion )
      throws AFSException;
***************
*** 1869,1875 ****
     * @param logLocation   the full path and name of the desired bos log
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native String getLog( int serverHandle, String logLocation )
      throws AFSException;
  
    /**
--- 1875,1881 ----
     * @param logLocation   the full path and name of the desired bos log
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native String getLog( long serverHandle, String logLocation )
      throws AFSException;
  
    /**
***************
*** 1886,1892 ****
     *                    the restart time fields
     * @exception AFSException  If an error occurs in the native code
     */
!   private static native void getRestartTime( int serverHandle, 
  					       int restartType, 
  					       ExecutableTime executableTime )
      throws AFSException;
--- 1892,1898 ----
     *                    the restart time fields
     * @exception AFSException  If an error occurs in the native code
     */
!   private static native void getRestartTime( long serverHandle, 
  					       int restartType, 
  					       ExecutableTime executableTime )
      throws AFSException;
***************
*** 1903,1909 ****
     * @param theServer   the server object containing the desired information
     * @exception AFSException  If an error occurs in the native code
     */
!   private static native void setRestartTime( int serverHandle, 
  					       int restartType, 
  					       ExecutableTime executableTime )
      throws AFSException;
--- 1909,1915 ----
     * @param theServer   the server object containing the desired information
     * @exception AFSException  If an error occurs in the native code
     */
!   private static native void setRestartTime( long serverHandle, 
  					       int restartType, 
  					       ExecutableTime executableTime )
      throws AFSException;
***************
*** 1916,1922 ****
     * @see #getBosServerHandle
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void startAllProcesses( int serverHandle )
      throws AFSException;
  
    /**
--- 1922,1928 ----
     * @see #getBosServerHandle
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void startAllProcesses( long serverHandle )
      throws AFSException;
  
    /**
***************
*** 1928,1934 ****
     * @param restartBosServer   whether or not to restart the bos server as well
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void restartAllProcesses( int serverHandle, 
  						    boolean restartBosServer )
      throws AFSException;
  
--- 1934,1940 ----
     * @param restartBosServer   whether or not to restart the bos server as well
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void restartAllProcesses( long serverHandle, 
  						    boolean restartBosServer )
      throws AFSException;
  
***************
*** 1940,1946 ****
     * @see #getBosServerHandle
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void stopAllProcesses( int serverHandle )
      throws AFSException;
  
    /**
--- 1946,1952 ----
     * @see #getBosServerHandle
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void stopAllProcesses( long serverHandle )
      throws AFSException;
  
    /**
Index: openafs/src/JAVA/classes/org/openafs/jafs/Token.java
diff -c openafs/src/JAVA/classes/org/openafs/jafs/Token.java:1.2 openafs/src/JAVA/classes/org/openafs/jafs/Token.java:1.2.2.1
*** openafs/src/JAVA/classes/org/openafs/jafs/Token.java:1.2	Thu Jun 19 12:53:14 2003
--- openafs/src/JAVA/classes/org/openafs/jafs/Token.java	Fri Oct 14 22:14:10 2005
***************
*** 91,97 ****
  {
    public static int ANYUSER_PAG_ID;
  
!   protected int tokenHandle;
    protected int pagID = -1;
    protected int errno;
  
--- 91,97 ----
  {
    public static int ANYUSER_PAG_ID;
  
!   protected long tokenHandle;
    protected int pagID = -1;
    protected int errno;
  
***************
*** 161,167 ****
      this.password = password;
      this.cellName = cellName;
  
! System.out.println(username + ", " + cellName);
      /* By default lets authenticate the user using libafsauthent.a */
      login();
    }
--- 161,167 ----
      this.password = password;
      this.cellName = cellName;
  
! //System.out.println(username + ", " + cellName);
      /* By default lets authenticate the user using libafsauthent.a */
      login();
    }
***************
*** 196,202 ****
     * @exception AFSException  If an error occurs in the native code
     * @return a token representing the authentication
     */
!   protected int getHandle()
    {
      return tokenHandle;
    }
--- 196,202 ----
     * @exception AFSException  If an error occurs in the native code
     * @return a token representing the authentication
     */
!   protected long getHandle()
    {
      return tokenHandle;
    }
***************
*** 250,255 ****
--- 250,256 ----
    public void login() throws AFSException
    {
      this.tokenHandle = this.getToken(cellName, username, password);
+ //System.out.println("Token handle -> " + tokenHandle);
    }
  
    /**
***************
*** 355,361 ****
     * @exception AFSException  If an error occurs in the native code
     * @return a token representing the authentication
     */
!   protected native int getToken( String cellName, String username, 
                                   String password ) 
  	throws AFSException;
  
--- 356,362 ----
     * @exception AFSException  If an error occurs in the native code
     * @return a token representing the authentication
     */
!   protected native long getToken( String cellName, String username, 
                                   String password ) 
  	throws AFSException;
  
***************
*** 365,371 ****
     * @param tokenHandle   the token to close
     * @exception AFSException  If an error occurs in the native code
     */
!   protected native void close( int tokenHandle ) throws AFSException;
  
    /**
     *  Gets the expiration time for a given token.
--- 366,372 ----
     * @param tokenHandle   the token to close
     * @exception AFSException  If an error occurs in the native code
     */
!   protected native void close( long tokenHandle ) throws AFSException;
  
    /**
     *  Gets the expiration time for a given token.
***************
*** 376,382 ****
     * @return a long representing the UTC time for the token expiration
     * @exception AFSException  If an error occurs in the native code
     */
!   protected native long getExpiration( int tokenHandle )
        throws AFSException;
  
    /**
--- 377,383 ----
     * @return a long representing the UTC time for the token expiration
     * @exception AFSException  If an error occurs in the native code
     */
!   protected native long getExpiration( long tokenHandle )
        throws AFSException;
  
    /**
Index: openafs/src/JAVA/classes/org/openafs/jafs/User.java
diff -c openafs/src/JAVA/classes/org/openafs/jafs/User.java:1.2 openafs/src/JAVA/classes/org/openafs/jafs/User.java:1.2.2.1
*** openafs/src/JAVA/classes/org/openafs/jafs/User.java:1.2	Thu Jun 19 12:53:14 2003
--- openafs/src/JAVA/classes/org/openafs/jafs/User.java	Fri Oct 14 22:14:10 2005
***************
*** 160,166 ****
    public static final int NO_REUSE_PASSWORD = 1;
  
    protected Cell cell;
!   protected int cellHandle;
    protected String name;
  
    /**
--- 160,166 ----
    public static final int NO_REUSE_PASSWORD = 1;
  
    protected Cell cell;
!   protected long cellHandle;
    protected String name;
  
    /**
***************
*** 542,548 ****
    protected void refreshGroupNames() throws AFSException
    {
      String currName;
!     int iterationID = getUserGroupsBegin( cell.getCellHandle(), name );
      groupNames = new ArrayList();
      while( ( currName = getUserGroupsNextString( iterationID ) ) != null ) {
        groupNames.add( currName );
--- 542,548 ----
    protected void refreshGroupNames() throws AFSException
    {
      String currName;
!     long iterationID = getUserGroupsBegin( cell.getCellHandle(), name );
      groupNames = new ArrayList();
      while( ( currName = getUserGroupsNextString( iterationID ) ) != null ) {
        groupNames.add( currName );
***************
*** 560,566 ****
    protected void refreshGroups() throws AFSException
    {
      Group currGroup;
!     int iterationID = getUserGroupsBegin( cell.getCellHandle(), name );
  
      groups = new ArrayList();
  
--- 560,566 ----
    protected void refreshGroups() throws AFSException
    {
      Group currGroup;
!     long iterationID = getUserGroupsBegin( cell.getCellHandle(), name );
  
      groups = new ArrayList();
  
***************
*** 582,588 ****
    protected void refreshGroupsOwnedNames() throws AFSException
    {
      String currName;
!     int iterationID = this.getGroupsOwnedBegin( cell.getCellHandle(), name );
      groupsOwnedNames = new ArrayList();
      while( ( currName = this.getGroupsOwnedNextString( iterationID ) ) 
  	   != null ) {
--- 582,588 ----
    protected void refreshGroupsOwnedNames() throws AFSException
    {
      String currName;
!     long iterationID = this.getGroupsOwnedBegin( cell.getCellHandle(), name );
      groupsOwnedNames = new ArrayList();
      while( ( currName = this.getGroupsOwnedNextString( iterationID ) ) 
  	   != null ) {
***************
*** 601,607 ****
    protected void refreshGroupsOwned() throws AFSException
    {
      Group currGroup;
!     int iterationID = getGroupsOwnedBegin( cell.getCellHandle(), name );
      groupsOwned = new ArrayList();
      currGroup = new Group( cell );
      while( getGroupsOwnedNext( cellHandle, iterationID, currGroup ) != 0 ) {
--- 601,607 ----
    protected void refreshGroupsOwned() throws AFSException
    {
      Group currGroup;
!     long iterationID = getGroupsOwnedBegin( cell.getCellHandle(), name );
      groupsOwned = new ArrayList();
      currGroup = new Group( cell );
      while( getGroupsOwnedNext( cellHandle, iterationID, currGroup ) != 0 ) {
***************
*** 1288,1294 ****
      if( (value != this.USER_OWNER_ACCESS) && 
  	(value != this.USER_ANYUSER_ACCESS) ) {
  	throw new IllegalArgumentException( "Cannot set listStatus to " 
!                                           + value );
      } else {
  	listStatus = value;
      }
--- 1288,1294 ----
      if( (value != this.USER_OWNER_ACCESS) && 
  	(value != this.USER_ANYUSER_ACCESS) ) {
  	throw new IllegalArgumentException( "Cannot set listStatus to " 
! 					    + value );
      } else {
  	listStatus = value;
      }
***************
*** 1313,1319 ****
      if( (value != this.USER_OWNER_ACCESS) && 
  	(value != this.USER_ANYUSER_ACCESS) ) {
  	throw new IllegalArgumentException( "Cannot set listGroupsOwned to " 
!                                           + value );
      } else {
  	listGroupsOwned = value;
      }
--- 1313,1319 ----
      if( (value != this.USER_OWNER_ACCESS) && 
  	(value != this.USER_ANYUSER_ACCESS) ) {
  	throw new IllegalArgumentException( "Cannot set listGroupsOwned to " 
! 					    + value );
      } else {
  	listGroupsOwned = value;
      }
***************
*** 1339,1345 ****
      if( (value != this.USER_OWNER_ACCESS) && 
  	(value != this.USER_ANYUSER_ACCESS) ) {
  	throw new IllegalArgumentException( "Cannot set listMembership to " 
!                                           + value );
      } else {
  	listMembership = value;
      }
--- 1339,1345 ----
      if( (value != this.USER_OWNER_ACCESS) && 
  	(value != this.USER_ANYUSER_ACCESS) ) {
  	throw new IllegalArgumentException( "Cannot set listMembership to " 
! 					    + value );
      } else {
  	listMembership = value;
      }
***************
*** 1503,1509 ****
     *
     * @return a <code>String</code> representation of the <code>User</code>
     */
!   protected String getInfo()
    {
      String r;
      try {
--- 1503,1509 ----
     *
     * @return a <code>String</code> representation of the <code>User</code>
     */
!   public String getInfo()
    {
      String r;
      try {
***************
*** 1624,1630 ****
     * @return    a <code>String</code> representation of the groups belonged to
     * @see       Group#toString
     */
!   protected String getInfoGroups() throws AFSException
    {
  	String r;
  	r = "User: " + name + "\n\n";
--- 1624,1630 ----
     * @return    a <code>String</code> representation of the groups belonged to
     * @see       Group#toString
     */
!   public String getInfoGroups() throws AFSException
    {
  	String r;
  	r = "User: " + name + "\n\n";
***************
*** 1644,1650 ****
     * @return    a <code>String</code> representation of the groups owned
     * @see       Group#toString
     */
!   protected String getInfoGroupsOwned() throws AFSException
    {
  	String r;
  	r = "User: " + name + "\n\n";
--- 1644,1650 ----
     * @return    a <code>String</code> representation of the groups owned
     * @see       Group#toString
     */
!   public String getInfoGroupsOwned() throws AFSException
    {
  	String r;
  	r = "User: " + name + "\n\n";
***************
*** 1723,1730 ****
     *                automatically assigned)
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void create( int cellHandle, String userName, 
!                                        String password, int uid )
  	throws AFSException;
  
    /**
--- 1723,1730 ----
     *                automatically assigned)
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void create( long cellHandle, String userName, 
! 				       String password, int uid )
  	throws AFSException;
  
    /**
***************
*** 1737,1743 ****
     * @param groupName      the name of the user to delete
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void delete( int cellHandle, String userName )
  	throws AFSException;
  
    /**
--- 1737,1743 ----
     * @param groupName      the name of the user to delete
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void delete( long cellHandle, String userName )
  	throws AFSException;
  
    /**
***************
*** 1748,1754 ****
     * @param groupName      the name of the user to unlock
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void unlock( int cellHandle, String userName )
  	throws AFSException;
  
    /**
--- 1748,1754 ----
     * @param groupName      the name of the user to unlock
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native void unlock( long cellHandle, String userName )
  	throws AFSException;
  
    /**
***************
*** 1763,1770 ****
     * @see User
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void getUserInfo( int cellHandle, String name, 
!                                             User user ) 
  	throws AFSException;
  
    /**
--- 1763,1770 ----
     * @see User
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void getUserInfo( long cellHandle, String name, 
! 					    User user ) 
  	throws AFSException;
  
    /**
***************
*** 1778,1785 ****
     *                 information
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void setUserInfo( int cellHandle, String name, 
!                                             User theUser ) 
  	throws AFSException;
  
    /**
--- 1778,1785 ----
     *                 information
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void setUserInfo( long cellHandle, String name, 
! 					    User theUser ) 
  	throws AFSException;
  
    /**
***************
*** 1792,1799 ****
     * @param newName     the new name for the user
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void rename( int cellHandle, String oldName, 
!                                        String newName )
  	throws AFSException;
  
    /**
--- 1792,1799 ----
     * @param newName     the new name for the user
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void rename( long cellHandle, String oldName, 
! 				       String newName )
  	throws AFSException;
  
    /**
***************
*** 1805,1812 ****
     * @param newPassword     the new password for the user
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void setPassword( int cellHandle, String userName, 
!                                             String newPassword )
  	throws AFSException;
  
    /**
--- 1805,1812 ----
     * @param newPassword     the new password for the user
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void setPassword( long cellHandle, String userName, 
! 					    String newPassword )
  	throws AFSException;
  
    /**
***************
*** 1820,1826 ****
     * @return an iteration ID
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native int getUserGroupsBegin( int cellHandle, String name )
  	throws AFSException;
  
    /**
--- 1820,1826 ----
     * @return an iteration ID
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native long getUserGroupsBegin( long cellHandle, String name )
  	throws AFSException;
  
    /**
***************
*** 1828,1838 ****
     * <code>null</code> if there are no more groups.
     *
     * @param iterationId   the iteration ID of this iteration
!    * @see #getUserGroupsBegin
     * @return the name of the next group
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native String getUserGroupsNextString( int iterationId )
  	throws AFSException;
  
    /**
--- 1828,1838 ----
     * <code>null</code> if there are no more groups.
     *
     * @param iterationId   the iteration ID of this iteration
!    * @see getUserGroupsBegin
     * @return the name of the next group
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native String getUserGroupsNextString( long iterationId )
  	throws AFSException;
  
    /**
***************
*** 1842,1866 ****
     * @param cellHandle    the handle of the cell to which the users belong
     * @see Cell#getCellHandle
     * @param iterationId   the iteration ID of this iteration
!    * @see #getUserGroupsBegin
     * @param theGroup   a Group object to be populated with the values of the 
     *                   next group
     * @return 0 if there are no more users, != 0 otherwise
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getUserGroupsNext( int cellHandle, 
!                                                  int iterationId, 
!                                                  Group theGroup )
      throws AFSException;
  
    /**
     * Signals that the iteration is complete and will not be accessed anymore.
     *
     * @param iterationId   the iteration ID of this iteration
!    * @see #getUserGroupsBegin
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void getUserGroupsDone( int iterationId )
  	throws AFSException;
  
    /**
--- 1842,1866 ----
     * @param cellHandle    the handle of the cell to which the users belong
     * @see Cell#getCellHandle
     * @param iterationId   the iteration ID of this iteration
!    * @see getUserGroupsBegin
     * @param theGroup   a Group object to be populated with the values of the 
     *                   next group
     * @return 0 if there are no more users, != 0 otherwise
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getUserGroupsNext( long cellHandle, 
! 						 long iterationId, 
! 						 Group theGroup )
      throws AFSException;
  
    /**
     * Signals that the iteration is complete and will not be accessed anymore.
     *
     * @param iterationId   the iteration ID of this iteration
!    * @see getUserGroupsBegin
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void getUserGroupsDone( long iterationId )
  	throws AFSException;
  
    /**
***************
*** 1872,1878 ****
     * @exception AFSException   If an error occurs in the native code
     * @see Cell#getCellHandle
     */
!   protected static native int getGroupsOwnedCount( int cellHandle, String name )
  	throws AFSException;
  
    /**
--- 1872,1878 ----
     * @exception AFSException   If an error occurs in the native code
     * @see Cell#getCellHandle
     */
!   protected static native int getGroupsOwnedCount( long cellHandle, String name )
  	throws AFSException;
  
    /**
***************
*** 1886,1893 ****
     * @return an iteration ID
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native int getGroupsOwnedBegin( int cellHandle, 
!                                                    String name )
  	throws AFSException;
  
    /**
--- 1886,1893 ----
     * @return an iteration ID
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native long getGroupsOwnedBegin( long cellHandle, 
! 						   String name )
  	throws AFSException;
  
    /**
***************
*** 1895,1905 ****
     * if there are no more groups.
     *
     * @param iterationId   the iteration ID of this iteration
!    * @see #getGroupsOwnedBegin
     * @return the name of the next group
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native String getGroupsOwnedNextString( int iterationId )
  	throws AFSException;
  
    /**
--- 1895,1905 ----
     * if there are no more groups.
     *
     * @param iterationId   the iteration ID of this iteration
!    * @see getGroupsOwnedBegin
     * @return the name of the next group
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native String getGroupsOwnedNextString( long iterationId )
  	throws AFSException;
  
    /**
***************
*** 1909,1933 ****
     * @param cellHandle    the handle of the cell to which the users belong
     * @see Cell#getCellHandle
     * @param iterationId   the iteration ID of this iteration
!    * @see #getGroupsOwnedBegin
     * @param theGroup   a Group object to be populated with the values of the 
     *                   next group
     * @return 0 if there are no more users, != 0 otherwise
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getGroupsOwnedNext( int cellHandle, 
!                 						  int iterationId, 
! 			            			  Group theGroup )
      throws AFSException;
  
    /**
     * Signals that the iteration is complete and will not be accessed anymore.
     *
     * @param iterationId   the iteration ID of this iteration
!    * @see #getGroupsOwnedBegin
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void getGroupsOwnedDone( int iterationId )
  	throws AFSException;
  
    /**
--- 1909,1933 ----
     * @param cellHandle    the handle of the cell to which the users belong
     * @see Cell#getCellHandle
     * @param iterationId   the iteration ID of this iteration
!    * @see getGroupsOwnedBegin
     * @param theGroup   a Group object to be populated with the values of the 
     *                   next group
     * @return 0 if there are no more users, != 0 otherwise
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int getGroupsOwnedNext( long cellHandle, 
! 						  long iterationId, 
! 						  Group theGroup )
      throws AFSException;
  
    /**
     * Signals that the iteration is complete and will not be accessed anymore.
     *
     * @param iterationId   the iteration ID of this iteration
!    * @see getGroupsOwnedBegin
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void getGroupsOwnedDone( long iterationId )
  	throws AFSException;
  
    /**
***************
*** 1937,1939 ****
--- 1937,1948 ----
     */
    protected static native void reclaimUserMemory();
  }
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
Index: openafs/src/JAVA/classes/org/openafs/jafs/VersionInfo.java
diff -c /dev/null openafs/src/JAVA/classes/org/openafs/jafs/VersionInfo.java:1.1.2.2
*** /dev/null	Sat Oct 22 02:14:46 2005
--- openafs/src/JAVA/classes/org/openafs/jafs/VersionInfo.java	Fri Oct 14 22:14:10 2005
***************
*** 0 ****
--- 1,72 ----
+ /*
+  * @(#)VersionInfo.java	1.0 05/09/2005
+  *
+  * Copyright (c) 2001 International Business Machines Corp.
+  * All rights reserved.
+  *
+  * This software has been released under the terms of the IBM Public
+  * License.  For details, see the LICENSE file in the top-level source
+  * directory or online at http://www.openafs.org/dl/license10.html
+  * 
+  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+  * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR
+  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+  */
+ 
+ package org.openafs.jafs;
+ 
+ /**
+  * Provides version information about the native C library and the JAVA side.
+  *
+  * At least a <<Class.forName("org.openafs.jafs.Token");>> is necessary before using these methods.
+  * Perhaps a redesign would be required because the library initialization occures only in Token.java.
+  */
+ public class VersionInfo
+ {
+   /**
+    * Returns java interface version string
+    * the native library version should be higher
+    */
+   public static String getVersionOfJavaInterface() {return "20050905";}
+ 
+   /**
+    * Returns the native library version
+    *
+    * @exception AFSException if internal (libjafs, libjafsadmin) versions differ
+    */
+   public static String getVersionOfLibrary() throws AFSException
+   {
+   	String ver = getVersionOfLibjafs();
+ 	if (!ver.equals(getVersionOfLibjafsadm()))
+ 		throw new AFSException("library versions differ", 0);
+ 	return ver;
+   }
+ 
+   /**
+    * Returns build information of the native library.
+    * This information is autogenerated by the openafs make system.
+    * Example: "@(#) OpenAFS 1.3.87 built  2005-09-06 "
+    *
+    * @exception AFSException if internal (libjafs, libjafsadmin) versions differ
+    */
+   public static String getBuildInfo() throws AFSException
+   {
+   	String info = getBuildInfoOfLibjafs();
+ 	if (!info.equals(getBuildInfoOfLibjafsadm()))
+ 		throw new AFSException("library build info differ", 0);
+ 	return info;
+   }
+ 
+   private static native String getVersionOfLibjafs();
+   private static native String getVersionOfLibjafsadm();
+   private static native String getBuildInfoOfLibjafs();
+   private static native String getBuildInfoOfLibjafsadm();
+ }
Index: openafs/src/JAVA/classes/org/openafs/jafs/Volume.java
diff -c openafs/src/JAVA/classes/org/openafs/jafs/Volume.java:1.2 openafs/src/JAVA/classes/org/openafs/jafs/Volume.java:1.2.2.1
*** openafs/src/JAVA/classes/org/openafs/jafs/Volume.java:1.2	Thu Jun 19 12:53:14 2003
--- openafs/src/JAVA/classes/org/openafs/jafs/Volume.java	Fri Oct 14 22:14:10 2005
***************
*** 315,321 ****
    protected void refreshInfo() throws AFSException
    {
      getVolumeInfo( cell.getCellHandle(), server.getVosHandle(), 
!                    partition.getID(), getID(), this );
      cachedInfo = true;
      creationDateCal = null;
      lastUpdateDateCal = null;
--- 315,321 ----
    protected void refreshInfo() throws AFSException
    {
      getVolumeInfo( cell.getCellHandle(), server.getVosHandle(), 
! 		   partition.getID(), getID(), this );
      cachedInfo = true;
      creationDateCal = null;
      lastUpdateDateCal = null;
***************
*** 333,339 ****
    public void create( int quota ) throws AFSException
    {
      id = create( cell.getCellHandle(), server.getVosHandle(), 
!                  partition.getID(), name, quota );
      maxQuota = quota;
    }
  
--- 333,339 ----
    public void create( int quota ) throws AFSException
    {
      id = create( cell.getCellHandle(), server.getVosHandle(), 
! 		 partition.getID(), name, quota );
      maxQuota = quota;
    }
  
***************
*** 366,372 ****
    {
      Server siteServer = sitePartition.getServer();
      createReadOnlyVolume( cell.getCellHandle(), siteServer.getVosHandle(), 
!                           sitePartition.getID(), getID() );
      release( false );
      return new Volume( name + ".readonly", sitePartition );
    }
--- 366,372 ----
    {
      Server siteServer = sitePartition.getServer();
      createReadOnlyVolume( cell.getCellHandle(), siteServer.getVosHandle(), 
! 			  sitePartition.getID(), getID() );
      release( false );
      return new Volume( name + ".readonly", sitePartition );
    }
***************
*** 379,385 ****
    public void delete() throws AFSException
    {
      delete( cell.getCellHandle(), server.getVosHandle(), partition.getID(), 
!             getID() );
      name = null;
      creationDateCal = null;
      lastUpdateDateCal = null;
--- 379,385 ----
    public void delete() throws AFSException
    {
      delete( cell.getCellHandle(), server.getVosHandle(), partition.getID(), 
! 	    getID() );
      name = null;
      creationDateCal = null;
      lastUpdateDateCal = null;
***************
*** 434,440 ****
        startTime = (int) ((dumpSince.getTime().getTime())/((long) 1000));
      }
      dump( cell.getCellHandle(), server.getVosHandle(), partition.getID(), 
!           getID(), startTime, fileName );
    }
  
    /**
--- 434,440 ----
        startTime = (int) ((dumpSince.getTime().getTime())/((long) 1000));
      }
      dump( cell.getCellHandle(), server.getVosHandle(), partition.getID(), 
! 	  getID(), startTime, fileName );
    }
  
    /**
***************
*** 485,491 ****
        throws AFSException
    {
      restore( cell.getCellHandle(), server.getVosHandle(), partition.getID(), 
!              id, name, fileName, incremental );
    }
  
    /**
--- 485,491 ----
        throws AFSException
    {
      restore( cell.getCellHandle(), server.getVosHandle(), partition.getID(), 
! 	     id, name, fileName, incremental );
    }
  
    /**
***************
*** 541,547 ****
    {
      Server newServer = newPartition.getServer();
      move( cell.getCellHandle(), server.getVosHandle(), partition.getID(), 
!           newServer.getVosHandle(), newPartition.getID(), getID() );
  
      server = newServer;
      partition = newPartition;
--- 541,547 ----
    {
      Server newServer = newPartition.getServer();
      move( cell.getCellHandle(), server.getVosHandle(), partition.getID(), 
! 	  newServer.getVosHandle(), newPartition.getID(), getID() );
  
      server = newServer;
      partition = newPartition;
***************
*** 568,575 ****
    public void salvage() throws AFSException
    {
      Server.salvage( cell.getCellHandle(), server.getBosHandle(), 
!                     partition.getName(), name, 4, null, null, false, false, 
!                     false, false, false, false );
    }
  
    /**
--- 568,575 ----
    public void salvage() throws AFSException
    {
      Server.salvage( cell.getCellHandle(), server.getBosHandle(), 
! 		    partition.getName(), name, 4, null, null, false, false, 
! 		    false, false, false, false );
    }
  
    /**
***************
*** 598,604 ****
      throws AFSException
    {
      Cell.createMountPoint( cell.getCellHandle(), directory, getName(), 
!                            readWrite, false ); 
    }
  
    //////////////// accessors:  ////////////////////////
--- 598,604 ----
      throws AFSException
    {
      Cell.createMountPoint( cell.getCellHandle(), directory, getName(), 
! 			   readWrite, false ); 
    }
  
    //////////////// accessors:  ////////////////////////
***************
*** 847,853 ****
      if ( !cachedInfo ) refreshInfo();
      if (maxQuota == 0) {
        throw new AFSException("Volume with id " + id + 
!                              " has an unlimited quota configured.", 0);
      }
      return maxQuota;
    }
--- 847,853 ----
      if ( !cachedInfo ) refreshInfo();
      if (maxQuota == 0) {
        throw new AFSException("Volume with id " + id + 
!                                   " has an unlimited quota configured.", 0);
      }
      return maxQuota;
    }
***************
*** 954,960 ****
    public void setQuota( int quota ) throws AFSException
    {
      this.changeQuota( cell.getCellHandle(), server.getVosHandle(), 
!                       partition.getID(), getID(), quota );
      maxQuota = quota;
    }
  
--- 954,960 ----
    public void setQuota( int quota ) throws AFSException
    {
      this.changeQuota( cell.getCellHandle(), server.getVosHandle(), 
! 		      partition.getID(), getID(), quota );
      maxQuota = quota;
    }
  
***************
*** 966,972 ****
     *
     * @return a <code>String</code> representation of the <code>Volume</code>
     */
!   protected String getInfo()
    {
        String r;
        try {
--- 966,972 ----
     *
     * @return a <code>String</code> representation of the <code>Volume</code>
     */
!   public String getInfo()
    {
        String r;
        try {
***************
*** 1096,1104 ****
     *                    the information
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void getVolumeInfo( int cellHandle, int serverHandle,
!                                               int partition, int volId, 
!                                               Volume theVolume ) 
  	throws AFSException;
  
    /**
--- 1096,1104 ----
     *                    the information
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void getVolumeInfo( long cellHandle, long serverHandle,
! 					      int partition, int volId, 
! 					      Volume theVolume ) 
  	throws AFSException;
  
    /**
***************
*** 1116,1124 ****
     * @return the numeric ID assigned to the volume
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native int create( int cellHandle, int serverHandle, 
!                                       int partition, String volumeName, 
!                                       int quota ) 
  	throws AFSException;
  
    /**
--- 1116,1124 ----
     * @return the numeric ID assigned to the volume
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native int create( long cellHandle, long serverHandle, 
! 				      int partition, String volumeName, 
! 				      int quota ) 
  	throws AFSException;
  
    /**
***************
*** 1134,1141 ****
     * @param volId   the numeric id of the volume to delete
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void delete( int cellHandle, int serverHandle, 
!                                        int partition, int volId ) 
  	throws AFSException;
  
    /**
--- 1134,1141 ----
     * @param volId   the numeric id of the volume to delete
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void delete( long cellHandle, long serverHandle, 
! 				       int partition, int volId ) 
  	throws AFSException;
  
    /**
***************
*** 1146,1152 ****
     *               volume
     * @see Cell#getCellHandle
     */
!   protected static native void createBackupVolume( int cellHandle, int volId )
  	throws AFSException;
  
    /**
--- 1146,1152 ----
     *               volume
     * @see Cell#getCellHandle
     */
!   protected static native void createBackupVolume( long cellHandle, int volId )
  	throws AFSException;
  
    /**
***************
*** 1161,1169 ****
     * @param volId  the numeric id of the volume for which to create a read-only volume
     * @see Cell#getCellHandle
     */
!   protected static native void createReadOnlyVolume( int cellHandle, 
!                                                      int serverHandle, 
!                                                      int partition, int volId )
  	throws AFSException;
  
    /**
--- 1161,1169 ----
     * @param volId  the numeric id of the volume for which to create a read-only volume
     * @see Cell#getCellHandle
     */
!   protected static native void createReadOnlyVolume( long cellHandle, 
! 						     long serverHandle, 
! 						     int partition, int volId )
  	throws AFSException;
  
    /**
***************
*** 1179,1187 ****
     *               delete the read-only volume
     * @see Cell#getCellHandle
     */
!   protected static native void deleteReadOnlyVolume( int cellHandle, 
!                                                      int serverHandle, 
!                                                      int partition, int volId )
  	throws AFSException;
  
    /**
--- 1179,1187 ----
     *               delete the read-only volume
     * @see Cell#getCellHandle
     */
!   protected static native void deleteReadOnlyVolume( long cellHandle, 
! 						     long serverHandle, 
! 						     int partition, int volId )
  	throws AFSException;
  
    /**
***************
*** 1198,1206 ****
     * @param newQuota    the new quota (in KB) to assign the volume
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void changeQuota( int cellHandle, int serverHandle, 
!                                             int partition, int volId, 
!                                             int newQuota ) 
  	throws AFSException;
  
    /**
--- 1198,1206 ----
     * @param newQuota    the new quota (in KB) to assign the volume
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void changeQuota( long cellHandle, long serverHandle, 
! 					    int partition, int volId, 
! 					    int newQuota ) 
  	throws AFSException;
  
    /**
***************
*** 1220,1228 ****
     * @param volId  the numeric id of the volume to move
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void move( int cellHandle, int fromServerHandle, 
!                                      int fromPartition, int toServerHandle, 
!                                      int toPartition, int volId ) 
  	throws AFSException;
  
    /**
--- 1220,1228 ----
     * @param volId  the numeric id of the volume to move
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void move( long cellHandle, long fromServerHandle, 
! 				     int fromPartition, long toServerHandle, 
! 				     int toPartition, int volId ) 
  	throws AFSException;
  
    /**
***************
*** 1233,1240 ****
     * @param forceComplete  whether or not to force a complete release
     * @see Cell#getCellHandle
     */
!   protected static native void release( int cellHandle, int volId, 
!                                         boolean forceComplete )
  	throws AFSException;
  
    /**
--- 1233,1240 ----
     * @param forceComplete  whether or not to force a complete release
     * @see Cell#getCellHandle
     */
!   protected static native void release( long cellHandle, int volId, 
! 					boolean forceComplete )
  	throws AFSException;
  
    /**
***************
*** 1253,1261 ****
     * @param dumpFile   the full path of the file to which to dump
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void dump( int cellHandle, int serverHandle, 
!                                      int partition, int volId, int startTime, 
!                                      String dumpFile ) 
  	throws AFSException;
  
    /**
--- 1253,1261 ----
     * @param dumpFile   the full path of the file to which to dump
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void dump( long cellHandle, long serverHandle, 
! 				     int partition, int volId, int startTime, 
! 				     String dumpFile ) 
  	throws AFSException;
  
    /**
***************
*** 1277,1286 ****
     *                     otherwise restores a full dump
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void restore( int cellHandle, int serverHandle, 
!                                         int partition, int volId, 
!                                         String volumeName, String dumpFile, 
!                                         boolean incremental ) 
  	throws AFSException;
  
    /**
--- 1277,1286 ----
     *                     otherwise restores a full dump
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void restore( long cellHandle, long serverHandle, 
! 					int partition, int volId, 
! 					String volumeName, String dumpFile, 
! 					boolean incremental ) 
  	throws AFSException;
  
    /**
***************
*** 1292,1299 ****
     * @param newVolumeName  the new name for the volume
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void rename( int cellHandle, int volId, 
!                                        String newVolumeName ) 
  	throws AFSException;
  
    /**
--- 1292,1299 ----
     * @param newVolumeName  the new name for the volume
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void rename( long cellHandle, int volId, 
! 				       String newVolumeName ) 
  	throws AFSException;
  
    /**
***************
*** 1311,1319 ****
     *                     status of the volume -- busy or offline)
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void mount( int serverHandle, int partition, 
!                                       int volId, int sleepTime, 
!                                       boolean offline ) 
  	throws AFSException;
  
    /**
--- 1311,1319 ----
     *                     status of the volume -- busy or offline)
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void mount( long serverHandle, int partition, 
! 				      int volId, int sleepTime, 
! 				      boolean offline ) 
  	throws AFSException;
  
    /**
***************
*** 1327,1334 ****
     * @param volId  the numeric id of the volume to bring offline
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void unmount( int serverHandle, int partition, 
!                                         int volId ) 
  	throws AFSException;
  
    /**
--- 1327,1334 ----
     * @param volId  the numeric id of the volume to bring offline
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void unmount( long serverHandle, int partition, 
! 					int volId ) 
  	throws AFSException;
  
    /**
***************
*** 1339,1345 ****
     * @param volId  the numeric id of the volume to lock
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void lock( int cellHandle, int volId ) 
  	throws AFSException;
  
    /**
--- 1339,1345 ----
     * @param volId  the numeric id of the volume to lock
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void lock( long cellHandle, int volId ) 
  	throws AFSException;
  
    /**
***************
*** 1350,1356 ****
     * @param volId  the numeric id of the volume to unlock
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void unlock( int cellHandle, int volId ) 
  	throws AFSException;
  
    /**
--- 1350,1356 ----
     * @param volId  the numeric id of the volume to unlock
     * @exception AFSException   If an error occurs in the native code
     */
!   protected static native void unlock( long cellHandle, int volId ) 
  	throws AFSException;
  
    /**
***************
*** 1368,1375 ****
     * @return   the id of the volume in question
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int translateNameToID( int cellHandle, String name, 
!                                                  int volumeType )
      throws AFSException;
  
    /**
--- 1368,1375 ----
     * @return   the id of the volume in question
     * @exception AFSException  If an error occurs in the native code
     */
!   protected static native int translateNameToID( long cellHandle, String name, 
! 						 int volumeType )
      throws AFSException;
  
    /**
***************
*** 1379,1381 ****
--- 1379,1394 ----
     */
    protected static native void reclaimVolumeMemory();
  }
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
Index: openafs/src/JAVA/libjafs/ACL.c
diff -c openafs/src/JAVA/libjafs/ACL.c:1.3 openafs/src/JAVA/libjafs/ACL.c:1.3.2.1
*** openafs/src/JAVA/libjafs/ACL.c:1.3	Tue Jul 15 19:11:25 2003
--- openafs/src/JAVA/libjafs/ACL.c	Fri Oct 14 22:14:11 2005
***************
*** 28,47 ****
  #include <stdio.h>
  #include <sys/ioctl.h>
  #include <afs/vice.h>
  #include <afs/venus.h>
  #include <afs/afs_args.h>
  
  /*
    #include <afs/afs_osi.h>
  */
  
  /* just for debugging */
! #define MAXHOSTS  13
! #define OMAXHOSTS 8
! #define MAXNAME   100
! #define MAXSIZE	2048
! #define MAXINSIZE 1300		/* pioctl complains if data is larger than this */
! #define VMSGSIZE  128		/* size of msg buf in volume hdr */
  
  static char space[MAXSIZE];
  
--- 28,50 ----
  #include <stdio.h>
  #include <sys/ioctl.h>
  #include <afs/vice.h>
+ #include <netinet/in.h>
  #include <afs/venus.h>
  #include <afs/afs_args.h>
  
+ #include "GetNativeString.h"
+ 
  /*
    #include <afs/afs_osi.h>
  */
  
  /* just for debugging */
! #define	MAXHOSTS 13
! #define	OMAXHOSTS 8
! #define MAXNAME 100
! #define	MAXSIZE	2048
! #define MAXINSIZE 1300    /* pioctl complains if data is larger than this */
! #define VMSGSIZE 128      /* size of msg buf in volume hdr */
  
  static char space[MAXSIZE];
  
***************
*** 59,90 ****
   * path     the directory path
   * returns NULL if an exception is encountered.
   */
! char *
! getACL(char *path)
  {
      struct ViceIoctl params;
      char *buffer;
  
      params.in = NULL;
      params.out = NULL;
!     params.in_size = 0;
!     params.out_size = 0;
! 
!     buffer = (char *)malloc(ACL_LEN);
! 
      if (!buffer) {
! 	fprintf(stderr, "ERROR: ACL::getACL -> could not allocate buffer\n");
! 	return NULL;
      }
  
      params.out = buffer;
!     params.out_size = ACL_LEN;
  
!     if (call_syscall(AFSCALL_PIOCTL, path, VIOCGETAL, &params, 1, 0)) {
! 	fprintf(stderr, "ERROR: ACL::getACL -> VIOCGETAL failed: %d\n",
! 		errno);
! 	free(buffer);
! 	return NULL;
      }
  
      return params.out;
--- 62,94 ----
   * path     the directory path
   * returns NULL if an exception is encountered.
   */
! char* getACL(char *path)
  {
      struct ViceIoctl params;
      char *buffer;
+     int rval1=0;
  
+     buffer = (char*) malloc(ACL_LEN);
      params.in = NULL;
      params.out = NULL;
!     params.in_size = params.out_size = 0;
!     
      if (!buffer) {
!       fprintf(stderr, "ERROR: ACL::getACL -> could not allocate buffer\n");
!       return NULL;
      }
  
      params.out = buffer;
!     params.out_size = ACL_LEN; 
  
! #if defined(AFS_PPC64_LINUX20_ENV) || defined(AFS_S390X_LINUX20_ENV)
!     if(pioctl(path, VIOCGETAL, &params, 1)) {
! #else /* AFS_PPC_LINUX20_ENV */
!     if(syscall(AFS_SYSCALL, AFSCALL_PIOCTL, path, VIOCGETAL, &params, 1)) {
! #endif /* AFS_PPC_LINUX20_ENV */
!       fprintf(stderr, "ERROR: ACL::getACL -> VIOCGETAL failed: %d, path: %s\n", errno, path);
!       free(buffer);
!       return NULL;
      }
  
      return params.out;
***************
*** 98,105 ****
   * aclString  string representation of ACL to be set
   * returns TRUE if the operation succeeds; otherwise FALSE;
   */
! jboolean
! setACL(char *path, char *aclString)
  {
      struct ViceIoctl params;
      char *redirect, *parentURI, *cptr;
--- 102,108 ----
   * aclString  string representation of ACL to be set
   * returns TRUE if the operation succeeds; otherwise FALSE;
   */
! jboolean setACL(char *path, char *aclString)
  {
      struct ViceIoctl params;
      char *redirect, *parentURI, *cptr;
***************
*** 109,118 ****
      params.out = NULL;
      params.out_size = 0;
  
!     if (call_syscall(AFSCALL_PIOCTL, path, VIOCGETAL, &params, 1)) {
! 	fprintf(stderr, "ERROR: ACL::setACL -> VIOCSETAL failed: %d\n",
! 		errno);
! 	return JNI_FALSE;
      }
  
      return JNI_TRUE;
--- 112,124 ----
      params.out = NULL;
      params.out_size = 0;
  
! #if defined(AFS_PPC64_LINUX20_ENV) || defined(AFS_S390X_LINUX20_ENV)
!     if(pioctl(path, VIOCSETAL, &params, 1)) {
! #else /* AFS_PPC_LINUX20_ENV */
!     if(syscall(AFS_SYSCALL, AFSCALL_PIOCTL, path, VIOCSETAL, &params, 1)) {
! #endif /* AFS_PPC_LINUX20_ENV */
!       fprintf(stderr, "ERROR: ACL::setACL -> VIOCSETAL failed: %d, path: %s\n", errno, path);
!       return JNI_FALSE;
      }
  
      return JNI_TRUE;
***************
*** 128,158 ****
   * path     the directory path
   * returns NULL if an exception is encountered.
   */
! JNIEXPORT jstring JNICALL
! Java_org_openafs_jafs_ACL_getACLString(JNIEnv * env, jobject obj,
! 				       jstring pathUTF)
  {
      char *path, *acl;
      jstring answer = NULL;
  
!     path = getNativeString(env, pathUTF);
!     if (path == NULL) {
! 	fprintf(stderr, "ERROR: ACL::getACLString ->");
! 	fprintf(stderr, "path = NULL\n");
! 	throwAFSException(env, JAFSNULLPATH);
! 	return NULL;
      }
  
      acl = getACL(path);
-     free(path);
  
!     if (acl) {
! 	answer = (*env)->NewStringUTF(env, acl);
! 	free(acl);
      } else {
! 	throwAFSException(env, errno);
      }
  
      return answer;
  }
  
--- 134,171 ----
   * path     the directory path
   * returns NULL if an exception is encountered.
   */
! JNIEXPORT jstring JNICALL Java_org_openafs_jafs_ACL_getACLString
!   (JNIEnv *env, jobject obj, jstring pathUTF)
  {
      char *path, *acl;
      jstring answer = NULL;
  
!     /*jchar* wpath;
!     path = (char*) (*env)->GetStringUTFChars(env, pathUTF, 0);
!     wpath=(jchar*) (*env)->GetStringChars(env,pathUTF,0);*/
! 
!     path = GetNativeString(env,pathUTF);
! 
!     if(path == NULL) {
!       fprintf(stderr, "ERROR: ACL::getACLString ->");
!       fprintf(stderr, "path = NULL\n");
!       throwMessageException( env, "Path is NULL" ); 
!       return NULL;
      }
  
      acl = getACL(path);
  
!     if(acl) {
!       answer =  (*env) -> NewStringUTF(env, acl);
!       free(acl);
      } else {
!       throwAFSException( env, errno );
      }
  
+     /*(*env)->ReleaseStringUTFChars(env, pathUTF, path);
+       (*env)->ReleaseStringChars(env, pathUTF, (jchar*)wpath);*/
+ 
+     free(path); //psomogyi memory leak - added
      return answer;
  }
  
***************
*** 168,219 ****
   * aclString  string representation of ACL to be set
   * throws an afsAdminExceptionName if an internal exception is encountered.
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_ACL_setACLString(JNIEnv * env, jobject obj,
! 				       jstring pathUTF, jstring aclStringUTF)
  {
      char *path, *aclString;
  
!     if (pathUTF == NULL) {
! 	fprintf(stderr, "ERROR: ACL::setACLString -> pathUTF == NULL\n");
! 	throwAFSException(env, JAFSNULLPATH);
! 	return;
!     }
! 
!     if (aclStringUTF == NULL) {
! 	fprintf(stderr, "ERROR: ACL::setACLString -> aclStringUTF == NULL\n");
! 	throwAFSException(env, JAFSNULLACL);
! 	return;
!     }
! 
!     /* path = (char*) (*env)->GetStringUTFChars(env, pathUTF, 0); */
!     path = getNativeString(env, pathUTF);
!     if (path == NULL) {
! 	fprintf(stderr, "ERROR: ACL::setACLString -> failed to get path\n");
! 	throwMessageException(env, "Failed to get path.");
! 	return;
!     }
! 
!     /* aclString = (char*) (*env)->GetStringUTFChars(env, aclStringUTF, 0); */
!     aclString = getNativeString(env, aclStringUTF);
!     if (aclString == NULL) {
! 	free(path);
! 	fprintf(stderr,
! 		"ERROR: ACL::setACLString -> failed to get aclString\n");
! 	throwMessageException(env, "Failed to get ACL string.");
! 	return;
      }
  
      if (!setACL(path, aclString)) {
! 	throwAFSException(env, errno);
      }
  
!     /* Clean up */
      free(path);
      free(aclString);
- 
-     /*
-      * (*env)->ReleaseStringUTFChars(env, pathUTF, path);
-      * (*env)->ReleaseStringUTFChars(env, aclStringUTF, aclString);
-      */
  }
--- 181,232 ----
   * aclString  string representation of ACL to be set
   * throws an afsAdminExceptionName if an internal exception is encountered.
   */
! JNIEXPORT void JNICALL Java_org_openafs_jafs_ACL_setACLString
!   (JNIEnv *env, jobject obj, jstring pathUTF, jstring aclStringUTF)
  {
      char *path, *aclString;
  
!     if(!pathUTF) {
!       fprintf(stderr, "ERROR: ACL::setACLString -> pathUTF == NULL\n");
!       throwMessageException( env, "pathUTF == NULL" );
!       return;
!     }
! 
!     /*path = (char*) (*env)->GetStringUTFChars(env, pathUTF, 0);*/
!     path = GetNativeString(env,pathUTF);
! 
!     if(path == NULL) {
!       fprintf(stderr, "ERROR: ACL::setACLString -> failed to get path\n");
!       throwMessageException( env, "Failed to get path" );
!       return;
!     }
! 
!     if(!aclStringUTF) {
!       fprintf(stderr, "ERROR: ACL::setACLString -> aclStringUTF == NULL\n");
!       throwMessageException( env, "aclStringUTF == NULL" ); 
!       return;
!     }
! 
!     /*aclString = (char*) (*env)->GetStringUTFChars(env, aclStringUTF, 0);*/
!     aclString = GetNativeString(env,aclStringUTF);
! 
!     if(aclString == NULL) {
!       fprintf(stderr, "ERROR: ACL::setACLString -> failed to get aclString\n");
!       (*env)->ReleaseStringUTFChars(env, pathUTF, path);
!       throwMessageException( env, "aclString == NULL" ); 
!       return;
      }
  
      if (!setACL(path, aclString)) {
!       throwAFSException( env, errno );
      }
  
!     /*(*env)->ReleaseStringUTFChars(env, pathUTF, path);
!       (*env)->ReleaseStringUTFChars(env, aclStringUTF, aclString);*/
! 
      free(path);
      free(aclString);
  }
+ 
+ 
+ 
Index: openafs/src/JAVA/libjafs/AdminToken.c
diff -c openafs/src/JAVA/libjafs/AdminToken.c:1.3 openafs/src/JAVA/libjafs/AdminToken.c:1.3.2.1
*** openafs/src/JAVA/libjafs/AdminToken.c:1.3	Tue Jul 15 19:11:26 2003
--- openafs/src/JAVA/libjafs/AdminToken.c	Fri Oct 14 22:14:11 2005
***************
*** 38,51 ****
   * env      the Java environment
   * obj      the current Java object
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Token_initializeAdminClient(JNIEnv * env, jclass cls)
  {
!     afs_status_t ast;
!     if (!afsclient_Init(&ast)) {
! 	throwAFSException(env, ast);
! 	return;
!     }
  }
  
  
--- 38,51 ----
   * env      the Java environment
   * obj      the current Java object
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Token_initializeAdminClient(JNIEnv *env, jclass cls)
  {
!   afs_status_t ast;
!   if( !afsclient_Init( &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  }
  
  
***************
*** 60,132 ****
   * jpassword    the password of the user
   * returns a token representing the authentication
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Token_getToken(JNIEnv * env, jobject obj,
! 				     jstring jcellName, jstring juserName,
! 				     jstring jpassword)
! {
!     afs_status_t ast;
!     char *cellName;
!     char *userName;
!     char *password;
!     void *tokenHandle;
!     int rc;
! 
!     // convert java strings
!     if (jcellName != NULL) {
! 	cellName = getNativeString(env, jcellName);
! 	if (!cellName) {
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return 0;
! 	}
!     } else {
! 	cellName = NULL;
!     }
! 
!     if (juserName != NULL) {
! 	userName = getNativeString(env, juserName);
! 	if (!userName) {
! 	    if (cellName != NULL)
! 		free(cellName);
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return 0;
! 	}
!     } else {
! 	if (cellName != NULL)
! 	    free(cellName);
! 	throwAFSException(env, JAFSNULLUSER);
! 	return 0;
!     }
! 
!     if (jpassword != NULL) {
! 	password = getNativeString(env, jpassword);
! 	if (!password) {
! 	    if (cellName != NULL)
! 		free(cellName);
! 	    free(userName);
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return 0;
! 	}
!     } else {
! 	if (cellName != NULL)
! 	    free(cellName);
! 	free(userName);
! 	throwAFSException(env, JAFSNULLPASS);
! 	return 0;
!     }
  
!     if (!
! 	(afsclient_TokenGetNew
! 	 (cellName, userName, password, &tokenHandle, &ast))) {
! 	throwAFSException(env, ast);
!     }
! 
!     if (cellName != NULL)
! 	free(cellName);
!     free(userName);
!     free(password);
! 
!     return (jint) tokenHandle;
  }
  
  /**
--- 60,134 ----
   * jpassword    the password of the user
   * returns a token representing the authentication
   */
! JNIEXPORT jlong JNICALL 
! Java_org_openafs_jafs_Token_getToken
!   (JNIEnv *env, jobject obj, jstring jcellName, jstring juserName,
!    jstring jpassword)
! {
!   afs_status_t ast;
!   const char *cellName;
!   const char *userName;
!   const char *password;
!   void *tokenHandle;
!   int rc;
! 
!   // convert java strings
!   if( jcellName != NULL ) { 
!       cellName = (*env)->GetStringUTFChars(env, jcellName, 0);
!       if( !cellName ) {
! 	  throwAFSException( env, JAFSADMNOMEM );
! 	  return 0;    
!       }
!   } else {
!       cellName = NULL;
!   }
!   if( juserName != NULL ) {
!       userName = (*env)->GetStringUTFChars(env, juserName, 0);
!       if( !userName ) {
! 	  throwAFSException( env, JAFSADMNOMEM );
! 	  return 0;    
!       }
!   } else {
!       userName = NULL;
!   }
!   if( jpassword != NULL ) {
!       password = (*env)->GetStringUTFChars(env, jpassword, 0);
!       if( !password ) {
! 	  throwAFSException( env, JAFSADMNOMEM );
! 	  return 0;    
!       }
!   } else {
!       password = NULL;
!   }
! 
!   if ( !(afsclient_TokenGetNew( cellName, userName, password, &tokenHandle, 
! 				&ast) ) ) {
!     // release converted strings
!       if( cellName != NULL ) {
! 	  (*env)->ReleaseStringUTFChars(env, jcellName, cellName);
!       }
!       if( userName != NULL ) {
! 	  (*env)->ReleaseStringUTFChars(env, juserName, userName);
!       }
!       if( password != NULL ) {
! 	  (*env)->ReleaseStringUTFChars(env, jpassword, password);
!       }
!       throwAFSException( env, ast );
!       return 0;
!   }
! 
!   // release converted strings
!   if( cellName != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jcellName, cellName);
!   }
!   if( userName != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, juserName, userName);
!   }
!   if( password != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jpassword, password);
!   }
  
!   return (jlong) tokenHandle;
  }
  
  /**
***************
*** 136,149 ****
   * obj      the current Java object
   * tokenHandle   the token to close
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Token_close(JNIEnv * env, jobject obj, jint tokenHandle)
  {
      afs_status_t ast;
  
!     if (!afsclient_TokenClose((void *)tokenHandle, &ast)) {
! 	throwAFSException(env, ast);
! 	return;
      }
  }
  
--- 138,152 ----
   * obj      the current Java object
   * tokenHandle   the token to close
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Token_close
!   (JNIEnv *env, jobject obj, jlong tokenHandle)
  {
      afs_status_t ast;
  
!     if( !afsclient_TokenClose( (void *) tokenHandle, &ast ) ) {
!       throwAFSException( env, ast );
!       return;
      }
  }
  
***************
*** 158,189 ****
   * tokenHandle    a token handle previously returned by a call to getToken
   * returns a handle to the open cell
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Cell_getCellHandle(JNIEnv * env, jobject obj,
! 					 jstring jcellName, jint tokenHandle)
! {
!     afs_status_t ast;
!     char *cellName;
!     void *cellHandle;
! 
!     if (jcellName != NULL) {
! 	cellName = getNativeString(env, jcellName);
! 	if (!cellName) {
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return -1;
! 	}
!     } else {
! 	throwAFSException(env, JAFSNULLCELL);
! 	return -1;
!     }
  
!     if (!afsclient_CellOpen(cellName, (void *)tokenHandle, &cellHandle, &ast)) {
! 	throwAFSException(env, ast);
!     }
! 
!     free(cellName);
! 
!     return (jint) cellHandle;
  }
  
  /**
--- 161,198 ----
   * tokenHandle    a token handle previously returned by a call to getToken
   * returns a handle to the open cell
   */
! JNIEXPORT jlong JNICALL 
! Java_org_openafs_jafs_Cell_getCellHandle
!   (JNIEnv *env, jobject obj, jstring jcellName, jlong tokenHandle)
! {
!   afs_status_t ast;
!   const char *cellName;
!   void *cellHandle;
! 
!   if( jcellName != NULL ) {
!     cellName = (*env)->GetStringUTFChars(env, jcellName, 0);
!     if( !cellName ) {
! 	throwAFSException( env, JAFSADMNOMEM );
! 	return;    
!     }
!   } else {
!     cellName = NULL;
!   }
! 
!   if( !afsclient_CellOpen( cellName, (void *) tokenHandle, 
! 			   &cellHandle, &ast ) ) {
!     if( cellName != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jcellName, cellName);
!     }  
!     throwAFSException( env, ast );
!     return;
!   }
! 
!   if( cellName != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jcellName, cellName);
!   }  
  
!   return (jlong) cellHandle;
  }
  
  /**
***************
*** 193,208 ****
   * obj      the current Java object
   * cellHandle   the cell handle to close
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Cell_closeCell(JNIEnv * env, jobject obj,
! 				     jint cellHandle)
  {
-     afs_status_t ast;
  
!     if (!afsclient_CellClose((void *)cellHandle, &ast)) {
! 	throwAFSException(env, ast);
! 	return;
      }
  }
  
  /**
--- 202,219 ----
   * obj      the current Java object
   * cellHandle   the cell handle to close
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Cell_closeCell (JNIEnv *env, jobject obj, 
!                                          jlong cellHandle)
  {
  
!    afs_status_t ast;
! 
!     if( !afsclient_CellClose( (void *) cellHandle, &ast ) ) {
!       throwAFSException( env, ast );
!       return;
      }
+ 
  }
  
  /**
***************
*** 218,251 ****
   *                      a vos handle
   * returns a vos handle to the server
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Server_getVosServerHandle(JNIEnv * env, jobject obj,
! 						jint cellHandle,
! 						jstring jserverName)
! {
!     afs_status_t ast;
!     void *serverHandle;
!     char *serverName;
  
!     if (jserverName != NULL) {
! 	serverName = getNativeString(env, jserverName);
! 	if (!serverName) {
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return -1;
! 	}
!     } else {
! 	throwAFSException(env, JAFSNULLSERVER);
! 	return -1;
!     }
! 
!     if (!vos_ServerOpen
! 	((void *)cellHandle, serverName, (void **)&serverHandle, &ast)) {
! 	throwAFSException(env, ast);
!     }
!     // release converted string
!     free(serverName);
! 
!     return (jint) serverHandle;
  }
  
  /**
--- 229,268 ----
   *                      a vos handle
   * returns a vos handle to the server
   */
! JNIEXPORT jlong JNICALL 
! Java_org_openafs_jafs_Server_getVosServerHandle
!   (JNIEnv *env, jobject obj, jlong cellHandle, jstring jserverName)
! {
!   afs_status_t ast;
!   void *serverHandle;
!   // convert java string
!   const char *serverName;
! 
!   if( jserverName != NULL ) {
!       serverName = (*env)->GetStringUTFChars(env, jserverName, 0);
!       if( !serverName ) {
! 	  throwAFSException( env, JAFSADMNOMEM );
! 	  return;    
!       }
!   } else {
!       serverName = NULL;
!   }
! 
!   if( !vos_ServerOpen( (void *) cellHandle, serverName, 
! 		       (void **) &serverHandle, &ast ) ) {
!       if( serverName != NULL ) {
! 	  (*env)->ReleaseStringUTFChars(env, jserverName, serverName);
!       }
!       throwAFSException( env, ast );
!       return 0;
!   }
! 
!   // release converted string
!   if( serverName != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jserverName, serverName);
!   }
  
!   return (jlong) serverHandle;
  }
  
  /**
***************
*** 255,269 ****
   * obj      the current Java object
   * vosServerHandle   the vos server handle to close
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Server_closeVosServerHandle(JNIEnv * env, jobject obj,
! 						  jint vosServerHandle)
  {
      afs_status_t ast;
  
!     if (!vos_ServerClose((void *)vosServerHandle, &ast)) {
! 	throwAFSException(env, ast);
! 	return;
      }
  }
  
--- 272,286 ----
   * obj      the current Java object
   * vosServerHandle   the vos server handle to close
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Server_closeVosServerHandle
!   (JNIEnv *env, jobject obj, jlong vosServerHandle)
  {
      afs_status_t ast;
  
!     if( !vos_ServerClose( (void *) vosServerHandle, &ast ) ) {
!       throwAFSException( env, ast );
!       return;
      }
  }
  
***************
*** 280,313 ****
   *                      a bos handle
   * returns a bos handle to the server
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Server_getBosServerHandle(JNIEnv * env, jobject obj,
! 						jint cellHandle,
! 						jstring jserverName)
! {
!     afs_status_t ast;
!     void *serverHandle;
!     char *serverName;
! 
!     if (jserverName != NULL) {
! 	serverName = getNativeString(env, jserverName);
! 	if (!serverName) {
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	throwAFSException(env, JAFSNULLSERVER);
! 	return;
!     }
  
!     if (!bos_ServerOpen
! 	((void *)cellHandle, serverName, (void **)&serverHandle, &ast)) {
! 	throwAFSException(env, ast);
!     }
!     // release converted string
!     free(serverName);
! 
!     return (jint) serverHandle;
  }
  
  /**
--- 297,336 ----
   *                      a bos handle
   * returns a bos handle to the server
   */
! JNIEXPORT jlong JNICALL 
! Java_org_openafs_jafs_Server_getBosServerHandle
!   (JNIEnv *env, jobject obj, jlong cellHandle, jstring jserverName)
! {
!   afs_status_t ast;
!   void *serverHandle;
!   // convert java string
!   const char *serverName;
! 
!   if( jserverName != NULL ) {
!       serverName = (*env)->GetStringUTFChars(env, jserverName, 0);
!       if( !serverName ) {
! 	  throwAFSException( env, JAFSADMNOMEM );
! 	  return;    
!       }
!   } else {
!       serverName = NULL;
!   }
! 
!   if( !bos_ServerOpen( (void *) cellHandle, serverName, 
! 		       (void **) &serverHandle, &ast ) ) {
!       if( serverName != NULL ) {
! 	  (*env)->ReleaseStringUTFChars(env, jserverName, serverName);
!       }
!       throwAFSException( env, ast );
!       return 0;
!   }
! 
!   // release converted string
!   if( serverName != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jserverName, serverName);
!   }
  
!   return (jlong) serverHandle;
  }
  
  /**
***************
*** 317,331 ****
   * obj      the current Java object
   * bosServerHandle   the bos server handle to close
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Server_closeBosServerHandle(JNIEnv * env, jobject obj,
! 						  jint bosServerHandle)
  {
      afs_status_t ast;
  
!     if (!bos_ServerClose((void *)bosServerHandle, &ast)) {
! 	throwAFSException(env, ast);
! 	return;
      }
  }
  
--- 340,354 ----
   * obj      the current Java object
   * bosServerHandle   the bos server handle to close
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Server_closeBosServerHandle
!   (JNIEnv *env, jobject obj, jlong bosServerHandle)
  {
      afs_status_t ast;
  
!     if( !bos_ServerClose( (void *) bosServerHandle, &ast ) ) {
!       throwAFSException( env, ast );
!       return;
      }
  }
  
***************
*** 339,383 ****
   *                       to getToken
   * returns a long representing the UTC time for the token expiration
   */
! JNIEXPORT jlong JNICALL
! Java_org_openafs_jafs_Token_getExpiration(JNIEnv * env, jobject obj,
! 					  jint tokenHandle)
  {
      afs_status_t ast;
      unsigned long expTime;
!     char *prince = malloc(sizeof(char) * KAS_MAX_NAME_LEN);
!     char *inst = malloc(sizeof(char) * KAS_MAX_NAME_LEN);
!     char *cell = malloc(sizeof(char) * AFS_MAX_SERVER_NAME_LEN);
      int hkt;
  
!     if (!prince || !inst || !cell) {
! 	if (prince) {
! 	    free(prince);
! 	}
! 	if (inst) {
! 	    free(inst);
! 	}
! 	if (cell) {
! 	    free(cell);
! 	}
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return;
!     }
! 
!     if (!afsclient_TokenQuery
! 	((void *)tokenHandle, &expTime, prince, inst, cell, &hkt, &ast)) {
! 	throwAFSException(env, ast);
      }
  
!     free(prince);
!     free(inst);
!     free(cell);
  
      return (jlong) expTime;
  }
  
  // reclaim global memory used by this portion
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Token_reclaimAuthMemory(JNIEnv * env, jclass cls)
  {
  }
--- 362,416 ----
   *                       to getToken
   * returns a long representing the UTC time for the token expiration
   */
! JNIEXPORT jlong JNICALL 
! Java_org_openafs_jafs_Token_getExpiration
!   (JNIEnv *env, jobject obj, jlong tokenHandle)
  {
      afs_status_t ast;
      unsigned long expTime;
!     char *prince = malloc( sizeof(char)*KAS_MAX_NAME_LEN ); 
!     char *inst = malloc( sizeof(char)*KAS_MAX_NAME_LEN );    
!     char *cell = malloc( sizeof(char)*AFS_MAX_SERVER_NAME_LEN );    
      int hkt;
  
!     if( !prince || !inst || !cell ) {
!       if( prince ) {
!         free( prince );
!       }
!       if( inst ) {
!         free( inst );
!       }
!       if( cell ) {
!         free( cell );
!       }
!       throwAFSException( env, JAFSADMNOMEM );
!       return;    
!     }
! 
!     if( !afsclient_TokenQuery( (void *) tokenHandle, &expTime, prince, inst, 
! 			       cell, &hkt, &ast ) ) {
! 	free( prince );
! 	free( inst );
! 	free( cell );
! 	throwAFSException( env, ast );
! 	return 0;
      }
  
!     free( prince );
!     free( inst );
!     free( cell );
  
      return (jlong) expTime;
  }
  
  // reclaim global memory used by this portion
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Token_reclaimAuthMemory (JNIEnv *env, jclass cls)
  {
  }
+ 
+ 
+ 
+ 
+ 
+ 
Index: openafs/src/JAVA/libjafs/Cell.c
diff -c openafs/src/JAVA/libjafs/Cell.c:1.3 openafs/src/JAVA/libjafs/Cell.c:1.3.2.1
*** openafs/src/JAVA/libjafs/Cell.c:1.3	Tue Jul 15 19:11:26 2003
--- openafs/src/JAVA/libjafs/Cell.c	Fri Oct 14 22:14:11 2005
***************
*** 33,41 ****
  #include <afs_AdminClientErrors.h>
  #include <afs_AdminCommonErrors.h>
  
! /*-----------------------------------------------------------------------
!  * Definitions in Internal.c
!  */
  extern jclass userCls;
  //extern jfieldID user_cellHandleField;
  extern jfieldID user_nameField;
--- 33,40 ----
  #include <afs_AdminClientErrors.h>
  #include <afs_AdminCommonErrors.h>
  
! //// definitions in Internal.c  //////////////////
! 
  extern jclass userCls;
  //extern jfieldID user_cellHandleField;
  extern jfieldID user_nameField;
***************
*** 50,75 ****
  //extern jfieldID server_cellHandleField;
  extern jfieldID server_cachedInfoField;
  
! /*-----------------------------------------------------------------------
!  * Definition in User.c
!  */
! extern void getUserInfoChar(JNIEnv * env, int cellHandle, const char *name,
! 			    jobject user);
  
! /*-----------------------------------------------------------------------
!  * Definition in Group.c
!  */
! extern void getGroupInfoChar(JNIEnv * env, int cellHandle, const char *name,
! 			     jobject group);
  
! /*-----------------------------------------------------------------------
!  * Definition in Server.c
!  */
! extern void fillServerInfo(JNIEnv * env, jint cellHandle, jobject server,
! 			   afs_serverEntry_t servEntry);
  
  
! /*-----------------------------------------------------------------------*/
  
  /**
   * Returns the total number of KAS users belonging to the cell denoted
--- 49,76 ----
  //extern jfieldID server_cellHandleField;
  extern jfieldID server_cachedInfoField;
  
! //////////////////////////////////////////////////////////
  
! ///// definition in jafs_User.c /////////////////
  
! extern void getUserInfoChar (JNIEnv *env, void *cellHandle, const char *name, 
! 			     jobject user);
! 
! ///////////////////////////////////////////////////
! 
! ///// definition in jafs_Group.c /////////////////
! 
! extern void getGroupInfoChar (JNIEnv *env, void *cellHandle, const char *name, 
! 			      jobject group);
! 
! ///////////////////////////////////////////////////
! 
! ///// definition in jafs_Server.c /////////////////
  
+ extern void fillServerInfo (JNIEnv *env, void *cellHandle, jobject server, 
+ 			    afs_serverEntry_t servEntry);
  
! ///////////////////////////////////////////////////
  
  /**
   * Returns the total number of KAS users belonging to the cell denoted
***************
*** 80,108 ****
   *  cellHandle    the handle of the cell to which the users belong
   *  returns total count of KAS users
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Cell_getKasUserCount(JNIEnv * env, jclass cls,
! 					   jint cellHandle)
! {
!     afs_status_t ast;
!     void *iterationId;
!     kas_identity_t who;
!     int i = 0;
! 
!     if (!kas_PrincipalGetBegin((void *)cellHandle, NULL, &iterationId, &ast)) {
! 	throwAFSException(env, ast);
! 	return -1;
!     }
  
!     while (kas_PrincipalGetNext((void *)iterationId, &who, &ast))
! 	i++;
! 
!     if (ast != ADMITERATORDONE) {
! 	throwAFSException(env, ast);
! 	return -1;
!     }
! 
!     return i;
  }
  
  
--- 81,109 ----
   *  cellHandle    the handle of the cell to which the users belong
   *  returns total count of KAS users
   */
! JNIEXPORT jint JNICALL 
! Java_org_openafs_jafs_Cell_getKasUserCount (JNIEnv *env, jclass cls, 
! 					       jlong cellHandle) {
! 
!   afs_status_t ast;
!   void *iterationId;
!   kas_identity_t who;
!   int i = 0;
! 
!   if( !kas_PrincipalGetBegin( (void *) cellHandle, NULL, 
! 			      &iterationId, &ast ) ) {
!     throwAFSException( env, ast );
!     return -1;
!   }
! 
!   while ( kas_PrincipalGetNext( iterationId, &who, &ast ) ) i++;
! 
!   if( ast != ADMITERATORDONE ) {
!     throwAFSException( env, ast );
!     return -1;
!   }
  
!   return i;
  }
  
  
***************
*** 117,135 ****
   *  cellHandle    the handle of the cell to which the users belong
   *  returns an iteration ID
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Cell_getKasUsersBegin(JNIEnv * env, jclass cls,
! 					    jint cellHandle)
! {
!     afs_status_t ast;
!     void *iterationId;
  
!     if (!kas_PrincipalGetBegin((void *)cellHandle, NULL, &iterationId, &ast)) {
! 	throwAFSException(env, ast);
! 	return;
!     }
  
-     return (jint) iterationId;
  }
  
  /**
--- 118,138 ----
   *  cellHandle    the handle of the cell to which the users belong
   *  returns an iteration ID
   */
! JNIEXPORT jlong JNICALL 
! Java_org_openafs_jafs_Cell_getKasUsersBegin (JNIEnv *env, jclass cls, 
! 						jlong cellHandle) {
! 
!   afs_status_t ast;
!   void *iterationId;
! 
!   if( !kas_PrincipalGetBegin( (void *) cellHandle, NULL, &iterationId, 
! 			      &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
!   return (jlong) iterationId;
  
  }
  
  /**
***************
*** 145,177 ****
   *  startIndex    the starting base-zero index
   *  returns an iteration ID
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Cell_getKasUsersBeginAt(JNIEnv * env, jclass cls,
! 					      jint cellHandle,
! 					      jint startIndex)
! {
!     afs_status_t ast;
!     void *iterationId;
!     kas_identity_t who;
!     int i;
! 
!     if (!kas_PrincipalGetBegin((void *)cellHandle, NULL, &iterationId, &ast)) {
! 	throwAFSException(env, ast);
! 	return;
      }
  
!     for (i = 1; i < startIndex; i++) {
! 	if (!kas_PrincipalGetNext((void *)iterationId, &who, &ast)) {
! 	    if (ast == ADMITERATORDONE) {
! 		return 0;
! 	    } else {
! 		throwAFSException(env, ast);
! 		return 0;
! 	    }
! 	}
!     }
  
-     return (jint) iterationId;
  }
  
  /**
--- 148,182 ----
   *  startIndex    the starting base-zero index
   *  returns an iteration ID
   */
! JNIEXPORT jlong JNICALL 
! Java_org_openafs_jafs_Cell_getKasUsersBeginAt (JNIEnv *env, jclass cls, 
! 						  jlong cellHandle, 
! 						  jint startIndex) {
! 
!   afs_status_t ast;
!   void *iterationId;
!   kas_identity_t who;
!   int i;
! 
!   if( !kas_PrincipalGetBegin( (void *) cellHandle, NULL, 
! 			      &iterationId, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
! 
!   for ( i = 1; i < startIndex; i++) {
!     if( !kas_PrincipalGetNext( (void *) iterationId, &who, &ast ) ) {
!       if( ast == ADMITERATORDONE ) {
!         return 0;
!       } else {
!         throwAFSException( env, ast );
!         return 0;
!       }
      }
+   }
  
!   return (jlong) iterationId;
  
  }
  
  /**
***************
*** 184,226 ****
   *  iterationId   the iteration ID of this iteration
   *  returns the name of the next user of the cell
   */
! JNIEXPORT jstring JNICALL
! Java_org_openafs_jafs_Cell_getKasUsersNextString(JNIEnv * env, jclass cls,
! 						 jint iterationId)
! {
!     afs_status_t ast;
!     kas_identity_t who;
!     jstring juser;
  
!     if (!kas_PrincipalGetNext((void *)iterationId, &who, &ast)) {
! 	if (ast == ADMITERATORDONE) {
! 	    return NULL;
! 	    // other
! 	} else {
! 	    throwAFSException(env, ast);
! 	    return;
! 	}
!     }
! 
!     if (strcmp(who.instance, "")) {
! 	char *fullName = (char *)malloc(sizeof(char) * (strlen(who.principal)
! 							+ strlen(who.instance)
! 							+ 2));
! 	if (!fullName) {
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
! 	*fullName = '\0';
! 	strcat(fullName, who.principal);
! 	strcat(fullName, ".");
! 	strcat(fullName, who.instance);
! 	juser = (*env)->NewStringUTF(env, fullName);
! 	free(fullName);
      } else {
! 	juser = (*env)->NewStringUTF(env, who.principal);
!     }
  
!     return juser;
  
  }
  
--- 189,231 ----
   *  iterationId   the iteration ID of this iteration
   *  returns the name of the next user of the cell
   */
! JNIEXPORT jstring JNICALL 
! Java_org_openafs_jafs_Cell_getKasUsersNextString (JNIEnv *env, jclass cls, 
! 						     jlong iterationId) {
! 
!   afs_status_t ast;
!   kas_identity_t who;
!   jstring juser;
  
!   if( !kas_PrincipalGetNext( (void *) iterationId, &who, &ast ) ) {
!     if( ast == ADMITERATORDONE ) {
! 	return NULL;
!     // other
      } else {
!       throwAFSException( env, ast );
!       return;
!     }    
!   }
! 
!   if( strcmp( who.instance, "" ) ) {
!     char *fullName = (char *) malloc( sizeof(char)*( strlen( who.principal ) 
! 						     + strlen( who.instance ) 
! 						     + 2 ) );
!     if( !fullName ) {
!       throwAFSException( env, JAFSADMNOMEM );
!       return;    
!     }
!     *fullName = '\0';
!     strcat( fullName, who.principal );
!     strcat( fullName, "." );
!     strcat( fullName, who.instance );
!     juser = (*env)->NewStringUTF(env, fullName );
!     free( fullName );
!   } else {
!     juser = (*env)->NewStringUTF(env, who.principal);
!   }
  
!   return juser;
  
  }
  
***************
*** 236,296 ****
   *                  the next kas user
   *  returns 0 if there are no more users, != 0 otherwise
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Cell_getKasUsersNext(JNIEnv * env, jclass cls,
! 					   jint cellHandle, jint iterationId,
! 					   jobject juserObject)
! {
! 
!     afs_status_t ast;
!     kas_identity_t who;
!     jstring juser;
!     char *fullName = NULL;
! 
! 
!     if (!kas_PrincipalGetNext((void *)iterationId, &who, &ast)) {
! 	if (ast == ADMITERATORDONE) {
! 	    return 0;
! 	    // other
! 	} else {
! 	    throwAFSException(env, ast);
! 	    return 0;
! 	}
!     }
!     // take care of the instance stuff(by concatenating with a period in between)
!     if (strcmp(who.instance, "")) {
! 	fullName =
! 	    (char *)malloc(sizeof(char) *
! 			   (strlen(who.principal) + strlen(who.instance) +
! 			    2));
! 	if (!fullName) {
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
! 	*fullName = '\0';
! 	strcat(fullName, who.principal);
! 	strcat(fullName, ".");
! 	strcat(fullName, who.instance);
! 	juser = (*env)->NewStringUTF(env, fullName);
!     } else {
! 	juser = (*env)->NewStringUTF(env, who.principal);
!     }
! 
!     if (userCls == 0) {
! 	internal_getUserClass(env, juserObject);
!     }
  
-     (*env)->SetObjectField(env, juserObject, user_nameField, juser);
  
!     if (fullName != NULL) {
! 	getUserInfoChar(env, (int)cellHandle, fullName, juserObject);
! 	free(fullName);
      } else {
! 	getUserInfoChar(env, (int)cellHandle, who.principal, juserObject);
!     }
!     (*env)->SetBooleanField(env, juserObject, user_cachedInfoField, TRUE);
  
!     return 1;
  
  }
  
--- 241,300 ----
   *                  the next kas user
   *  returns 0 if there are no more users, != 0 otherwise
   */
! JNIEXPORT jint JNICALL 
! Java_org_openafs_jafs_Cell_getKasUsersNext (JNIEnv *env, jclass cls, 
! 					       jlong cellHandle, 
! 					       jlong iterationId, 
! 					       jobject juserObject) {
! 
!   afs_status_t ast;
!   kas_identity_t who;
!   jstring juser;
!   char *fullName = NULL;
  
  
!   if( !kas_PrincipalGetNext( (void *) iterationId, &who, &ast ) ) {
!     if( ast == ADMITERATORDONE ) {
! 	return 0;
!     // other
      } else {
!       throwAFSException( env, ast );
!       return 0;
!     }    
!   }
! 
!   // take care of the instance stuff(by concatenating with a period in between)
!   if( strcmp( who.instance, "" ) ) {
!     fullName = (char *) malloc( sizeof(char)*( strlen( who.principal ) + 
! 					       strlen( who.instance ) + 2 ) );
!     if( !fullName ) {
!       throwAFSException( env, JAFSADMNOMEM );
!       return 0;    
!     }
!     *fullName = '\0';
!     strcat( fullName, who.principal );
!     strcat( fullName, "." );
!     strcat( fullName, who.instance );
!     juser = (*env)->NewStringUTF(env, fullName );
!   } else {
!     juser = (*env)->NewStringUTF(env, who.principal);
!   }
! 
!   if( userCls == 0 ) {
!     internal_getUserClass( env, juserObject );
!   }
! 
!   (*env)->SetObjectField(env, juserObject, user_nameField, juser);
! 
!   if( fullName != NULL ) { 
!       getUserInfoChar( env, (void *) cellHandle, fullName, juserObject );
!       free( fullName );
!   } else {
!       getUserInfoChar( env, (void *) cellHandle, who.principal, juserObject );
!   }
!   (*env)->SetBooleanField( env, juserObject, user_cachedInfoField, TRUE );
  
!   return 1;
  
  }
  
***************
*** 301,316 ****
   *  cls      the current Java class
   *  iterationId   the iteration ID of this iteration
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Cell_getKasUsersDone(JNIEnv * env, jclass cls,
! 					   jint iterationId)
! {
!     afs_status_t ast;
! 
!     if (!kas_PrincipalGetDone((void *)iterationId, &ast)) {
! 	throwAFSException(env, ast);
! 	return;
!     }
  
  }
  
--- 305,320 ----
   *  cls      the current Java class
   *  iterationId   the iteration ID of this iteration
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Cell_getKasUsersDone (JNIEnv *env, jclass cls, 
! 					       jlong iterationId) {
! 
!   afs_status_t ast;
! 
!   if( !kas_PrincipalGetDone( (void *) iterationId, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
  }
  
***************
*** 322,344 ****
   *  cellHandle    the handle of the cell to which the user belongs
   *  returns the name of the cell
   */
! JNIEXPORT jstring JNICALL
! Java_org_openafs_jafs_Cell_getCellName(JNIEnv * env, jclass cls,
! 				       jint cellHandle)
! {
!     afs_status_t ast;
!     char *cellName;
!     jstring jcellName;
! 
!     if (!afsclient_CellNameGet
! 	((void *)cellHandle, (const char **)&cellName, &ast)) {
! 	throwAFSException(env, ast);
! 	return;
!     }
! 
!     jcellName = (*env)->NewStringUTF(env, cellName);
  
!     return jcellName;
  
  }
  
--- 326,348 ----
   *  cellHandle    the handle of the cell to which the user belongs
   *  returns the name of the cell
   */
! JNIEXPORT jstring JNICALL 
! Java_org_openafs_jafs_Cell_getCellName (JNIEnv *env, jclass cls, 
! 					   jlong cellHandle) {
! 
!   afs_status_t ast;
!   char *cellName;
!   jstring jcellName;
! 
!   if( !afsclient_CellNameGet( (void *) cellHandle, 
! 			      (const char **) &cellName, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
!   
!   jcellName = (*env)->NewStringUTF(env, cellName);
  
!   return jcellName;
  
  }
  
***************
*** 351,388 ****
   *  cellHandle    the handle of the cell to which the users belong
   *  returns total number of PTS users
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Cell_getPtsUserCount(JNIEnv * env, jclass cls,
! 					   jint cellHandle)
! {
!     afs_status_t ast;
!     void *iterationId;
!     char *userName;
!     int i = 0;
  
!     if (!pts_UserListBegin((void *)cellHandle, &iterationId, &ast)) {
! 	throwAFSException(env, ast);
! 	return -1;
!     }
  
!     userName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN);
  
!     if (!userName) {
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return -1;
!     }
  
!     while (pts_UserListNext((void *)iterationId, userName, &ast))
! 	i++;
  
!     free(userName);
  
!     if (ast != ADMITERATORDONE) {
! 	throwAFSException(env, ast);
! 	return -1;
!     }
  
!     return i;
  }
  
  /**
--- 355,391 ----
   *  cellHandle    the handle of the cell to which the users belong
   *  returns total number of PTS users
   */
! JNIEXPORT jint JNICALL 
! Java_org_openafs_jafs_Cell_getPtsUserCount (JNIEnv *env, jclass cls, 
! 					       jlong cellHandle) {
  
!   afs_status_t ast;
!   void *iterationId;
!   char *userName;
!   int i = 0;
  
!   if( !pts_UserListBegin( (void *) cellHandle, &iterationId, &ast ) ) {
!     throwAFSException( env, ast );
!     return -1;
!   }
  
!   userName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN);
  
!   if( !userName ) {
!     throwAFSException( env, JAFSADMNOMEM );
!     return -1;    
!   }
  
!   while ( pts_UserListNext( (void *) iterationId, userName, &ast ) ) i++;
  
!   free( userName );
  
!   if( ast != ADMITERATORDONE ) {
!     throwAFSException( env, ast );
!     return -1;
!   }
! 
!   return i;
  }
  
  /**
***************
*** 394,454 ****
   *  cellHandle    the handle of the cell to which the users belong
   *  returns total number of users that are in PTS and not KAS
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Cell_getPtsOnlyUserCount(JNIEnv * env, jclass cls,
! 					       jint cellHandle)
! {
!     afs_status_t ast;
!     void *iterationId;
!     kas_identity_p who = (kas_identity_p) malloc(sizeof(kas_identity_t));
!     kas_principalEntry_t kasEntry;
!     char *userName;
!     int i = 0;
! 
!     if (who == NULL) {
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return -1;
!     }
! 
!     if (!pts_UserListBegin((void *)cellHandle, &iterationId, &ast)) {
! 	free(who);
! 	throwAFSException(env, ast);
! 	return -1;
!     }
! 
!     userName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN);
!     if (!userName) {
! 	free(who);
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return -1;
!     }
  
!     while (pts_UserListNext((void *)iterationId, userName, &ast)) {
! 	if (strcmp(userName, "anonymous") != 0) {
! 	    // make sure the name is within the allowed bounds
! 	    if (strlen(userName) > KAS_MAX_NAME_LEN) {
! 		free(who);
! 		free(userName);
! 		throwAFSException(env, ADMPTSUSERNAMETOOLONG);
! 		return -1;
! 	    }
! 	    // if there is a kas entry, recurse
! 	    internal_makeKasIdentity(userName, who);
! 	    if (!kas_PrincipalGet
! 		((void *)cellHandle, NULL, who, &kasEntry, &ast))
! 		i++;
! 	}
!     }
! 
!     free(userName);
!     free(who);
! 
!     if (ast != ADMITERATORDONE) {
! 	throwAFSException(env, ast);
! 	return -1;
!     }
! 
!     return i;
  }
  
  /**
--- 397,458 ----
   *  cellHandle    the handle of the cell to which the users belong
   *  returns total number of users that are in PTS and not KAS
   */
! JNIEXPORT jint JNICALL 
! Java_org_openafs_jafs_Cell_getPtsOnlyUserCount (JNIEnv *env, jclass cls, 
! 						   jlong cellHandle) {
! 
!   afs_status_t ast;
!   void *iterationId;
!   kas_identity_p who = (kas_identity_p) malloc( sizeof(kas_identity_t) );
!   kas_principalEntry_t kasEntry;
!   char *userName;
!   int i = 0;
! 
!   if( !who ) {
!     throwAFSException( env, JAFSADMNOMEM );
!     return -1;
!   }
! 
!   if( !pts_UserListBegin( (void *) cellHandle, &iterationId, &ast ) ) {
!     free( who );
!     throwAFSException( env, ast );
!     return -1;
!   }
! 
!   userName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN);
!     
!   if( !userName ) {
!     free( who );
!     throwAFSException( env, JAFSADMNOMEM );
!     return -1;
!   }
! 
!   while ( pts_UserListNext( (void *) iterationId, userName, &ast ) ) {
!     if( strcmp( userName, "anonymous" ) != 0 ) {
!       // make sure the name is within the allowed bounds
!       if( strlen( userName ) > KAS_MAX_NAME_LEN ) {
! 	    free( who );
! 	    free( userName );
! 	    throwAFSException( env, ADMPTSUSERNAMETOOLONG );
! 	    return -1;
! 	  }
!   
!       // if there is a kas entry, recurse
!       internal_makeKasIdentity( userName, who );
!       if( !kas_PrincipalGet( (void *) cellHandle, NULL, who, 
! 			     &kasEntry, &ast ) ) i++;
! 	}
!   }
! 
!   free( userName );
!   free( who );
! 
!   if( ast != ADMITERATORDONE ) {
!     throwAFSException( env, ast );
!     return -1;
!   }
  
!   return i;
  }
  
  /**
***************
*** 462,480 ****
   *  cellHandle    the handle of the cell to which the users belong
   *  returns an iteration ID
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Cell_getPtsUsersBegin(JNIEnv * env, jclass cls,
! 					    jint cellHandle)
! {
!     afs_status_t ast;
!     void *iterationId;
  
!     if (!pts_UserListBegin((void *)cellHandle, &iterationId, &ast)) {
! 	throwAFSException(env, ast);
! 	return -1;
!     }
! 
!     return (jint) iterationId;
  
  }
  
--- 466,484 ----
   *  cellHandle    the handle of the cell to which the users belong
   *  returns an iteration ID
   */
! JNIEXPORT jlong JNICALL 
! Java_org_openafs_jafs_Cell_getPtsUsersBegin (JNIEnv *env, jclass cls, 
! 						jlong cellHandle) {
! 
!   afs_status_t ast;
!   void *iterationId;
! 
!   if( !pts_UserListBegin( (void *) cellHandle, &iterationId, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
!   return (jlong) iterationId;
  
  }
  
***************
*** 487,526 ****
   *  iterationId   the iteration ID of this iteration
   *  returns the name of the next user of the cell
   */
! JNIEXPORT jstring JNICALL
! Java_org_openafs_jafs_Cell_getPtsUsersNextString(JNIEnv * env, jclass cls,
! 						 jint iterationId)
! {
!     afs_status_t ast;
!     char *userName;
!     jstring juser;
! 
!     userName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN);
! 
!     if (!userName) {
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return NULL;
!     }
! 
!     if (!pts_UserListNext((void *)iterationId, userName, &ast)) {
! 	free(userName);
! 	if (ast == ADMITERATORDONE) {
! 	    return NULL;
! 	} else {
! 	    throwAFSException(env, ast);
! 	    return NULL;
! 	}
!     }
! 
!     if (strcmp(userName, "anonymous") == 0) {
! 	free(userName);
! 	return Java_org_openafs_jafs_Cell_getPtsUsersNextString(env, cls,
! 								iterationId);
      }
  
!     juser = (*env)->NewStringUTF(env, userName);
!     free(userName);
!     return juser;
  
  }
  
--- 491,530 ----
   *  iterationId   the iteration ID of this iteration
   *  returns the name of the next user of the cell
   */
! JNIEXPORT jstring JNICALL 
! Java_org_openafs_jafs_Cell_getPtsUsersNextString (JNIEnv *env, jclass cls, 
! 						     jlong iterationId) {
! 
!   afs_status_t ast;
!   char *userName;
!   jstring juser;
! 
!   userName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN);
! 
!   if( !userName ) {
!     throwAFSException( env, JAFSADMNOMEM );
!     return;    
!   }
! 
!   if( !pts_UserListNext( (void *) iterationId, userName, &ast ) ) {
!     free( userName );
!     if( ast == ADMITERATORDONE ) {
!       return NULL;
!     } else {
!       throwAFSException( env, ast );
!       return;
      }
+   }
  
!   if( strcmp( userName, "anonymous" ) == 0 ) {
!     free( userName );
!     return Java_org_openafs_jafs_Cell_getPtsUsersNextString( env, cls, 
! 								iterationId );
!   }
! 
!   juser = (*env)->NewStringUTF(env, userName);
!   free( userName );
!   return juser;
  
  }
  
***************
*** 534,596 ****
   *  cellHandle   the cell handle to which these users will belong
   *  returns the name of the next pts user (not kas user) of the cell
   */
! JNIEXPORT jstring JNICALL
! Java_org_openafs_jafs_Cell_getPtsOnlyUsersNextString(JNIEnv * env, jclass cls,
! 						     jint iterationId,
! 						     jint cellHandle)
! {
!     kas_identity_p who = (kas_identity_p) malloc(sizeof(kas_identity_t));
      kas_principalEntry_t kasEntry;
      afs_status_t ast;
      char *userName;
      jstring juser;
  
!     if (!who) {
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return NULL;
      }
  
!     userName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN);
! 
!     if (!userName) {
! 	free(who);
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return NULL;
      }
  
!     while (1) {
  
! 	if (!pts_UserListNext((void *)iterationId, userName, &ast)) {
! 	    free(userName);
! 	    free(who);
! 	    if (ast == ADMITERATORDONE) {
  		return NULL;
  	    } else {
! 		throwAFSException(env, ast);
  		return NULL;
  	    }
  	}
  
! 	if (strcmp(userName, "anonymous") == 0) {
  	    continue;
  	}
  	// make sure the name is within the allowed bounds
! 	if (strlen(userName) > KAS_MAX_NAME_LEN) {
! 	    free(who);
! 	    free(userName);
! 	    throwAFSException(env, ADMPTSUSERNAMETOOLONG);
  	    return NULL;
  	}
  	// if there is a kas entry, recurse
! 	internal_makeKasIdentity(userName, who);
! 	if (kas_PrincipalGet((void *)cellHandle, NULL, who, &kasEntry, &ast)) {
  	    continue;
  	}
! 
  	juser = (*env)->NewStringUTF(env, userName);
! 	free(userName);
! 	free(who);
  	return juser;
      }
  
  }
--- 538,605 ----
   *  cellHandle   the cell handle to which these users will belong
   *  returns the name of the next pts user (not kas user) of the cell
   */
! JNIEXPORT jstring JNICALL 
! Java_org_openafs_jafs_Cell_getPtsOnlyUsersNextString (JNIEnv *env, 
! 							 jclass cls, 
! 							 jlong iterationId, 
! 							 jlong cellHandle) {
! 
!     kas_identity_p who = (kas_identity_p) malloc( sizeof(kas_identity_t) );
      kas_principalEntry_t kasEntry;
      afs_status_t ast;
      char *userName;
      jstring juser;
  
!     if( !who ) {
!       throwAFSException( env, JAFSADMNOMEM );
!       return;    
      }
  
!     userName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN);
!     
!     if( !userName ) {
!       free( who );
!       throwAFSException( env, JAFSADMNOMEM );
!       return;    
      }
  
!     while( 1 ) {
  
! 	if( !pts_UserListNext( (void *) iterationId, userName, &ast ) ) {
! 	    free( userName );
! 	    free( who );
! 	    if( ast == ADMITERATORDONE ) {
  		return NULL;
  	    } else {
! 		throwAFSException( env, ast );
  		return NULL;
  	    }
  	}
  
! 	if( strcmp( userName, "anonymous" ) == 0 ) {
  	    continue;
  	}
+ 	
  	// make sure the name is within the allowed bounds
! 	if( strlen( userName ) > KAS_MAX_NAME_LEN ) {
! 	    free( who );
! 	    free( userName );
! 	    throwAFSException( env, ADMPTSUSERNAMETOOLONG );
  	    return NULL;
  	}
+ 	
  	// if there is a kas entry, recurse
! 	internal_makeKasIdentity( userName, who );
! 	if( kas_PrincipalGet( (void *) cellHandle, NULL, who, 
! 			      &kasEntry, &ast ) ) {
  	    continue;
  	}
! 	
  	juser = (*env)->NewStringUTF(env, userName);
! 	free( userName );
! 	free( who );
  	return juser;
+ 
      }
  
  }
***************
*** 607,660 ****
   *                  the next pts user
   *  returns 0 if there are no more users, != 0 otherwise
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Cell_getPtsUsersNext(JNIEnv * env, jclass cls,
! 					   jint cellHandle, jint iterationId,
! 					   jobject juserObject)
! {
! 
!     afs_status_t ast;
!     char *userName;
!     jstring juser;
! 
!     userName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN);
! 
!     if (!userName) {
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return 0;
!     }
! 
!     if (!pts_UserListNext((void *)iterationId, userName, &ast)) {
! 	free(userName);
! 	if (ast == ADMITERATORDONE) {
! 	    return 0;
! 	} else {
! 	    throwAFSException(env, ast);
! 	    return 0;
! 	}
!     }
! 
!     if (strcmp(userName, "anonymous") == 0) {
! 	free(userName);
! 	return Java_org_openafs_jafs_Cell_getPtsUsersNext(env, cls,
! 							  cellHandle,
! 							  iterationId,
! 							  juserObject);
      }
  
!     juser = (*env)->NewStringUTF(env, userName);
  
!     if (userCls == 0) {
! 	internal_getUserClass(env, juserObject);
!     }
  
!     (*env)->SetObjectField(env, juserObject, user_nameField, juser);
  
!     getUserInfoChar(env, (int)cellHandle, userName, juserObject);
!     (*env)->SetBooleanField(env, juserObject, user_cachedInfoField, TRUE);
  
-     free(userName);
-     return 1;
  }
  
  /**
--- 616,670 ----
   *                  the next pts user
   *  returns 0 if there are no more users, != 0 otherwise
   */
! JNIEXPORT jint JNICALL 
! Java_org_openafs_jafs_Cell_getPtsUsersNext (JNIEnv *env, jclass cls, 
! 					       jlong cellHandle, 
! 					       jlong iterationId, 
! 					       jobject juserObject ) {
!     
!   afs_status_t ast;
!   char *userName;
!   jstring juser;
! 
!   userName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN);
! 
!   if( !userName ) {
!     throwAFSException( env, JAFSADMNOMEM );
!     return 0;    
!   }
! 
!   if( !pts_UserListNext( (void *) iterationId, userName, &ast ) ) {
!     free( userName );
!     if( ast == ADMITERATORDONE ) {
!       return 0;
!     } else {
!       throwAFSException( env, ast );
!       return 0;
      }
+   }
  
!   if( strcmp( userName, "anonymous" ) == 0 ) {
!     free( userName );
!     return Java_org_openafs_jafs_Cell_getPtsUsersNext( env, cls, 
! 							  cellHandle, 
! 							  iterationId, 
! 							  juserObject );
!   }
!   
!   juser = (*env)->NewStringUTF(env, userName);
! 
!   if( userCls == 0 ) {
!     internal_getUserClass( env, juserObject );
!   }
  
!   (*env)->SetObjectField(env, juserObject, user_nameField, juser);
  
!   getUserInfoChar( env, (void *) cellHandle, userName, juserObject );
!   (*env)->SetBooleanField( env, juserObject, user_cachedInfoField, TRUE );
  
!   free( userName );
!   return 1;
  
  }
  
  /**
***************
*** 669,743 ****
   *                  the next pts (with no kas) user
   *  returns 0 if there are no more users, != 0 otherwise
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Cell_getPtsOnlyUsersNext(JNIEnv * env, jclass cls,
! 					       jint cellHandle,
! 					       jint iterationId,
! 					       jobject juserObject)
! {
!     kas_identity_p who = (kas_identity_p) malloc(sizeof(kas_identity_t));
!     kas_principalEntry_t kasEntry;
!     afs_status_t ast;
!     char *userName;
!     jstring juser;
! 
!     if (!who) {
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return 0;
!     }
! 
!     userName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN);
! 
!     if (!userName) {
! 	free(who);
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return 0;
!     }
! 
!     while (1) {
! 
! 	if (!pts_UserListNext((void *)iterationId, userName, &ast)) {
! 	    free(userName);
! 	    free(who);
! 	    if (ast == ADMITERATORDONE) {
! 		return 0;
! 	    } else {
! 		throwAFSException(env, ast);
! 		return 0;
! 	    }
! 	}
! 
! 	if (strcmp(userName, "anonymous") == 0) {
! 	    continue;
! 	}
! 	// make sure the name is within the allowed bounds
! 	if (strlen(userName) > KAS_MAX_NAME_LEN) {
! 	    free(userName);
! 	    free(who);
! 	    throwAFSException(env, ADMPTSUSERNAMETOOLONG);
! 	    return 0;
! 	}
! 
! 	if (userCls == 0) {
! 	    internal_getUserClass(env, juserObject);
! 	}
! 	// if there is a kas entry, recurse
! 	internal_makeKasIdentity(userName, who);
! 	if (kas_PrincipalGet((void *)cellHandle, NULL, who, &kasEntry, &ast)) {
! 	    continue;
! 	}
! 
! 	juser = (*env)->NewStringUTF(env, userName);
! 
! 	(*env)->SetObjectField(env, juserObject, user_nameField, juser);
! 	getUserInfoChar(env, (int)cellHandle, userName, juserObject);
! 	(*env)->SetBooleanField(env, juserObject, user_cachedInfoField, TRUE);
! 
! 	free(who);
! 	free(userName);
! 	return 1;
! 
!     }
  
  }
  
--- 679,757 ----
   *                  the next pts (with no kas) user
   *  returns 0 if there are no more users, != 0 otherwise
   */
! JNIEXPORT jint JNICALL 
! Java_org_openafs_jafs_Cell_getPtsOnlyUsersNext (JNIEnv *env, jclass cls, 
! 						   jlong cellHandle, 
! 						   jlong iterationId, 
! 						   jobject juserObject ) {
! 
!   kas_identity_p who = (kas_identity_p) malloc( sizeof(kas_identity_t) );
!   kas_principalEntry_t kasEntry;
!   afs_status_t ast;
!   char *userName;
!   jstring juser;
! 
!   if( !who ) {
!     throwAFSException( env, JAFSADMNOMEM );
!     return 0;    
!   }
!   
!   userName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN);
! 
!   if( !userName ) {
!     free( who );
!     throwAFSException( env, JAFSADMNOMEM );
!     return 0;    
!   }
! 
!   while( 1 ) {
! 
!       if( !pts_UserListNext( (void *) iterationId, userName, &ast ) ) {
! 	  free( userName );
! 	  free( who );
! 	  if( ast == ADMITERATORDONE ) {
! 	      return 0;
! 	  } else {
! 	      throwAFSException( env, ast );
! 	      return 0;
! 	  }
!       }
!       
!       if( strcmp( userName, "anonymous" ) == 0 ) {
! 	  continue;
!       }
!       
!       // make sure the name is within the allowed bounds
!       if( strlen( userName ) > KAS_MAX_NAME_LEN ) {
! 	  free( userName );
! 	  free( who );
! 	  throwAFSException( env, ADMPTSUSERNAMETOOLONG );
! 	  return 0;
!       }
!       
!       if( userCls == 0 ) {
! 	  internal_getUserClass( env, juserObject );
!       }
!       
!       
!       // if there is a kas entry, recurse
!       internal_makeKasIdentity( userName, who );
!       if( kas_PrincipalGet( (void *) cellHandle, NULL, who, 
! 			    &kasEntry, &ast ) ) {
! 	  continue;
!       } 
!       
!       juser = (*env)->NewStringUTF(env, userName);
!       
!       (*env)->SetObjectField(env, juserObject, user_nameField, juser);
!       getUserInfoChar( env, (void *) cellHandle, userName, juserObject );
!       (*env)->SetBooleanField( env, juserObject, user_cachedInfoField, TRUE );
!       
!       free( who );
!       free( userName );
!       return 1;
!       
!   }
  
  }
  
***************
*** 748,764 ****
   *  cls      the current Java class
   *  iterationId   the iteration ID of this iteration
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Cell_getPtsUsersDone(JNIEnv * env, jclass cls,
! 					   jint iterationId)
! {
!     afs_status_t ast;
! 
!     if (!pts_UserListDone((void *)iterationId, &ast)) {
! 	throwAFSException(env, ast);
! 	return;
!     }
! 
  }
  
  /**
--- 762,778 ----
   *  cls      the current Java class
   *  iterationId   the iteration ID of this iteration
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Cell_getPtsUsersDone (JNIEnv *env, jclass cls, 
! 					       jlong iterationId) {
! 
!   afs_status_t ast;
! 
!   if( !pts_UserListDone( (void *) iterationId, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
!   
  }
  
  /**
***************
*** 770,808 ****
   *  cellHandle    the handle of the cell to which the groups belong
   *  returns total number of groups
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Cell_getGroupCount(JNIEnv * env, jclass cls,
! 					 jint cellHandle)
! {
  
!     afs_status_t ast;
!     void *iterationId;
!     char *groupName;
!     int i = 0;
! 
!     if (!pts_GroupListBegin((void *)cellHandle, &iterationId, &ast)) {
! 	throwAFSException(env, ast);
! 	return -1;
!     }
  
!     groupName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN);
  
!     if (!groupName) {
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return -1;
!     }
  
!     while (pts_GroupListNext((void *)iterationId, groupName, &ast))
! 	i++;
  
!     free(groupName);
  
!     if (ast != ADMITERATORDONE) {
! 	throwAFSException(env, ast);
! 	return -1;
!     }
  
!     return i;
  }
  
  /**
--- 784,820 ----
   *  cellHandle    the handle of the cell to which the groups belong
   *  returns total number of groups
   */
! JNIEXPORT jint JNICALL 
! Java_org_openafs_jafs_Cell_getGroupCount (JNIEnv *env, jclass cls, 
! 					     jlong cellHandle) {
  
!   afs_status_t ast;
!   void *iterationId;
!   char *groupName;
!   int i = 0;
  
!   if( !pts_GroupListBegin( (void *) cellHandle, &iterationId, &ast ) ) {
!     throwAFSException( env, ast );
!     return -1;
!   }
  
!   groupName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN);
  
!   if( !groupName ) {
!     throwAFSException( env, JAFSADMNOMEM );
!     return -1;
!   }
  
!   while ( pts_GroupListNext( (void *) iterationId, groupName, &ast ) ) i++;
  
!   free( groupName );
  
!   if( ast != ADMITERATORDONE ) {
!     throwAFSException( env, ast );
!     return -1;
!   }
! 
!   return i;
  }
  
  /**
***************
*** 816,834 ****
   *  cellHandle    the handle of the cell to which the groups belong
   *  returns an iteration ID
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Cell_getGroupsBegin(JNIEnv * env, jclass cls,
! 					  jint cellHandle)
! {
!     afs_status_t ast;
!     void *iterationId;
  
!     if (!pts_GroupListBegin((void *)cellHandle, &iterationId, &ast)) {
! 	throwAFSException(env, ast);
! 	return;
!     }
  
-     return (jint) iterationId;
  }
  
  /**
--- 828,847 ----
   *  cellHandle    the handle of the cell to which the groups belong
   *  returns an iteration ID
   */
! JNIEXPORT jlong JNICALL 
! Java_org_openafs_jafs_Cell_getGroupsBegin (JNIEnv *env, jclass cls, 
! 					      jlong cellHandle) {
! 
!   afs_status_t ast;
!   void *iterationId;
! 
!   if( !pts_GroupListBegin( (void *) cellHandle, &iterationId, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
!   return (jlong) iterationId;
  
  }
  
  /**
***************
*** 843,878 ****
   *  startIndex    the starting base-zero index
   *  returns an iteration ID
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Cell_getGroupsBeginAt(JNIEnv * env, jclass cls,
! 					    jint cellHandle, jint startIndex)
! {
!     afs_status_t ast;
!     void *iterationId;
!     char *groupName;
!     int i;
! 
!     groupName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN);
! 
!     if (!pts_GroupListBegin((void *)cellHandle, &iterationId, &ast)) {
! 	throwAFSException(env, ast);
! 	return 0;
      }
  
!     for (i = 1; i < startIndex; i++) {
! 	if (!pts_GroupListNext((void *)iterationId, groupName, &ast)) {
! 	    free(groupName);
! 	    if (ast == ADMITERATORDONE) {
! 		return 0;
! 	    } else {
! 		throwAFSException(env, ast);
! 		return 0;
! 	    }
! 	}
!     }
  
-     free(groupName);
-     return (jint) iterationId;
  }
  
  /**
--- 856,893 ----
   *  startIndex    the starting base-zero index
   *  returns an iteration ID
   */
! JNIEXPORT jlong JNICALL 
! Java_org_openafs_jafs_Cell_getGroupsBeginAt (JNIEnv *env, jclass cls, 
! 						jlong cellHandle, 
! 						jint startIndex) {
! 
!   afs_status_t ast;
!   void *iterationId;
!   char *groupName;
!   int i;
! 
!   groupName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN);
! 
!   if( !pts_GroupListBegin( (void *) cellHandle, &iterationId, &ast ) ) {
!     throwAFSException( env, ast );
!     return 0;
!   }
! 
!   for ( i = 1; i < startIndex; i++) {
!     if( !pts_GroupListNext( (void *) iterationId, groupName, &ast ) ) {
!       free( groupName );
!       if( ast == ADMITERATORDONE ) {
!         return 0;
!       } else {
!         throwAFSException( env, ast );
!         return 0;
!       }
      }
+   }
  
!   free( groupName );
!   return (jlong) iterationId;
  
  }
  
  /**
***************
*** 884,917 ****
   *  iterationId   the iteration ID of this iteration
   *  returns the name of the next user of the cell
   */
! JNIEXPORT jstring JNICALL
! Java_org_openafs_jafs_Cell_getGroupsNextString(JNIEnv * env, jclass cls,
! 					       jint iterationId)
! {
!     afs_status_t ast;
!     char *groupName;
!     jstring jgroup;
! 
!     groupName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN);
! 
!     if (!groupName) {
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return NULL;
!     }
! 
!     if (!pts_GroupListNext((void *)iterationId, groupName, &ast)) {
! 	free(groupName);
! 	if (ast == ADMITERATORDONE) {
! 	    return NULL;
! 	} else {
! 	    throwAFSException(env, ast);
! 	    return NULL;
! 	}
      }
  
!     jgroup = (*env)->NewStringUTF(env, groupName);
!     free(groupName);
!     return jgroup;
  
  }
  
--- 899,932 ----
   *  iterationId   the iteration ID of this iteration
   *  returns the name of the next user of the cell
   */
! JNIEXPORT jstring JNICALL 
! Java_org_openafs_jafs_Cell_getGroupsNextString (JNIEnv *env, jclass cls, 
! 						   jlong iterationId) {
! 
!   afs_status_t ast;
!   char *groupName;
!   jstring jgroup;
! 
!   groupName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN);
! 
!   if( !groupName ) {
!     throwAFSException( env, JAFSADMNOMEM );
!     return;    
!   }
! 
!   if( !pts_GroupListNext( (void *) iterationId, groupName, &ast ) ) {
!     free( groupName );
!     if( ast == ADMITERATORDONE ) {
!       return NULL;
!     } else {
!       throwAFSException( env, ast );
!       return;
      }
+   }
  
!   jgroup = (*env)->NewStringUTF(env, groupName);
!   free( groupName );
!   return jgroup;
  
  }
  
***************
*** 927,971 ****
   *                   the next group
   *  returns 0 if there are no more users, != 0 otherwise
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Cell_getGroupsNext(JNIEnv * env, jclass cls,
! 					 jint cellHandle, jint iterationId,
! 					 jobject jgroupObject)
! {
!     afs_status_t ast;
!     char *groupName;
!     jstring jgroup;
! 
!     groupName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN);
! 
!     if (!groupName) {
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return;
!     }
! 
!     if (!pts_GroupListNext((void *)iterationId, groupName, &ast)) {
! 	free(groupName);
! 	if (ast == ADMITERATORDONE) {
! 	    return 0;
! 	} else {
! 	    throwAFSException(env, ast);
! 	    return 0;
! 	}
      }
  
!     jgroup = (*env)->NewStringUTF(env, groupName);
  
!     if (groupCls == 0) {
! 	internal_getGroupClass(env, jgroupObject);
!     }
  
!     (*env)->SetObjectField(env, jgroupObject, group_nameField, jgroup);
  
!     getGroupInfoChar(env, (int)cellHandle, groupName, jgroupObject);
!     (*env)->SetBooleanField(env, jgroupObject, group_cachedInfoField, TRUE);
  
-     free(groupName);
-     return 1;
  }
  
  /**
--- 942,987 ----
   *                   the next group
   *  returns 0 if there are no more users, != 0 otherwise
   */
! JNIEXPORT jint JNICALL 
! Java_org_openafs_jafs_Cell_getGroupsNext (JNIEnv *env, jclass cls, 
! 					     jlong cellHandle, 
! 					     jlong iterationId, 
! 					     jobject jgroupObject) {
! 
!   afs_status_t ast;
!   char *groupName;
!   jstring jgroup;
! 
!   groupName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN );
! 
!   if( !groupName ) {
!     throwAFSException( env, JAFSADMNOMEM );
!       return;    
!   }
!   
!   if( !pts_GroupListNext( (void *) iterationId, groupName, &ast ) ) {
!     free( groupName );
!     if( ast == ADMITERATORDONE ) {
!       return 0;
!     } else {
!       throwAFSException( env, ast );
!       return 0;
      }
+   }
  
!   jgroup = (*env)->NewStringUTF(env, groupName);
  
!   if( groupCls == 0 ) {
!     internal_getGroupClass( env, jgroupObject );
!   }
  
!   (*env)->SetObjectField(env, jgroupObject, group_nameField, jgroup);
!   getGroupInfoChar( env, (void *)cellHandle, groupName, jgroupObject );
!   (*env)->SetBooleanField( env, jgroupObject, group_cachedInfoField, TRUE );
  
!   free( groupName );
!   return 1;
  
  }
  
  /**
***************
*** 975,991 ****
   *  cls      the current Java class
   *  iterationId   the iteration ID of this iteration
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Cell_getGroupsDone(JNIEnv * env, jclass cls,
! 					 jint iterationId)
! {
!     afs_status_t ast;
! 
!     if (!pts_GroupListDone((void *)iterationId, &ast)) {
! 	throwAFSException(env, ast);
! 	return;
!     }
! 
  }
  
  /**
--- 991,1007 ----
   *  cls      the current Java class
   *  iterationId   the iteration ID of this iteration
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Cell_getGroupsDone (JNIEnv *env, jclass cls, 
! 					     jlong iterationId) {
! 
!   afs_status_t ast;
! 
!   if( !pts_GroupListDone( (void *) iterationId, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
!   
  }
  
  /**
***************
*** 998,1016 ****
   *  cellHandle    the handle of the cell to which the group belongs
   *  returns an integer reresenting the max group id in a cell
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Cell_getMaxGroupID(JNIEnv * env, jclass cls,
! 					 jint cellHandle)
! {
!     afs_status_t ast;
!     jint maxID;
  
!     if (!pts_GroupMaxGet((void *)cellHandle, (int *)&maxID, &ast)) {
! 	throwAFSException(env, ast);
! 	return 0;
!     }
  
-     return maxID;
  }
  
  /**
--- 1014,1033 ----
   *  cellHandle    the handle of the cell to which the group belongs
   *  returns an integer reresenting the max group id in a cell
   */
! JNIEXPORT jint JNICALL 
! Java_org_openafs_jafs_Cell_getMaxGroupID (JNIEnv *env, jclass cls, 
! 					     jlong cellHandle) {
! 
!   afs_status_t ast;
!   int maxID;
! 
!   if( !pts_GroupMaxGet( (void *) cellHandle, &maxID, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
!   return (jint)maxID;
  
  }
  
  /**
***************
*** 1022,1037 ****
   *  cellHandle    the handle of the cell to which the group belongs
   *  maxID an integer reresenting the new max group id in a cell
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Cell_setMaxGroupID(JNIEnv * env, jclass cls,
! 					 jint cellHandle, jint maxID)
! {
!     afs_status_t ast;
  
-     if (!pts_GroupMaxSet((void *)cellHandle, (int)maxID, &ast)) {
- 	throwAFSException(env, ast);
- 	return;
-     }
  }
  
  /**
--- 1039,1055 ----
   *  cellHandle    the handle of the cell to which the group belongs
   *  maxID an integer reresenting the new max group id in a cell
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Cell_setMaxGroupID (JNIEnv *env, jclass cls, 
! 					     jlong cellHandle, jint maxID) {
! 
!   afs_status_t ast;
! 
!   if( !pts_GroupMaxSet( (void *) cellHandle, (int) maxID, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
  }
  
  /**
***************
*** 1044,1062 ****
   *  cellHandle    the handle of the cell to which the user belongs
   *  returns an integer reresenting the max user id in a cell
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Cell_getMaxUserID(JNIEnv * env, jclass cls,
! 					jint cellHandle)
! {
!     afs_status_t ast;
!     jint maxID;
  
!     if (!pts_UserMaxGet((void *)cellHandle, (int *)&maxID, &ast)) {
! 	throwAFSException(env, ast);
! 	return 0;
!     }
  
-     return maxID;
  }
  
  /**
--- 1062,1081 ----
   *  cellHandle    the handle of the cell to which the user belongs
   *  returns an integer reresenting the max user id in a cell
   */
! JNIEXPORT jint JNICALL 
! Java_org_openafs_jafs_Cell_getMaxUserID (JNIEnv *env, jclass cls, 
! 					    jlong cellHandle) {
! 
!   afs_status_t ast;
!   int maxID;
! 
!   if( !pts_UserMaxGet( (void *) cellHandle, &maxID, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
!   return (jint)maxID;
  
  }
  
  /**
***************
*** 1068,1083 ****
   *  cellHandle    the handle of the cell to which the user belongs
   *  maxID an integer reresenting the new max user id in a cell
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Cell_setMaxUserID(JNIEnv * env, jclass cls,
! 					jint cellHandle, jint maxID)
! {
!     afs_status_t ast;
  
-     if (!pts_UserMaxSet((void *)cellHandle, (int)maxID, &ast)) {
- 	throwAFSException(env, ast);
- 	return;
-     }
  }
  
  /**
--- 1087,1103 ----
   *  cellHandle    the handle of the cell to which the user belongs
   *  maxID an integer reresenting the new max user id in a cell
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Cell_setMaxUserID (JNIEnv *env, jclass cls, 
! 					    jlong cellHandle, jint maxID) {
! 
!   afs_status_t ast;
! 
!   if( !pts_UserMaxSet( (void *) cellHandle, (int) maxID, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
  }
  
  /**
***************
*** 1089,1117 ****
   *  cellHandle    the handle of the cell to which the servers belong
   *  returns total number of servers
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Cell_getServerCount(JNIEnv * env, jclass cls,
! 					  jint cellHandle)
! {
!     afs_status_t ast;
!     void *iterationId;
!     afs_serverEntry_t servEntry;
!     int i = 0;
! 
!     if (!afsclient_AFSServerGetBegin((void *)cellHandle, &iterationId, &ast)) {
! 	throwAFSException(env, ast);
! 	return -1;
!     }
  
!     while (afsclient_AFSServerGetNext((void *)iterationId, &servEntry, &ast))
! 	i++;
! 
!     if (ast != ADMITERATORDONE) {
! 	throwAFSException(env, ast);
! 	return -1;
!     }
! 
!     return i;
  }
  
  /**
--- 1109,1138 ----
   *  cellHandle    the handle of the cell to which the servers belong
   *  returns total number of servers
   */
! JNIEXPORT jint JNICALL 
! Java_org_openafs_jafs_Cell_getServerCount (JNIEnv *env, jclass cls, 
! 					      jlong cellHandle) {
! 
!   afs_status_t ast;
!   void *iterationId;
!   afs_serverEntry_t servEntry;
!   int i = 0;
! 
!   if( !afsclient_AFSServerGetBegin( (void *) cellHandle, 
! 				    &iterationId, &ast ) ) {
!     throwAFSException( env, ast );
!     return -1;
!   }
! 
!   while ( afsclient_AFSServerGetNext( (void *) iterationId, 
! 				      &servEntry, &ast ) ) i++;
! 
!   if( ast != ADMITERATORDONE ) {
!     throwAFSException( env, ast );
!     return -1;
!   }
  
!   return i;
  }
  
  /**
***************
*** 1124,1142 ****
   *  cellHandle    the handle of the cell to which the servers belong
   *  returns an iteration ID
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Cell_getServersBegin(JNIEnv * env, jclass cls,
! 					   jint cellHandle)
! {
!     afs_status_t ast;
!     void *iterationId;
  
!     if (!afsclient_AFSServerGetBegin((void *)cellHandle, &iterationId, &ast)) {
! 	throwAFSException(env, ast);
! 	return -1;
!     }
  
-     return (jint) iterationId;
  }
  
  /**
--- 1145,1165 ----
   *  cellHandle    the handle of the cell to which the servers belong
   *  returns an iteration ID
   */
! JNIEXPORT jlong JNICALL 
! Java_org_openafs_jafs_Cell_getServersBegin (JNIEnv *env, jclass cls, 
! 					       jlong cellHandle) {
! 
!   afs_status_t ast;
!   void *iterationId;
! 
!   if( !afsclient_AFSServerGetBegin( (void *) cellHandle, 
! 				    &iterationId, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
!   return (jlong) iterationId;
  
  }
  
  /**
***************
*** 1148,1170 ****
   *  iterationId   the iteration ID of this iteration
   *  returns the name of the next server of the cell
   */
! JNIEXPORT jstring JNICALL
! Java_org_openafs_jafs_Cell_getServersNextString(JNIEnv * env, jclass cls,
! 						jint iterationId)
! {
!     afs_status_t ast;
!     jstring jserver;
!     afs_serverEntry_t servEntry;
  
!     if (!afsclient_AFSServerGetNext((void *)iterationId, &servEntry, &ast)) {
! 	if (ast == ADMITERATORDONE) {
! 	    return NULL;
! 	} else {
! 	    throwAFSException(env, ast);
! 	    return NULL;
! 	}
!     }
!     return jserver;
  }
  
  /**
--- 1171,1196 ----
   *  iterationId   the iteration ID of this iteration
   *  returns the name of the next server of the cell
   */
! JNIEXPORT jstring JNICALL 
! Java_org_openafs_jafs_Cell_getServersNextString (JNIEnv *env, jclass cls, 
! 						    jlong iterationId) {
! 
!   afs_status_t ast;
!   jstring jserver;
!   afs_serverEntry_t servEntry;
! 
!   if( !afsclient_AFSServerGetNext( (void *) iterationId, &servEntry, &ast ) ) {
!       if( ast == ADMITERATORDONE ) {
! 	  return NULL;
!       } else {
! 	  throwAFSException( env, ast );
! 	  return NULL;
!       }
!   }
!   
!   jserver = (*env)->NewStringUTF(env, "not_implemented"); /* psomogyi 20050514 */
  
!   return jserver;
  }
  
  /**
***************
*** 1179,1212 ****
   *                    of the next server 
   *  returns 0 if there are no more servers, != 0 otherwise
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Cell_getServersNext(JNIEnv * env, jclass cls,
! 					  jint cellHandle, jint iterationId,
! 					  jobject jserverObject)
! {
!     afs_status_t ast;
!     jstring jserver;
!     afs_serverEntry_t servEntry;
!     jintArray jaddress;
! 
!     if (!afsclient_AFSServerGetNext((void *)iterationId, &servEntry, &ast)) {
! 	if (ast == ADMITERATORDONE) {
! 	    return 0;
! 	} else {
! 	    throwAFSException(env, ast);
! 	    return 0;
! 	}
!     }
!     // get the class fields if need be
!     if (serverCls == 0) {
! 	internal_getServerClass(env, jserverObject);
      }
  
!     fillServerInfo(env, (int)cellHandle, jserverObject, servEntry);
  
!     (*env)->SetBooleanField(env, jserverObject, server_cachedInfoField, TRUE);
  
!     return 1;
  }
  
  /**
--- 1205,1239 ----
   *                    of the next server 
   *  returns 0 if there are no more servers, != 0 otherwise
   */
! JNIEXPORT jint JNICALL 
! Java_org_openafs_jafs_Cell_getServersNext
!   (JNIEnv *env, jclass cls, jlong cellHandle, jlong iterationId,
!    jobject jserverObject)
! {
!   afs_status_t ast;
!   jstring jserver;
!   afs_serverEntry_t servEntry;
!   jintArray jaddress;
! 
!   if( !afsclient_AFSServerGetNext( (void *) iterationId, &servEntry, &ast ) ) {
!     if( ast == ADMITERATORDONE ) {
!       return 0;
!     } else {
!       throwAFSException( env, ast );
!       return 0;
      }
+   }
+ 
+   // get the class fields if need be
+   if( serverCls == 0 ) {
+     internal_getServerClass( env, jserverObject );
+   }
  
!   fillServerInfo( env, (void *) cellHandle, jserverObject, servEntry );
  
!   (*env)->SetBooleanField( env, jserverObject, server_cachedInfoField, TRUE );
  
!   return 1;
  }
  
  /**
***************
*** 1216,1231 ****
   *  cls      the current Java class
   *  iterationId   the iteration ID of this iteration
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Cell_getServersDone(JNIEnv * env, jclass cls,
! 					  jint iterationId)
! {
!     afs_status_t ast;
  
-     if (!afsclient_AFSServerGetDone((void *)iterationId, &ast)) {
- 	throwAFSException(env, ast);
- 	return;
-     }
  }
  
  /**
--- 1243,1259 ----
   *  cls      the current Java class
   *  iterationId   the iteration ID of this iteration
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Cell_getServersDone
!   (JNIEnv *env, jclass cls, jlong iterationId)
! {
!   afs_status_t ast;
! 
!   if( !afsclient_AFSServerGetDone( (void *) iterationId, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
  }
  
  /**
***************
*** 1240,1301 ****
   *  readWrite   whether or not this is to be a readwrite mount point
   *  forceCheck  whether or not to check if this volume name exists
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Cell_createMountPoint(JNIEnv * env, jclass cls,
! 					    jint cellHandle,
! 					    jstring jdirectory,
! 					    jstring jvolumeName,
! 					    jboolean readWrite,
! 					    jboolean forceCheck)
! {
!     afs_status_t ast;
!     char *directory;
!     char *volumeName;
!     vol_type_t type;
!     vol_check_t check;
! 
!     if (jdirectory != NULL) {
! 	directory = getNativeString(env, jdirectory);
! 	if (!directory) {
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	throwAFSException(env, JAFSNULLPATH);
! 	return;
!     }
!     if (jvolumeName != NULL) {
! 	volumeName = getNativeString(env, jvolumeName);
! 	if (volumeName == NULL) {
! 	    free(directory);
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	free(directory);
! 	throwAFSException(env, JAFSNULLVOLUME);
! 	return;
!     }
! 
!     if (readWrite) {
! 	type = READ_WRITE;
!     } else {
! 	type = READ_ONLY;
!     }
! 
!     if (forceCheck) {
! 	check = CHECK_VOLUME;
!     } else {
! 	check = DONT_CHECK_VOLUME;
!     }
  
-     if (!afsclient_MountPointCreate
- 	((void *)cellHandle, directory, volumeName, type, check, &ast)) {
- 	throwAFSException(env, ast);
-     }
- 
-     free(directory);
-     free(volumeName);
  }
  
  /*
--- 1268,1340 ----
   *  readWrite   whether or not this is to be a readwrite mount point
   *  forceCheck  whether or not to check if this volume name exists
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Cell_createMountPoint (JNIEnv *env, jclass cls, 
! 						jlong cellHandle, 
! 						jstring jdirectory, 
! 						jstring jvolumeName, 
! 						jboolean readWrite, 
! 						jboolean forceCheck) {
! 
!   afs_status_t ast;
!   const char *directory;
!   const char *volumeName;
!   vol_type_t type;
!   vol_check_t check;
! 
!   if( jdirectory != NULL ) {
!     directory = (*env)->GetStringUTFChars(env, jdirectory, 0);
!     if( !directory ) {
! 	throwAFSException( env, JAFSADMNOMEM );
! 	return;    
!     }
!   } else {
!     directory = NULL;
!   }
!   if( jvolumeName != NULL ) {
!     volumeName = (*env)->GetStringUTFChars(env, jvolumeName, 0);
!     if( !volumeName ) {
!       if( directory != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, jdirectory, directory);
!       }
!       throwAFSException( env, JAFSADMNOMEM );
!       return;    
!     }
!   } else {
!     volumeName = NULL;
!   }
! 
!   if( readWrite ) {
!     type = READ_WRITE;
!   } else {
!     type = READ_ONLY;
!   }
! 
!   if( forceCheck ) {
!     check = CHECK_VOLUME;
!   } else {
!     check = DONT_CHECK_VOLUME;
!   }
! 
!   if( !afsclient_MountPointCreate( (void *) cellHandle, directory, 
! 				   volumeName, type, check, &ast ) ) {
!     if( volumeName != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jvolumeName, volumeName);
!     }
!     if( directory != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jdirectory, directory);
!     }
!     throwAFSException( env, ast );
!     return;
!   }
! 
!   if( volumeName != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, jvolumeName, volumeName);
!   }
!   if( directory != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, jdirectory, directory);
!   }
  
  }
  
  /*
***************
*** 1314,1413 ****
   *  lock    whether or not to allow lock access to this user
   *  admin    whether or not to allow admin access to this user
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Cell_setACL(JNIEnv * env, jclass cls,
! 				  jstring jdirectory, jstring juserName,
! 				  jboolean read, jboolean write,
! 				  jboolean lookup, jboolean delete,
! 				  jboolean insert, jboolean lock,
! 				  jboolean admin)
! {
!     afs_status_t ast;
!     char *directory;
!     char *userName;
!     acl_t acl;
  
-     if (!afsclient_Init(&ast)) {
- 	throwAFSException(env, ast);
- 	return;
-     }
  
-     if (jdirectory != NULL) {
- 	directory = getNativeString(env, jdirectory);
- 	if (!directory) {
- 	    throwAFSException(env, JAFSADMNOMEM);
- 	    return;
- 	}
-     } else {
- 	throwAFSException(env, JAFSNULLPATH);
- 	return;
-     }
  
-     if (juserName != NULL) {
- 	userName = getNativeString(env, juserName);
- 	if (!userName) {
- 	    free(directory);
- 	    throwAFSException(env, JAFSADMNOMEM);
- 	    return;
- 	}
-     } else {
- 	free(directory);
- 	throwAFSException(env, JAFSNULLUSER);
- 	return;
-     }
  
-     if (read) {
- 	acl.read = READ;
-     } else {
- 	acl.read = NO_READ;
-     }
  
-     if (write) {
- 	acl.write = WRITE;
-     } else {
- 	acl.write = NO_WRITE;
-     }
  
-     if (lookup) {
- 	acl.lookup = LOOKUP;
-     } else {
- 	acl.lookup = NO_LOOKUP;
-     }
  
-     if (delete) {
- 	acl.del = DELETE;
-     } else {
- 	acl.del = NO_DELETE;
-     }
  
-     if (insert) {
- 	acl.insert = INSERT;
-     } else {
- 	acl.insert = NO_INSERT;
-     }
  
-     if (lock) {
- 	acl.lock = LOCK;
-     } else {
- 	acl.lock = NO_LOCK;
-     }
  
-     if (admin) {
- 	acl.admin = ADMIN;
-     } else {
- 	acl.admin = NO_ADMIN;
-     }
  
-     if (!afsclient_ACLEntryAdd(directory, userName, &acl, &ast)) {
- 	throwAFSException(env, ast);
-     }
  
-     free(userName);
-     free(directory);
- }
  
- // reclaim global memory used by this portion
- JNIEXPORT void JNICALL
- Java_org_openafs_jafs_Cell_reclaimCellMemory(JNIEnv * env, jclass cls)
- {
- }
--- 1353,1485 ----
   *  lock    whether or not to allow lock access to this user
   *  admin    whether or not to allow admin access to this user
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Cell_setACL (JNIEnv *env, jclass cls, 
! 				      jstring jdirectory, jstring juserName, 
! 				      jboolean read, jboolean write, 
! 				      jboolean lookup, jboolean delete, 
! 				      jboolean insert, jboolean lock, 
! 				      jboolean admin) {
! 
!   afs_status_t ast;
!   const char *directory;
!   const char *userName;
!   acl_t acl;
! 
!   // Added by MP
!   if( !afsclient_Init( &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
! 
!   if( jdirectory != NULL ) {
!     directory = (*env)->GetStringUTFChars(env, jdirectory, 0);
!     if( !directory ) {
! 	throwAFSException( env, JAFSADMNOMEM );
! 	return;    
!     }
!   } else {
!     directory = NULL;
!   }
!   if( juserName != NULL ) {
!     userName = (*env)->GetStringUTFChars(env, juserName, 0);
!     if( !userName ) {
!       if( directory != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, jdirectory, directory);
!       }
!       throwAFSException( env, JAFSADMNOMEM );
!       return;    
!     }
!   } else {
!     userName = NULL;
!   }
! 
!   if( read ) {
!     acl.read = READ;
!   } else {
!     acl.read = NO_READ;
!   }
! 
!   if( write ) {
!     acl.write = WRITE;
!   } else {
!     acl.write = NO_WRITE;
!   }
! 
!   if( lookup ) {
!     acl.lookup = LOOKUP;
!   } else {
!     acl.lookup = NO_LOOKUP;
!   }
! 
!   if( delete ) {
!     acl.del = DELETE;
!   } else {
!     acl.del = NO_DELETE;
!   }
! 
!   if( insert ) {
!     acl.insert = INSERT;
!   } else {
!     acl.insert = NO_INSERT;
!   }
! 
!   if( lock ) {
!     acl.lock = LOCK;
!   } else {
!     acl.lock = NO_LOCK;
!   }
! 
!   if( admin ) {
!     acl.admin = ADMIN;
!   } else {
!     acl.admin = NO_ADMIN;
!   }
! 
!   if( !afsclient_ACLEntryAdd( directory, userName, &acl, &ast ) ) {
!       if( userName != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, juserName, userName);
!       }
!       if( directory != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, jdirectory, directory);
!       }
!       throwAFSException( env, ast );
!       return;
!   }
! 
!   if( userName != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, juserName, userName);
!   }
!   if( directory != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, jdirectory, directory);
!   }
! 
! }
! 
! // reclaim global memory used by this portion
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Cell_reclaimCellMemory (JNIEnv *env, jclass cls) {
! 
! }
! 
! 
! 
! 
! 
! 
! 
! 
! 
  
  
  
  
  
  
  
  
  
  
  
  
  
Index: openafs/src/JAVA/libjafs/ChangeLog
diff -c /dev/null openafs/src/JAVA/libjafs/ChangeLog:1.1.2.2
*** /dev/null	Sat Oct 22 02:14:46 2005
--- openafs/src/JAVA/libjafs/ChangeLog	Fri Oct 14 22:14:11 2005
***************
*** 0 ****
--- 1,41 ----
+ 20050524: (by Peter Somogyi somogyi@de.ibm.com)
+ 	- bugfix: ACL.c: syscall => pioctl (problem on ppc64)
+ 	- bugfix: ACL.c: memory leak
+ 	- some minor changes in ACL.c to be more accordance to src/venus/fs.c
+ 	- bugfix: inet_ntoa crashed; implemented an own function is Server.c instead
+ 	- modified src/libuafs/MakefileProto.LINUX: added -fPIC flag (doesn't tolerate mixing with non-fPIC on ppc)
+ 	
+ 20050525: (somogyi@de.ibm.com)
+ 	- removed non-error message from getACL; extended the error report (path string) instead of it
+ 
+ 20050602: (somogyi@de.ibm.com)
+ 	- moved ACL.c from libjafs.so into libjafsadm.so
+ 	(solves pioctl call failure in [get|set]ACL)
+ 	In the future each one should be in libjafsadm.so - using _only_ AFS API (!!!).
+ 20050603:
+ 	- moved GetNativeString from libjafs.so into libjafsadm.so
+ 20050610:
+ 	- created an automatic testAFS comprehensive java test
+ 	- modified java library: made all getInfo-like methods public
+ 20050614:
+ 	- bugfix: Cell.c: ..._getServersNextString: return "not_implemented" instead of making a crash
+ 20050616:
+ 	- created a multithreaded test; pioctl in getACL fails on i386_linux26, but doesn't fail under ppc64_linux26
+ 20050617:
+ 	- [#]ifdef-separated c sources and makefiles for ppc64_linux26
+ 	- bugfix: eliminating thread-safety crashes on pioctl/i386, but only pioctl works on ppc64 (idef-ed)
+ 	(pioctl didn't crash on ppc64)
+ 20050720:
+ 	- added s390x support, needs some special patches to openafs src
+ 	- added 64-bit support, affects java part
+ 	- refined testAFS.java tester tool
+ 
+ 20050727:
+ 	- tested on ppc64/32, fixed some bugs because of some s390x modifications
+ 
+ 20050830:
+ 	- modified Makefile.in to support OpenAFS version 1.3.85 or higher (added util/rxkstats.o to libjafs.so)
+ 
+ 20050906:
+ 	- added version info (overwritting an earlier implementation)
+ 	- added build info (using AFS_component_version_number.c) which is autogenerated
Index: openafs/src/JAVA/libjafs/Exceptions.h
diff -c openafs/src/JAVA/libjafs/Exceptions.h:1.2 openafs/src/JAVA/libjafs/Exceptions.h:1.2.2.1
*** openafs/src/JAVA/libjafs/Exceptions.h:1.2	Tue Jul 15 19:11:26 2003
--- openafs/src/JAVA/libjafs/Exceptions.h	Fri Oct 14 22:14:11 2005
***************
*** 1,9 ****
  #ifndef _Jafsadm_Exceptions
  #define _Jafsadm_Exceptions
  
! static char *afsExceptionName = "org/openafs/jafs/AFSException";
! static char *afsFileExceptionName = "org/openafs/jafs/AFSFileException";
! static char *afsSecurityExceptionName =
!     "org/openafs/jafs/AFSSecurityException";
  
  #endif
--- 1,12 ----
  #ifndef _Jafsadm_Exceptions
  #define _Jafsadm_Exceptions
  
! static char *afsExceptionName         = "org/openafs/jafs/AFSException";
! static char *afsFileExceptionName     = "org/openafs/jafs/AFSFileException";
! static char *afsSecurityExceptionName = "org/openafs/jafs/AFSSecurityException";
  
  #endif
+ 
+ 
+ 
+ 
Index: openafs/src/JAVA/libjafs/File.c
diff -c openafs/src/JAVA/libjafs/File.c:1.3 openafs/src/JAVA/libjafs/File.c:1.3.2.1
*** openafs/src/JAVA/libjafs/File.c:1.3	Tue Jul 15 19:11:26 2003
--- openafs/src/JAVA/libjafs/File.c	Fri Oct 14 22:14:11 2005
***************
*** 19,28 ****
   * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   */
  
- #if 0
  #include <afs/param.h>
  #include <errno.h>
- #endif
  
  #include "Internal.h"
  #include "org_openafs_jafs_File.h"
--- 19,26 ----
***************
*** 31,37 ****
  #include <fcntl.h>
  #include <jni.h>
  #include <pthread.h>
! #include <afs/afs_usrops.h>
  #include <afs/prs_fs.h>
  #include <sys/time.h>
  #include <unistd.h>
--- 29,35 ----
  #include <fcntl.h>
  #include <jni.h>
  #include <pthread.h>
! /*#include <afs/afs_usrops.h>*/
  #include <afs/prs_fs.h>
  #include <sys/time.h>
  #include <unistd.h>
***************
*** 49,55 ****
  #include "dmalloc.h"
  #endif
  
! void setFileNotExistsAttributes(JNIEnv * env, jobject * obj);
  
  typedef struct {
      char *fileName;
--- 47,53 ----
  #include "dmalloc.h"
  #endif
  
! void setFileNotExistsAttributes(JNIEnv *env, jobject *obj);
  
  typedef struct {
      char *fileName;
***************
*** 58,73 ****
  
  /*static char compile_date[] = COMPILE_DATE;*/
  
! int
! sub_time(struct timeval *tv1, struct timeval *tv2)
  {
!     if (tv2->tv_usec > tv1->tv_usec) {
! 	tv1->tv_usec += 1000000;
! 	tv1->tv_usec -= 1;
!     }
  
!     tv1->tv_usec -= tv2->tv_usec;
!     tv1->tv_sec -= tv2->tv_sec;
  }
  
  /**
--- 56,70 ----
  
  /*static char compile_date[] = COMPILE_DATE;*/
  
! int sub_time(struct timeval *tv1, struct timeval *tv2)
  {
!    if (tv2->tv_usec > tv1->tv_usec) {
!      tv1->tv_usec += 1000000;
!      tv1->tv_usec -= 1;
!    }
  
!    tv1->tv_usec -= tv2->tv_usec;
!    tv1->tv_sec -= tv2->tv_sec;
  }
  
  /**
***************
*** 77,118 ****
   * env      the Java environment
   * obj      the current Java object
   */
! char *
! getAbsolutePath(JNIEnv * env, jobject * obj, char *dirName)
  {
      jclass thisClass;
      jstring jDirName;
      jmethodID getAbsolutePathID;
!     char *auxDirName;
      jfieldID fid;
  
      thisClass = (*env)->GetObjectClass(env, *obj);
!     if (thisClass == NULL) {
! 	fprintf(stderr, "File::getAbsolutePath(): GetObjectClass failed\n");
! 	return NULL;
      }
- 
      fid = (*env)->GetFieldID(env, thisClass, "path", "Ljava/lang/String;");
!     if (fid == NULL) {
! 	fprintf(stderr,
! 		"File::getAbsolutePath(): GetFieldID (path) failed\n");
! 	return NULL;
      }
- 
      jDirName = (*env)->GetObjectField(env, *obj, fid);
-     if (jDirName == NULL) {
- 	fprintf(stderr, "File::getAbsolutePath(): failed to get file name\n");
- 	return NULL;
-     }
  
!     auxDirName = getNativeString(env, jDirName);
!     if (auxDirName == NULL) {
! 	fprintf(stderr,
! 		"File::getAbsolutePath(): failed to get translated file name\n");
! 	return NULL;
      }
      strcpy(dirName, auxDirName);
!     free(auxDirName);
  }
  
  /**
--- 74,106 ----
   * env      the Java environment
   * obj      the current Java object
   */
! char* getAbsolutePath(JNIEnv *env, jobject *obj, char *dirName)
  {
      jclass thisClass;
      jstring jDirName;
      jmethodID getAbsolutePathID;
!     const char *auxDirName;
      jfieldID fid;
  
      thisClass = (*env)->GetObjectClass(env, *obj);
!     if(thisClass == NULL) {
!       fprintf(stderr, "File::getAbsolutePath(): GetObjectClass failed\n");
!       return NULL;
      }
      fid = (*env)->GetFieldID(env, thisClass, "path", "Ljava/lang/String;");
!     if (fid == 0) {
!       fprintf(stderr, "File::getAbsolutePath(): GetFieldID (path) failed\n");
!       return NULL;
      }
      jDirName = (*env)->GetObjectField(env, *obj, fid);
  
!     if(jDirName == NULL) {
!       fprintf(stderr, "File::getAbsolutePath(): failed to get file name\n");
!       return NULL;
      }
+     auxDirName = (*env) -> GetStringUTFChars(env, jDirName, 0);
      strcpy(dirName, auxDirName);
!     (*env) -> ReleaseStringUTFChars(env, jDirName, auxDirName);
  }
  
  /**
***************
*** 130,139 ****
   *
   * throws AFSException
   */
! JNIEXPORT jboolean JNICALL
! Java_org_openafs_jafs_File_setAttributes(JNIEnv * env, jobject obj)
  {
!     char target[FILENAME_MAX + 1];
      char dirName[FILENAME_MAX];
      jclass thisClass;
      jfieldID fid;
--- 118,127 ----
   *
   * throws AFSException
   */
! JNIEXPORT jboolean JNICALL Java_org_openafs_jafs_File_setAttributes
!   (JNIEnv *env, jobject obj)
  {
!     char target[FILENAME_MAX+1];
      char dirName[FILENAME_MAX];
      jclass thisClass;
      jfieldID fid;
***************
*** 145,331 ****
      struct timeval tv0, tv1;
      struct timezone tz;
  
!     /*memset(target, 0, FILENAME_MAX); */
  
      *dirName = '\0';
      getAbsolutePath(env, &obj, dirName);
  
!     /*fprintf(stderr, "dirName=%s\n", dirName); */
  
!     if (*dirName == '\0') {
! 	fprintf(stderr, "File::setAttributes(): failed to get dirName\n");
! 	return JNI_FALSE;
      }
  
!     thisClass = (*env)->GetObjectClass(env, obj);
!     if (thisClass == NULL) {
! 	fprintf(stderr, "File::setAttributes(): GetObjectClass failed\n");
! 	return JNI_FALSE;
      }
  
      gettimeofday(&tv0, &tz);
      if ((strcmp(dirName, "/afs") == 0) || (strcmp(dirName, "/afs/") == 0)) {
! 	rc = 1;			/* special case for /afs since statmountpoint fails on it */
      } else {
! 	rc = uafs_statmountpoint(dirName);
! 	gettimeofday(&tv1, &tz);
! 	sub_time(&tv1, &tv0);
! 	/*printf("%s: statmountpoint %d.%06d\n", dirName, tv1.tv_sec, tv1.tv_usec); */
!     }
! 
!     if (rc < 0) {
! 	setError(env, &obj, errno);
! 	if (errno == ENOENT) {
! 	    setFileNotExistsAttributes(env, &obj);
! 	    return JNI_TRUE;	/* not really an error */
! 	} else {
! 	    fprintf(stderr,
! 		    "File::setAttributes(): uafs_statmountpoint failed "
! 		    "for %s (%s)\n", dirName, error_message(errno));
! 	    return JNI_FALSE;
! 	}
      }
  
      if (rc == 1) {
! 	/* this is an AFS mount point; we don't want to stat it */
! 	/* fake up a stat entry instead */
! 	mtpoint = 1;
! 	st.st_mtime = 0;
! 	st.st_size = 2048;
! 	st.st_mode = 0;		/* don't match anything */
      } else {
! 	mtpoint = 0;
! 	fid = (*env)->GetFieldID(env, thisClass, "isLink", "Z");
! 	if (fid == 0) {
! 	    fprintf(stderr,
! 		    "File::setAttributes(): GetFieldID (isLink) failed\n");
! 	    setError(env, &obj, -1);
! 	    return JNI_FALSE;
! 	}
! 	islink = (*env)->GetBooleanField(env, obj, fid);
! 	if (islink != JNI_TRUE) {
! 	    rc = uafs_lstat(dirName, &st);
! 	} else {
! 	    /* Here we are being called on a link object for the second time,
! 	     * so we want info on the object pointed to by the link. */
! 	    fprintf(stderr, "islink = TRUE on file %s\n", dirName);
! 	    rc = uafs_stat(dirName, &st);
! 	}
! 
! 	if (rc < 0) {
! 	    setError(env, &obj, errno);
! 	    fprintf(stderr, "uafs_lstat failed for dir %s: error %d\n",
! 		    dirName, errno);
! 	    if (errno == ENOENT) {
! 		setFileNotExistsAttributes(env, &obj);
! 		return JNI_TRUE;
! 	    }
! 	    fprintf(stderr,
! 		    "File::setAttributes(): uafs_stat failed for %s (%s)\n",
! 		    dirName, error_message(errno));
! 	    return JNI_FALSE;
! 	}
      }
  
      fid = (*env)->GetFieldID(env, thisClass, "exists", "Z");
      if (fid == 0) {
! 	fprintf(stderr,
! 		"File::setAttributes(): GetFieldID (exists) failed\n");
! 	setError(env, &obj, -1);
! 	return JNI_FALSE;
      }
      (*env)->SetBooleanField(env, obj, fid, JNI_TRUE);
  
      fid = (*env)->GetFieldID(env, thisClass, "isDirectory", "Z");
      if (fid == 0) {
! 	fprintf(stderr,
! 		"File::setAttributes(): GetFieldID (isDirectory) failed\n");
! 	setError(env, &obj, -1);
! 	return JNI_FALSE;
      }
      if ((st.st_mode & S_IFMT) == S_IFDIR && !mtpoint) {
! 	(*env)->SetBooleanField(env, obj, fid, JNI_TRUE);
      } else {
! 	(*env)->SetBooleanField(env, obj, fid, JNI_FALSE);
      }
  
      fid = (*env)->GetFieldID(env, thisClass, "isFile", "Z");
      if (fid == 0) {
! 	fprintf(stderr,
! 		"File::setAttributes(): GetFieldID (isFile) failed\n");
! 	setError(env, &obj, -1);
! 	return JNI_FALSE;
      }
      if ((st.st_mode & S_IFMT) == S_IFREG) {
! 	(*env)->SetBooleanField(env, obj, fid, JNI_TRUE);
      } else {
! 	(*env)->SetBooleanField(env, obj, fid, JNI_FALSE);
      }
  
      fid = (*env)->GetFieldID(env, thisClass, "isLink", "Z");
      if (fid == 0) {
! 	fprintf(stderr,
! 		"File::setAttributes(): GetFieldID (isLink) failed\n");
! 	setError(env, &obj, -1);
! 	return JNI_FALSE;
!     }
! 
!     if (islink != JNI_TRUE) {	/* don't re-process link */
! 	if ((st.st_mode & S_IFMT) == S_IFLNK) {
! 	    (*env)->SetBooleanField(env, obj, fid, JNI_TRUE);
! 
! 	    /* Find the target of the link */
! 	    rc = uafs_readlink(dirName, target, FILENAME_MAX);
! 	    if (rc < 0) {
! 		fprintf(stderr,
! 			"File::setAttributes(): uafs_readlink failed\n");
! 		setError(env, &obj, errno);
! 		return JNI_FALSE;
! 	    } else {
! 		target[rc] = 0;	/* weird that we have to do this */
! 		/*fprintf(stderr, "readlink %s succeeded, target=%s, rc=%d\n", dirName,
! 		 * target, rc); */
! 	    }
! 
! 	    rc = setString(env, &obj, "target", target);
! 	    if (rc < 0) {
! 		fprintf(stderr, "setString dirName=%s target=%s failed\n",
! 			dirName, target);
! 	    }
! 	} else {
! 	    (*env)->SetBooleanField(env, obj, fid, JNI_FALSE);
! 	}
      }
  
      fid = (*env)->GetFieldID(env, thisClass, "isMountPoint", "Z");
      if (fid == 0) {
! 	fprintf(stderr,
! 		"File::setAttributes(): GetFieldID (isMountPoint) failed\n");
! 	setError(env, &obj, -1);
! 	return JNI_FALSE;
      }
  
      if (mtpoint) {
! 	(*env)->SetBooleanField(env, obj, fid, JNI_TRUE);
      } else {
! 	(*env)->SetBooleanField(env, obj, fid, JNI_FALSE);
      }
  
      fid = (*env)->GetFieldID(env, thisClass, "lastModified", "J");
      if (fid == 0) {
! 	fprintf(stderr,
! 		"File::setAttributes(): GetFieldID (lastModified) failed\n");
! 	setError(env, &obj, -1);
! 	return JNI_FALSE;
      }
!     (*env)->SetLongField(env, obj, fid, ((jlong) st.st_mtime) * 1000);
  
      fid = (*env)->GetFieldID(env, thisClass, "length", "J");
      if (fid == 0) {
! 	fprintf(stderr,
! 		"File::setAttributes(): GetFieldID (length) failed\n");
! 	setError(env, &obj, -1);
! 	return JNI_FALSE;
      }
      (*env)->SetLongField(env, obj, fid, st.st_size);
  
--- 133,316 ----
      struct timeval tv0, tv1;
      struct timezone tz;
  
!     /*memset(target, 0, FILENAME_MAX);*/
  
      *dirName = '\0';
      getAbsolutePath(env, &obj, dirName);
  
!     /*fprintf(stderr, "dirName=%s\n", dirName);*/
  
!     if(*dirName == '\0') {
!       fprintf(stderr, "File::setAttributes(): failed to get dirName\n");
!       return JNI_FALSE;
      }
  
!     thisClass = (*env) -> GetObjectClass(env, obj);
!     if(thisClass == NULL) {
!       fprintf(stderr, "File::setAttributes(): GetObjectClass failed\n");
!       return JNI_FALSE;
      }
  
      gettimeofday(&tv0, &tz);
      if ((strcmp(dirName, "/afs") == 0) || (strcmp(dirName, "/afs/") == 0)) {
!       rc = 1;   /* special case for /afs since statmountpoint fails on it */
      } else {
!       rc = uafs_statmountpoint(dirName);
!       gettimeofday(&tv1, &tz);
!       sub_time(&tv1, &tv0);
!       /*printf("%s: statmountpoint %d.%06d\n", dirName, tv1.tv_sec, tv1.tv_usec);*/
!     }
! 
!     if(rc < 0) {
!       setError(env, &obj, errno);
!       if(errno == ENOENT) {
!         setFileNotExistsAttributes(env, &obj);
!         return JNI_TRUE;   /* not really an error */
!       } else {
!         fprintf(stderr, "File::setAttributes(): uafs_statmountpoint failed "
!                         "for %s (%s)\n", dirName, error_message(errno));
!         return JNI_FALSE;
!       }
      }
  
      if (rc == 1) {
!       /* this is an AFS mount point; we don't want to stat it */
!       /* fake up a stat entry instead */
!       mtpoint = 1;
!       st.st_mtime = 0;
!       st.st_size = 2048;
!       st.st_mode = 0;  /* don't match anything */
      } else {
!       mtpoint = 0;
!       fid = (*env)->GetFieldID(env, thisClass, "isLink", "Z");
!       if (fid == 0) {
!         fprintf(stderr, "File::setAttributes(): GetFieldID (isLink) failed\n");
!         setError(env, &obj, -1);
!         return JNI_FALSE;
!       }
!       islink = (*env)->GetBooleanField(env, obj, fid);
!       if (islink != JNI_TRUE) {
!         rc = uafs_lstat(dirName, &st);
!       } else {
!         /* Here we are being called on a link object for the second time,
!            so we want info on the object pointed to by the link. */
!         fprintf(stderr, "islink = TRUE on file %s\n", dirName);
!         rc = uafs_stat(dirName, &st);
!       }
! 
!       if(rc < 0) {
!         setError(env, &obj, errno);
!         fprintf(stderr, "uafs_lstat failed for dir %s: error %d\n",
!                          dirName, errno);
!         if(errno == ENOENT) {
!           setFileNotExistsAttributes(env, &obj);
!           return JNI_TRUE;
!         }
!         fprintf(stderr, 
!             "File::setAttributes(): uafs_stat failed for %s (%s)\n", 
!              dirName, error_message(errno));
!         return JNI_FALSE;
!       }
      }
  
      fid = (*env)->GetFieldID(env, thisClass, "exists", "Z");
      if (fid == 0) {
!       fprintf(stderr, 
!             "File::setAttributes(): GetFieldID (exists) failed\n");
!       setError(env, &obj, -1);
!       return JNI_FALSE;
      }
      (*env)->SetBooleanField(env, obj, fid, JNI_TRUE);
  
      fid = (*env)->GetFieldID(env, thisClass, "isDirectory", "Z");
      if (fid == 0) {
!       fprintf(stderr, 
!             "File::setAttributes(): GetFieldID (isDirectory) failed\n");
!       setError(env, &obj, -1);
!       return JNI_FALSE;
      }
      if ((st.st_mode & S_IFMT) == S_IFDIR && !mtpoint) {
!       (*env)->SetBooleanField(env, obj, fid, JNI_TRUE);
      } else {
!       (*env)->SetBooleanField(env, obj, fid, JNI_FALSE);
      }
  
      fid = (*env)->GetFieldID(env, thisClass, "isFile", "Z");
      if (fid == 0) {
!       fprintf(stderr, 
!             "File::setAttributes(): GetFieldID (isFile) failed\n");
!       setError(env, &obj, -1);
!       return JNI_FALSE;
      }
      if ((st.st_mode & S_IFMT) == S_IFREG) {
!       (*env)->SetBooleanField(env, obj, fid, JNI_TRUE);
      } else {
!       (*env)->SetBooleanField(env, obj, fid, JNI_FALSE);
      }
  
      fid = (*env)->GetFieldID(env, thisClass, "isLink", "Z");
      if (fid == 0) {
!       fprintf(stderr, 
!             "File::setAttributes(): GetFieldID (isLink) failed\n");
!       setError(env, &obj, -1);
!       return JNI_FALSE;
!     }
! 
!     if (islink != JNI_TRUE) {    /* don't re-process link */
!       if ((st.st_mode & S_IFMT) == S_IFLNK) {
!         (*env)->SetBooleanField(env, obj, fid, JNI_TRUE);
! 
!         /* Find the target of the link */
!         rc = uafs_readlink(dirName, target, FILENAME_MAX);
!         if (rc < 0) {
!           fprintf(stderr, "File::setAttributes(): uafs_readlink failed\n");
!           setError(env, &obj, errno);
!           return JNI_FALSE;
!         } else {
!           target[rc] = 0;     /* weird that we have to do this */
!           /*fprintf(stderr, "readlink %s succeeded, target=%s, rc=%d\n", dirName,
!             target, rc);*/
!         }
! 
!         rc = setString(env, &obj, "target", target);
!         if (rc < 0) {
!           fprintf(stderr, "setString dirName=%s target=%s failed\n",
!                            dirName, target);
!         }
!       } else {
!         (*env)->SetBooleanField(env, obj, fid, JNI_FALSE);
!       }
      }
  
      fid = (*env)->GetFieldID(env, thisClass, "isMountPoint", "Z");
      if (fid == 0) {
!       fprintf(stderr, 
!             "File::setAttributes(): GetFieldID (isMountPoint) failed\n");
!       setError(env, &obj, -1);
!       return JNI_FALSE;
      }
  
      if (mtpoint) {
!       (*env)->SetBooleanField(env, obj, fid, JNI_TRUE);
      } else {
!       (*env)->SetBooleanField(env, obj, fid, JNI_FALSE);
      }
  
      fid = (*env)->GetFieldID(env, thisClass, "lastModified", "J");
      if (fid == 0) {
!       fprintf(stderr, 
!             "File::setAttributes(): GetFieldID (lastModified) failed\n");
!       setError(env, &obj, -1);
!       return JNI_FALSE;
      }
!     (*env)->SetLongField(env, obj, fid, ((jlong) st.st_mtime)*1000);
  
      fid = (*env)->GetFieldID(env, thisClass, "length", "J");
      if (fid == 0) {
!       fprintf(stderr, 
!             "File::setAttributes(): GetFieldID (length) failed\n");
!       setError(env, &obj, -1);
!       return JNI_FALSE;
      }
      (*env)->SetLongField(env, obj, fid, st.st_size);
  
***************
*** 342,349 ****
   *
   * return  permission/ACL mask
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_File_getRights(JNIEnv * env, jobject obj)
  {
      char dirName[FILENAME_MAX];
      jclass thisClass;
--- 327,334 ----
   *
   * return  permission/ACL mask
   */
! JNIEXPORT jint JNICALL Java_org_openafs_jafs_File_getRights
!   (JNIEnv *env, jobject obj)
  {
      char dirName[FILENAME_MAX];
      jclass thisClass;
***************
*** 355,364 ****
      *dirName = '\0';
      getAbsolutePath(env, &obj, dirName);
  
!     if (*dirName == '\0') {
! 	fprintf(stderr, "File::getRights(): failed to get dirName\n");
! 	setError(env, &obj, -1);
! 	return JNI_FALSE;
      }
  
      /*-Access Rights-
--- 340,349 ----
      *dirName = '\0';
      getAbsolutePath(env, &obj, dirName);
  
!     if(*dirName == '\0') {
!       fprintf(stderr, "File::getRights(): failed to get dirName\n");
!       setError(env, &obj, -1);
!       return JNI_FALSE;
      }
  
      /*-Access Rights-
***************
*** 374,398 ****
      rights = 0;
      afs_rights = uafs_getRights(dirName);
      if (afs_rights < 0) {
! 	setError(env, &obj, errno);
! 	return -1;
      }
! 
      if (afs_rights & PRSFS_READ)
! 	rights |= UAFS_READ;
      if (afs_rights & PRSFS_WRITE)
! 	rights |= UAFS_WRITE;
      if (afs_rights & PRSFS_INSERT)
! 	rights |= UAFS_INSERT;
      if (afs_rights & PRSFS_LOOKUP)
! 	rights |= UAFS_LOOKUP;
      if (afs_rights & PRSFS_DELETE)
! 	rights |= UAFS_DELETE;
      if (afs_rights & PRSFS_LOCK)
! 	rights |= UAFS_LOCK;
      if (afs_rights & PRSFS_ADMINISTER)
! 	rights |= UAFS_ADMIN;
! 
      return rights;
  }
  
--- 359,383 ----
      rights = 0;
      afs_rights = uafs_getRights(dirName);
      if (afs_rights < 0) {
!       setError(env, &obj, errno);
!       return -1;
      }
!     
      if (afs_rights & PRSFS_READ)
!       rights |= UAFS_READ;
      if (afs_rights & PRSFS_WRITE)
!       rights |= UAFS_WRITE;
      if (afs_rights & PRSFS_INSERT)
!       rights |= UAFS_INSERT;
      if (afs_rights & PRSFS_LOOKUP)
!       rights |= UAFS_LOOKUP;
      if (afs_rights & PRSFS_DELETE)
!       rights |= UAFS_DELETE;
      if (afs_rights & PRSFS_LOCK)
!       rights |= UAFS_LOCK;
      if (afs_rights & PRSFS_ADMINISTER)
!       rights |= UAFS_ADMIN;
!     
      return rights;
  }
  
***************
*** 405,414 ****
   *
   * return   the directory handle
   */
! JNIEXPORT jlong JNICALL
! Java_org_openafs_jafs_File_listNative(JNIEnv * env, jobject obj,
! 				      jobject buffer)
  {
      char dirName[FILENAME_MAX];
      jclass arrayListClass;
      jmethodID addID;
--- 390,400 ----
   *
   * return   the directory handle
   */
! JNIEXPORT jlong JNICALL Java_org_openafs_jafs_File_listNative
!   (JNIEnv *env, jobject obj, jobject buffer)
  {
+   return 0;
+ #if 0
      char dirName[FILENAME_MAX];
      jclass arrayListClass;
      jmethodID addID;
***************
*** 417,468 ****
      struct usr_dirent *enp;
      int i, dirSize;
  
!     *dirName = '\0';
      getAbsolutePath(env, &obj, dirName);
!     if (*dirName == '\0') {
! 	fprintf(stderr, "File::listNative(): failed to get dirName\n");
! 	setError(env, &obj, -1);
! 	return 0;
      }
      arrayListClass = (*env)->GetObjectClass(env, buffer);
!     if (arrayListClass == NULL) {
! 	fprintf(stderr, "File::listNative(): GetObjectClass failed\n");
! 	setError(env, &obj, -1);
! 	return 0;
!     }
!     addID =
! 	(*env)->GetMethodID(env, arrayListClass, "add",
! 			    "(Ljava/lang/Object;)Z");
!     if (addID == 0) {
! 	fprintf(stderr, "File::listNative(): failed to get addID\n");
! 	setError(env, &obj, -1);
! 	return 0;
      }
      dirp = uafs_opendir(dirName);
!     if (dirp == NULL) {
! 	fprintf(stderr, "File::listNative(): uafs_opendir(%s) failed(%s)\n",
! 		dirName, error_message(errno));
! 	setError(env, &obj, errno);
! 	//throwAFSSecurityException( env, errno );
! 	return 0;
!     }
!     while ((enp = uafs_readdir(dirp)) != NULL) {
! 	if (strcmp(enp->d_name, ".") == 0 || strcmp(enp->d_name, "..") == 0) {
! 	    continue;
  	}
! 	entryJString = (*env)->NewStringUTF(env, enp->d_name);
! 	if (entryJString == NULL) {
! 	    fprintf(stderr, "File::listNative(): NewStringUTF failed\n");
! 	    setError(env, &obj, -1);
! 	    return 0;
! 	}
! 	(*env)->CallBooleanMethod(env, buffer, addID, entryJString);
      }
!     /*uafs_closedir(dirp); */
  
      setError(env, &obj, 0);
  
      return (jlong) dirp;
  }
  
  /**
--- 403,455 ----
      struct usr_dirent *enp;
      int i, dirSize;
  
!     *dirName='\0';
      getAbsolutePath(env, &obj, dirName);
!     if(*dirName == '\0') {
!       fprintf(stderr, "File::listNative(): failed to get dirName\n");
!       setError(env, &obj, -1);
!       return 0;
      }
      arrayListClass = (*env)->GetObjectClass(env, buffer);
!     if(arrayListClass == NULL) {
!       fprintf(stderr, "File::listNative(): GetObjectClass failed\n");
!       setError(env, &obj, -1);
!       return 0;
!     }
!     addID = (*env) -> GetMethodID(env, arrayListClass, "add", 
!                                   "(Ljava/lang/Object;)Z");
!     if(addID == 0) {
!       fprintf(stderr, 
!             "File::listNative(): failed to get addID\n");
!       setError(env, &obj, -1);
!       return 0;
      }
      dirp = uafs_opendir(dirName);
!     if(dirp == NULL) {
!       fprintf(stderr, "File::listNative(): uafs_opendir(%s) failed(%s)\n",
!                        dirName, error_message(errno));
!       setError(env, &obj, errno);
!       //throwAFSSecurityException( env, errno );
!       return 0;
!     }
!     while((enp = uafs_readdir(dirp)) != NULL) {
! 	if(strcmp(enp->d_name, ".") == 0 || strcmp(enp->d_name, "..") == 0) {
!         continue;
  	}
!       entryJString = (*env) -> NewStringUTF(env, enp->d_name);
!       if(entryJString == NULL) {
!         fprintf(stderr, "File::listNative(): NewStringUTF failed\n");
!         setError(env, &obj, -1);
!         return 0;
!       }
!       (*env) -> CallBooleanMethod(env, buffer, addID, entryJString);
      }
!     /*uafs_closedir(dirp);*/
  
      setError(env, &obj, 0);
  
      return (jlong) dirp;
+ #endif
  }
  
  /**
***************
*** 473,491 ****
   *
   * return  true if the directory closes without error
   */
! JNIEXPORT jboolean JNICALL
! Java_org_openafs_jafs_File_closeDir(JNIEnv * env, jobject obj, jlong dp)
  {
-     usr_DIR *dirp = (usr_DIR *) dp;
-     int rc;
  
!     rc = uafs_closedir(dirp);
!     if (rc < 0) {
! 	setError(env, &obj, errno);
! 	return JNI_FALSE;
!     } else {
! 	return JNI_TRUE;
!     }
  }
  
  
--- 460,483 ----
   *
   * return  true if the directory closes without error
   */
! JNIEXPORT jboolean JNICALL Java_org_openafs_jafs_File_closeDir
!   (JNIEnv *env, jobject obj, jlong dp)
  {
  
!   return JNI_TRUE;
! 
! #if 0
!   usr_DIR *dirp = (usr_DIR *) dp;
!   int rc;
!   
!   rc = uafs_closedir(dirp);
!   if (rc < 0) {
!     setError(env, &obj, errno);
!     return JNI_FALSE;
!   }
!   else return JNI_TRUE;
! #endif
! 
  }
  
  
***************
*** 497,520 ****
   *
   * return  true if the file is removed without error
   */
! JNIEXPORT jboolean JNICALL
! Java_org_openafs_jafs_File_rmfile(JNIEnv * env, jobject obj)
  {
      char dirName[FILENAME_MAX];
      int rc;
  
!     *dirName = '\0';
      getAbsolutePath(env, &obj, dirName);
!     if (*dirName == '\0') {
! 	setError(env, &obj, EINVAL);
! 	fprintf(stderr, "File::rmfile(): failed to get dirName\n");
! 	return JNI_FALSE;
      }
      rc = uafs_unlink(dirName);
!     if (rc < 0) {
! 	setError(env, &obj, errno);
! 	fprintf(stderr, "File::rmfile(): uafs_unlink failed\n");
! 	return JNI_FALSE;
      }
      setError(env, &obj, 0);
      return JNI_TRUE;
--- 489,512 ----
   *
   * return  true if the file is removed without error
   */
! JNIEXPORT jboolean JNICALL Java_org_openafs_jafs_File_rmfile
!   (JNIEnv *env, jobject obj)
  {
      char dirName[FILENAME_MAX];
      int rc;
  
!     *dirName='\0';
      getAbsolutePath(env, &obj, dirName);
!     if(*dirName == '\0') {
!       setError(env, &obj, EINVAL);
!       fprintf(stderr, "File::rmfile(): failed to get dirName\n");
!       return JNI_FALSE;
      }
      rc = uafs_unlink(dirName);
!     if(rc < 0) {
!       setError(env, &obj, errno);
!       fprintf(stderr, "File::rmfile(): uafs_unlink failed\n");
!       return JNI_FALSE;
      }
      setError(env, &obj, 0);
      return JNI_TRUE;
***************
*** 528,551 ****
   *
   * return  true if the directory is removed without error
   */
! JNIEXPORT jboolean JNICALL
! Java_org_openafs_jafs_File_rmdir(JNIEnv * env, jobject obj)
  {
      char dirName[FILENAME_MAX];
      int rc;
  
!     *dirName = '\0';
      getAbsolutePath(env, &obj, dirName);
!     if (*dirName == '\0') {
! 	setError(env, &obj, -1);
! 	fprintf(stderr, "File::rmdir(): failed to get dirName\n");
! 	return JNI_FALSE;
      }
      rc = uafs_rmdir(dirName);
!     if (rc < 0) {
! 	setError(env, &obj, errno);
! 	fprintf(stderr, "File::rmdir(): uafs_unlink failed\n");
! 	return JNI_FALSE;
      }
      setError(env, &obj, 0);
      return JNI_TRUE;
--- 520,543 ----
   *
   * return  true if the directory is removed without error
   */
! JNIEXPORT jboolean JNICALL Java_org_openafs_jafs_File_rmdir
!   (JNIEnv *env, jobject obj)
  {
      char dirName[FILENAME_MAX];
      int rc;
  
!     *dirName='\0';
      getAbsolutePath(env, &obj, dirName);
!     if(*dirName == '\0') {
!       setError(env, &obj, -1);
!       fprintf(stderr, "File::rmdir(): failed to get dirName\n");
!       return JNI_FALSE;
      }
      rc = uafs_rmdir(dirName);
!     if(rc < 0) {
!       setError(env, &obj, errno);
!       fprintf(stderr, "File::rmdir(): uafs_unlink failed\n");
!       return JNI_FALSE;
      }
      setError(env, &obj, 0);
      return JNI_TRUE;
***************
*** 560,583 ****
   * return  true if and only if the directory was
   *          created; false otherwise
   */
! JNIEXPORT jboolean JNICALL
! Java_org_openafs_jafs_File_mkdir(JNIEnv * env, jobject obj)
  {
      char dirName[FILENAME_MAX];
      int rc;
  
!     *dirName = '\0';
      getAbsolutePath(env, &obj, dirName);
!     if (*dirName == '\0') {
! 	setError(env, &obj, EINVAL);
! 	fprintf(stderr, "File::mkdir(): failed to get dirName\n");
! 	return JNI_FALSE;
      }
      rc = uafs_mkdir(dirName, 0755);
!     if (rc < 0) {
! 	setError(env, &obj, errno);
! 	fprintf(stderr, "File::mkdir(): uafs_mkdir failed\n");
! 	return JNI_FALSE;
      }
      setError(env, &obj, 0);
      return JNI_TRUE;
--- 552,575 ----
   * return  true if and only if the directory was
   *          created; false otherwise
   */
! JNIEXPORT jboolean JNICALL Java_org_openafs_jafs_File_mkdir
!   (JNIEnv *env, jobject obj)
  {
      char dirName[FILENAME_MAX];
      int rc;
  
!     *dirName='\0';
      getAbsolutePath(env, &obj, dirName);
!     if(*dirName == '\0') {
!       setError(env, &obj, EINVAL);
!       fprintf(stderr, "File::mkdir(): failed to get dirName\n");
!       return JNI_FALSE;
      }
      rc = uafs_mkdir(dirName, 0755);
!     if(rc < 0) {
!       setError(env, &obj, errno);
!       fprintf(stderr, "File::mkdir(): uafs_mkdir failed\n");
!       return JNI_FALSE;
      }
      setError(env, &obj, 0);
      return JNI_TRUE;
***************
*** 596,628 ****
   * throws   NullPointerException  
   *          If parameter dest is null
   */
! JNIEXPORT jboolean JNICALL
! Java_org_openafs_jafs_File_renameTo(JNIEnv * env, jobject obj,
! 				    jobject newFile)
  {
      char thisDirName[FILENAME_MAX], newDirName[FILENAME_MAX];
      int rc;
  
!     *thisDirName = '\0';
      getAbsolutePath(env, &obj, thisDirName);
!     if (*thisDirName == '\0') {
! 	setError(env, &obj, -1);
! 	fprintf(stderr,
! 		"File::renameTo(): failed to get dirName for this \n");
! 	return JNI_FALSE;
      }
!     *newDirName = '\0';
      getAbsolutePath(env, &newFile, newDirName);
!     if (*newDirName == '\0') {
! 	setError(env, &obj, -1);
! 	fprintf(stderr, "File::renameTo(): failed to get dirName for new \n");
! 	return JNI_FALSE;
      }
      rc = uafs_rename(thisDirName, newDirName);
!     if (rc < 0) {
! 	setError(env, &obj, errno);
! 	fprintf(stderr, "File::renameTo(): uafs_rename failed\n");
! 	return JNI_FALSE;
      }
      return JNI_TRUE;
  }
--- 588,618 ----
   * throws   NullPointerException  
   *          If parameter dest is null
   */
! JNIEXPORT jboolean JNICALL Java_org_openafs_jafs_File_renameTo
!   (JNIEnv *env, jobject obj, jobject newFile)
  {
      char thisDirName[FILENAME_MAX], newDirName[FILENAME_MAX];
      int rc;
  
!     *thisDirName='\0';
      getAbsolutePath(env, &obj, thisDirName);
!     if(*thisDirName == '\0') {
!       setError(env, &obj, -1);
!       fprintf(stderr, "File::renameTo(): failed to get dirName for this \n");
!       return JNI_FALSE;
      }
!     *newDirName='\0';
      getAbsolutePath(env, &newFile, newDirName);
!     if(*newDirName == '\0') {
!       setError(env, &obj, -1);
!       fprintf(stderr, "File::renameTo(): failed to get dirName for new \n");
!       return JNI_FALSE;
      }
      rc = uafs_rename(thisDirName, newDirName);
!     if(rc < 0) {
!       setError(env, &obj, errno);
!       fprintf(stderr, "File::renameTo(): uafs_rename failed\n");
!       return JNI_FALSE;
      }
      return JNI_TRUE;
  }
***************
*** 634,692 ****
   * env      the Java environment
   * obj      the current Java object
   */
! void
! setFileNotExistsAttributes(JNIEnv * env, jobject * obj)
  {
      jclass thisClass;
      jfieldID fid;
  
!     thisClass = (*env)->GetObjectClass(env, *obj);
!     if (thisClass == NULL) {
! 	fprintf(stderr,
! 		"File::setFileNotExistsAttributes(): GetObjectClass failed\n");
! 	return;
      }
  
      fid = (*env)->GetFieldID(env, thisClass, "exists", "Z");
      if (fid == 0) {
! 	fprintf(stderr,
! 		"File::setFileNotExistsAttributes(): GetFieldID (exists) failed\n");
! 	return;
      }
      (*env)->SetBooleanField(env, *obj, fid, JNI_FALSE);
  
      fid = (*env)->GetFieldID(env, thisClass, "isDirectory", "Z");
      if (fid == 0) {
! 	fprintf(stderr,
! 		"File::setFileNotExistsAttributes(): GetFieldID (isDirectory) failed\n");
! 	return;
      }
      (*env)->SetBooleanField(env, *obj, fid, JNI_FALSE);
  
      fid = (*env)->GetFieldID(env, thisClass, "isFile", "Z");
      if (fid == 0) {
! 	fprintf(stderr,
! 		"File::setFileNotExistsAttributes(): GetFieldID (isDirectory) failed\n");
! 	return;
      }
      (*env)->SetBooleanField(env, *obj, fid, JNI_FALSE);
  
      fid = (*env)->GetFieldID(env, thisClass, "lastModified", "J");
      if (fid == 0) {
! 	fprintf(stderr,
! 		"File::setFileNotExistsAttributes(): GetFieldID (lastModified) failed\n");
! 	return;
      }
      (*env)->SetLongField(env, *obj, fid, 0);
  
! 
      fid = (*env)->GetFieldID(env, thisClass, "length", "J");
      if (fid == 0) {
! 	fprintf(stderr,
! 		"File::setFileNotExistsAttributes(): GetFieldID (length) failed\n");
! 	return;
      }
      (*env)->SetLongField(env, *obj, fid, 0);
  
      return;
  }
--- 624,684 ----
   * env      the Java environment
   * obj      the current Java object
   */
! void setFileNotExistsAttributes
!     (JNIEnv *env, jobject *obj)
  {
      jclass thisClass;
      jfieldID fid;
  
!     thisClass = (*env) -> GetObjectClass(env, *obj);
!     if(thisClass == NULL) {
!       fprintf(stderr, 
!             "File::setFileNotExistsAttributes(): GetObjectClass failed\n");
!       return;
      }
  
      fid = (*env)->GetFieldID(env, thisClass, "exists", "Z");
      if (fid == 0) {
!       fprintf(stderr, 
!             "File::setFileNotExistsAttributes(): GetFieldID (exists) failed\n");
!       return;
      }
      (*env)->SetBooleanField(env, *obj, fid, JNI_FALSE);
  
      fid = (*env)->GetFieldID(env, thisClass, "isDirectory", "Z");
      if (fid == 0) {
!       fprintf(stderr, 
!             "File::setFileNotExistsAttributes(): GetFieldID (isDirectory) failed\n");
!       return;
      }
      (*env)->SetBooleanField(env, *obj, fid, JNI_FALSE);
  
      fid = (*env)->GetFieldID(env, thisClass, "isFile", "Z");
      if (fid == 0) {
!       fprintf(stderr, 
!             "File::setFileNotExistsAttributes(): GetFieldID (isDirectory) failed\n");
!       return;
      }
      (*env)->SetBooleanField(env, *obj, fid, JNI_FALSE);
  
      fid = (*env)->GetFieldID(env, thisClass, "lastModified", "J");
      if (fid == 0) {
!       fprintf(stderr, 
!             "File::setFileNotExistsAttributes(): GetFieldID (lastModified) failed\n");
!       return;
      }
      (*env)->SetLongField(env, *obj, fid, 0);
  
!     
      fid = (*env)->GetFieldID(env, thisClass, "length", "J");
      if (fid == 0) {
!       fprintf(stderr, 
!             "File::setFileNotExistsAttributes(): GetFieldID (length) failed\n");
!       return;
      }
      (*env)->SetLongField(env, *obj, fid, 0);
  
      return;
  }
+ 
+ 
Index: openafs/src/JAVA/libjafs/FileInputStream.c
diff -c openafs/src/JAVA/libjafs/FileInputStream.c:1.3 openafs/src/JAVA/libjafs/FileInputStream.c:1.3.2.1
*** openafs/src/JAVA/libjafs/FileInputStream.c:1.3	Tue Jul 15 19:11:26 2003
--- openafs/src/JAVA/libjafs/FileInputStream.c	Fri Oct 14 22:14:11 2005
***************
*** 33,39 ****
  /**
   * Be carefull with the memory management:
   *
!  * - For every getNativeString call the corresponding free().
   * - For every Get<type>ArrayElements call the corresponding
   *   Release<type>ArrayElements
   * - For every malloc call the corresponding free.
--- 33,39 ----
  /**
   * Be carefull with the memory management:
   *
!  * - For every GetStringUTFChars call the corresponding ReleaseStringUTFChars.
   * - For every Get<type>ArrayElements call the corresponding
   *   Release<type>ArrayElements
   * - For every malloc call the corresponding free.
***************
*** 51,69 ****
   * @return		file descriptor
   * @exception	AFSFileException  if an I/O or other file related error occurs.
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_FileInputStream_openReadOnly(JNIEnv * env, jobject obj,
! 						   jstring fileNameUTF)
  {
!     int err;
!     int fd = -1;		//file descriptor
  
!     fd = openAFSFile(env, fileNameUTF, O_RDONLY, 0, &err);
!     if (fd < 0) {
! 	fprintf(stderr, "FileInputStream::openReadOnly(): err=%d\n", err);
! 	throwAFSFileException(env, err, NULL);
!     }
!     return fd;
  }
  
  /**
--- 51,68 ----
   * @return		file descriptor
   * @exception	AFSFileException  if an I/O or other file related error occurs.
   */
! JNIEXPORT jint JNICALL Java_org_openafs_jafs_FileInputStream_openReadOnly
!   (JNIEnv *env, jobject obj, jstring fileNameUTF)
  {
!   int err;
!   int fd = -1;		//file descriptor
  
!   fd = openAFSFile(env, fileNameUTF, O_RDONLY, 0, &err);
!   if (fd < 0) {
!     fprintf(stderr, "FileInputStream::openReadOnly(): err=%d\n", err);
!     throwAFSFileException( env, err, NULL );
!   }
!   return fd;
  }
  
  /**
***************
*** 82,121 ****
   *			the file has been reached.
   * @exception	AFSFileException  if an I/O or other file related error occurs.
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_FileInputStream_read(JNIEnv * env, jobject obj,
! 					   jbyteArray jbytes, jint offset,
! 					   jint length)
  {
!     int fd, bytesLen, bytesRead;
!     jclass thisClass;
!     jmethodID getFileDescriptorID;
!     jbyte *bytes;
!     jfieldID fid;
! 
!     /* If we have to read 0 bytes just return */
!     if (length == 0)
! 	return 0;
! 
!     thisClass = (*env)->GetObjectClass(env, obj);
!     fid = (*env)->GetFieldID(env, thisClass, "fileDescriptor", "I");
!     fd = (*env)->GetIntField(env, obj, fid);
! 
!     if (fd < 0) {
! 	fprintf(stderr, "FileInputStream::read(): invalid file state\n");
! 	throwAFSFileException(env, 0, "Invalid file state");
! 	return -1;
!     }
! 
!     bytes = (*env)->GetByteArrayElements(env, jbytes, 0);
!     bytesLen = (*env)->GetArrayLength(env, jbytes);
!     bytesRead = uafs_read(fd, bytes, bytesLen);
  
!     if (errno != 0)
! 	throwAFSFileException(env, errno, NULL);
  
!     (*env)->ReleaseByteArrayElements(env, jbytes, bytes, 0);
!     return (bytesRead > 0) ? bytesRead : -1;
  }
  
  /**
--- 81,116 ----
   *			the file has been reached.
   * @exception	AFSFileException  if an I/O or other file related error occurs.
   */
! JNIEXPORT jint JNICALL Java_org_openafs_jafs_FileInputStream_read
!   (JNIEnv *env, jobject obj, jbyteArray jbytes, jint offset, jint length)
  {
!   int fd, bytesLen, bytesRead;
!   jclass thisClass;
!   jmethodID getFileDescriptorID;
!   jbyte *bytes;
!   jfieldID fid;
! 
!   /* If we have to read 0 bytes just return */
!   if(length == 0) return 0;
! 
!   thisClass = (*env)->GetObjectClass(env, obj);
!   fid = (*env)->GetFieldID(env, thisClass, "fileDescriptor", "I");
!   fd = (*env)->GetIntField(env, obj, fid);
! 
!   if(fd < 0) {
!     fprintf(stderr, "FileInputStream::read(): invalid file state\n");
!     throwAFSFileException(env, 0, "Invalid file state");
!     return -1;
!   }
! 
!   bytes = (*env) -> GetByteArrayElements(env, jbytes, 0);
!   bytesLen = (*env) -> GetArrayLength(env, jbytes);
!   bytesRead = uafs_read(fd, bytes, bytesLen);
  
!   if (errno != 0) throwAFSFileException(env, errno, NULL);
  
!   (*env) -> ReleaseByteArrayElements(env, jbytes, bytes, 0);
!   return (bytesRead > 0) ? bytesRead : -1;
  }
  
  /**
***************
*** 128,155 ****
   *
   * @exception	AFSFileException  if an I/O or other file related error occurs.
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_FileInputStream_close(JNIEnv * env, jobject obj)
  {
!     int fd, rc;
!     jclass thisClass;
!     jmethodID getFileDescriptorID;
!     jfieldID fid;
!     char *bytes;
! 
!     thisClass = (*env)->GetObjectClass(env, obj);
!     fid = (*env)->GetFieldID(env, thisClass, "fileDescriptor", "I");
!     fd = (*env)->GetIntField(env, obj, fid);
! 
!     if (fd < 0) {
! 	fprintf(stderr, "FileInputStream::close(): invalid file state\n");
! 	throwAFSFileException(env, 0, "Invalid file state");
! 	return;
!     }
! 
!     rc = uafs_close(fd);
! 
!     if (rc != 0) {
! 	throwAFSFileException(env, errno, NULL);
!     }
  }
--- 123,153 ----
   *
   * @exception	AFSFileException  if an I/O or other file related error occurs.
   */
! JNIEXPORT void JNICALL Java_org_openafs_jafs_FileInputStream_close
!   (JNIEnv *env, jobject obj)
  {
!   int fd, rc;
!   jclass thisClass;
!   jmethodID getFileDescriptorID;
!   jfieldID fid;
!   char *bytes;
! 
!   thisClass = (*env)->GetObjectClass(env, obj);
!   fid = (*env)->GetFieldID(env, thisClass, "fileDescriptor", "I");
!   fd = (*env)->GetIntField(env, obj, fid);
! 
!   if(fd < 0) {
!     fprintf(stderr, "FileInputStream::close(): invalid file state\n");
!     throwAFSFileException(env, 0, "Invalid file state");
!     return;
!   }
! 
!   rc = uafs_close(fd);
! 
!   if (rc != 0) {
!     throwAFSFileException(env, errno, NULL);
!   }
  }
+ 
+ 
+ 
Index: openafs/src/JAVA/libjafs/FileOutputStream.c
diff -c openafs/src/JAVA/libjafs/FileOutputStream.c:1.3 openafs/src/JAVA/libjafs/FileOutputStream.c:1.3.2.1
*** openafs/src/JAVA/libjafs/FileOutputStream.c:1.3	Tue Jul 15 19:11:26 2003
--- openafs/src/JAVA/libjafs/FileOutputStream.c	Fri Oct 14 22:14:11 2005
***************
*** 36,42 ****
  /**
   * Be carefull with the memory management:
   *
!  * - For every getNativeString call the corresponding free().
   * - For every Get<type>ArrayElements call the corresponding
   *   Release<type>ArrayElements
   * - For every malloc call the corresponding free.
--- 36,42 ----
  /**
   * Be carefull with the memory management:
   *
!  * - For every GetStringUTFChars call the corresponding ReleaseStringUTFChars.
   * - For every Get<type>ArrayElements call the corresponding
   *   Release<type>ArrayElements
   * - For every malloc call the corresponding free.
***************
*** 54,72 ****
   * @returns		file descriptor
   * @exception	AFSFileException  if an I/O or other file related error occurs.
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_FileOutputStream_openWrite(JNIEnv * env, jobject obj,
! 						 jstring fileNameUTF)
  {
!     int err;
!     jint fd = -1;		//file descriptor
  
!     fd = openAFSFile(env, fileNameUTF, O_CREAT | O_TRUNC, 0644, &err);
!     if (fd < 0) {
! 	fprintf(stderr, "FileOutputStream::openWrite(): err=%d\n", err);
! 	throwAFSFileException(env, err, NULL);
!     }
!     return fd;
  }
  
  /**
--- 54,71 ----
   * @returns		file descriptor
   * @exception	AFSFileException  if an I/O or other file related error occurs.
   */
! JNIEXPORT jint JNICALL Java_org_openafs_jafs_FileOutputStream_openWrite
!   (JNIEnv *env, jobject obj, jstring fileNameUTF)
  {
!   int err;
!   jint fd = -1;		//file descriptor
  
!   fd = openAFSFile(env, fileNameUTF, O_CREAT | O_TRUNC, 0644, &err);
!   if (fd < 0) {
!     fprintf(stderr, "FileOutputStream::openWrite(): err=%d\n", err);
!     throwAFSFileException(env, err, NULL);
!   }
!   return fd;
  }
  
  /**
***************
*** 79,97 ****
   * @return		file descriptor
   * @exception	AFSFileException  if an I/O or other file related error occurs.
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_FileOutputStream_openAppend(JNIEnv * env, jobject obj,
! 						  jstring fileNameUTF)
  {
!     int err;
!     jint fd = -1;		//file descriptor
  
!     fd = openAFSFile(env, fileNameUTF, O_CREAT | O_APPEND, 0644, &err);
!     if (fd < 0) {
! 	fprintf(stderr, "FileOutputStream::openAppend(): err=%d\n", err);
! 	throwAFSFileException(env, err, NULL);
!     }
!     return fd;
  }
  
  /**
--- 78,95 ----
   * @return		file descriptor
   * @exception	AFSFileException  if an I/O or other file related error occurs.
   */
! JNIEXPORT jint JNICALL Java_org_openafs_jafs_FileOutputStream_openAppend
!   (JNIEnv *env, jobject obj, jstring fileNameUTF)
  {
!   int err;
!   jint fd = -1;		//file descriptor
  
!   fd = openAFSFile(env, fileNameUTF, O_CREAT | O_APPEND, 0644, &err);
!   if (fd < 0) {
!     fprintf(stderr, "FileOutputStream::openAppend(): err=%d\n", err);
!     throwAFSFileException(env, err, NULL);
!   }
!   return fd;
  }
  
  /**
***************
*** 106,115 ****
   *
   * @exception	AFSFileException  if an I/O or other file related error occurs.
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_FileOutputStream_write(JNIEnv * env, jobject obj,
! 					     jbyteArray jbytes, jint offset,
! 					     jint length)
  {
      int fd, written, toWrite;
      jint twritten;
--- 104,111 ----
   *
   * @exception	AFSFileException  if an I/O or other file related error occurs.
   */
! JNIEXPORT void JNICALL Java_org_openafs_jafs_FileOutputStream_write
!   (JNIEnv *env, jobject obj, jbyteArray jbytes, jint offset, jint length)
  {
      int fd, written, toWrite;
      jint twritten;
***************
*** 121,152 ****
      thisClass = (*env)->GetObjectClass(env, obj);
      fid = (*env)->GetFieldID(env, thisClass, "fileDescriptor", "I");
      fd = (*env)->GetIntField(env, obj, fid);
!     if (fd < 0) {
! 	fprintf(stderr, "FileOutputStream::write(): failed to get file 
!                        descriptor\n");
! 	throwAFSFileException(env, 0, "Failed to get file descriptor!");
!     }
! 
!     bytes = (char *)malloc(length);
!     if (bytes == NULL) {
! 	fprintf(stderr,
! 		"FileOutputStream::write(): malloc failed of %d bytes\n",
! 		length);
! 	throwAFSFileException(env, 0, "Failed to allocate memory!");
      }
! 
!     (*env)->GetByteArrayRegion(env, jbytes, offset, length, bytes);
      toWrite = length;
      twritten = 0;
! 
!     while (toWrite > 0) {
! 	written = uafs_write(fd, bytes, length);
! 	twritten += written;
! 	if (written < 0) {
! 	    free(bytes);
! 	    throwAFSFileException(env, errno, NULL);
! 	}
! 	toWrite -= written;
      }
      free(bytes);
  }
--- 117,144 ----
      thisClass = (*env)->GetObjectClass(env, obj);
      fid = (*env)->GetFieldID(env, thisClass, "fileDescriptor", "I");
      fd = (*env)->GetIntField(env, obj, fid);
!     if(fd < 0) {
!       fprintf(stderr, "FileOutputStream::write(): failed to get file "
!                        "descriptor\n");
!       throwAFSFileException(env, 0, "Failed to get file descriptor!");
!     }
!     bytes = (char*) malloc(length);
!     if(bytes == NULL) {
!       fprintf(stderr, "FileOutputStream::write(): malloc failed of %d bytes\n",
!                        length);
!       throwAFSFileException(env, 0, "Failed to allocate memory!");
      }
!     (*env) -> GetByteArrayRegion(env, jbytes, offset, length, bytes);
      toWrite = length;
      twritten = 0;
!     while(toWrite>0) {
!       written = uafs_write(fd, bytes, length);
!       twritten += written;
!       if(written<0) {
!         free(bytes);
!         throwAFSFileException(env, errno, NULL);
!       }
!       toWrite -= written;
      }
      free(bytes);
  }
***************
*** 161,168 ****
   *
   * @exception	AFSFileException  if an I/O or other file related error occurs.
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_FileOutputStream_close(JNIEnv * env, jobject obj)
  {
      int fd, rc;
      jclass thisClass;
--- 153,160 ----
   *
   * @exception	AFSFileException  if an I/O or other file related error occurs.
   */
! JNIEXPORT void JNICALL Java_org_openafs_jafs_FileOutputStream_close
!   (JNIEnv *env, jobject obj)
  {
      int fd, rc;
      jclass thisClass;
***************
*** 173,185 ****
      thisClass = (*env)->GetObjectClass(env, obj);
      fid = (*env)->GetFieldID(env, thisClass, "fileDescriptor", "I");
      fd = (*env)->GetIntField(env, obj, fid);
!     if (fd < 0) {
! 	fprintf(stderr,
! 		"FileOutputStream::close(): failed to get file descriptor\n");
! 	throwAFSFileException(env, 0, "Failed to get file descriptor!");
      }
      rc = uafs_close(fd);
      if (rc != 0) {
! 	throwAFSFileException(env, rc, NULL);
      }
  }
--- 165,178 ----
      thisClass = (*env)->GetObjectClass(env, obj);
      fid = (*env)->GetFieldID(env, thisClass, "fileDescriptor", "I");
      fd = (*env)->GetIntField(env, obj, fid);
!     if(fd < 0) {
!       fprintf(stderr, "FileOutputStream::close(): failed to get file descriptor\n");
!       throwAFSFileException(env, 0, "Failed to get file descriptor!");
      }
      rc = uafs_close(fd);
      if (rc != 0) {
!       throwAFSFileException(env, rc, NULL);
      }
  }
+ 
+ 
Index: openafs/src/JAVA/libjafs/GetNativeString.c
diff -c /dev/null openafs/src/JAVA/libjafs/GetNativeString.c:1.1.2.2
*** /dev/null	Sat Oct 22 02:14:46 2005
--- openafs/src/JAVA/libjafs/GetNativeString.c	Fri Oct 14 22:14:12 2005
***************
*** 0 ****
--- 1,49 ----
+ 
+ #include <jni.h>
+ #include "GetNativeString.h"
+ 
+ char* GetNativeString(JNIEnv *env, jstring jstr){
+   jbyteArray bytes = 0;
+   jthrowable exc;
+   char *result = 0;
+   
+   if ((*env)->EnsureLocalCapacity(env, 2) < 0) {
+     return 0; /* out of memory error */
+   }
+   
+   jclass stringClass=(*env)->FindClass(env,"java/lang/String");
+ 
+   if(!stringClass){
+     return 0;
+   }
+ 
+   jmethodID  MID_String_getBytes = (*env)->GetMethodID(env,stringClass,"getBytes","()[B");
+   if(!MID_String_getBytes){
+     return 0;
+   }
+ 
+   bytes = (*env)->CallObjectMethod(env, jstr,
+ 				   MID_String_getBytes);
+   exc = (*env)->ExceptionOccurred(env);
+   if (!exc) {
+     jint len = (*env)->GetArrayLength(env, bytes);
+     result = (char *)malloc(len + 1);
+     if (result == 0) {
+ 
+       /*JNU_ThrowByName(env, "java/lang/OutOfMemoryError",
+ 	0);*/
+ 
+       (*env)->DeleteLocalRef(env, bytes);
+       return 0;
+     }
+     (*env)->GetByteArrayRegion(env, bytes, 0, len,
+ 			       (jbyte *)result);
+     result[len] = 0; /* NULL-terminate */
+   } else {
+     (*env)->DeleteLocalRef(env, exc);
+   }
+   (*env)->DeleteLocalRef(env, bytes);
+      return result;  
+ }
+ 
+ jstring GetJavaString(JNIEnv *env, char*);
Index: openafs/src/JAVA/libjafs/GetNativeString.h
diff -c /dev/null openafs/src/JAVA/libjafs/GetNativeString.h:1.1.2.2
*** /dev/null	Sat Oct 22 02:14:46 2005
--- openafs/src/JAVA/libjafs/GetNativeString.h	Fri Oct 14 22:14:12 2005
***************
*** 0 ****
--- 1,6 ----
+ 
+ #include <jni.h>
+ #include <stdlib.h>
+ 
+ char* GetNativeString(JNIEnv *env, jstring jstr);
+ jstring GetJavaString(JNIEnv *env, char*);
Index: openafs/src/JAVA/libjafs/Group.c
diff -c openafs/src/JAVA/libjafs/Group.c:1.3 openafs/src/JAVA/libjafs/Group.c:1.3.2.1
*** openafs/src/JAVA/libjafs/Group.c:1.3	Tue Jul 15 19:11:26 2003
--- openafs/src/JAVA/libjafs/Group.c	Fri Oct 14 22:14:12 2005
***************
*** 65,124 ****
   * gid     the group id to assign to the group (0 to have one 
   *                automatically assigned)
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Group_create(JNIEnv * env, jclass cls, jint cellHandle,
! 				   jstring jgroupName, jstring jownerName,
! 				   jint gid)
! {
!     afs_status_t ast;
!     // convert java strings
!     char *groupName;
!     char *ownerName;
! 
!     if (jgroupName != NULL) {
! 	groupName = getNativeString(env, jgroupName);
! 	if (groupName == NULL) {
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	throwAFSException(env, JAFSNULLGROUP);
! 	return;
!     }
  
!     if (jownerName != NULL) {
! 	ownerName = getNativeString(env, jownerName);
! 	if (ownerName == NULL) {
! 	    free(groupName);
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	free(groupName);
! 	throwAFSException(env, JAFSNULLOWNER);
! 	return;
!     }
! 
!     // make sure the name is within the allowed bounds
!     if (strlen(groupName) > PTS_MAX_NAME_LEN) {
! 	// release converted java strings
! 	free(groupName);
! 	free(ownerName);
! 	throwAFSException(env, ADMPTSGROUPNAMETOOLONG);
! 	return;
!     }
! 
!     if (!pts_GroupCreate
! 	((void *)cellHandle, groupName, ownerName, (int *)&gid, &ast)) {
! 	// release converted java strings
! 	free(groupName);
! 	free(ownerName);
! 	throwAFSException(env, ast);
! 	return;
      }
      // release converted java strings
!     free(groupName);
!     free(ownerName);
  }
  
  /**
--- 65,134 ----
   * gid     the group id to assign to the group (0 to have one 
   *                automatically assigned)
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Group_create
!   (JNIEnv *env, jclass cls, jlong cellHandle, jstring jgroupName, 
!    jstring jownerName, jint gid )
! {
!   afs_status_t ast;
!   // convert java strings
!   const char *groupName;
!   const char *ownerName;
! 
!   if( jgroupName != NULL ) {
!     groupName = (*env)->GetStringUTFChars(env, jgroupName, 0);
!     if( !groupName ) {
! 	throwAFSException( env, JAFSADMNOMEM );
! 	return;    
!     }
!   } else {
!     groupName = NULL;
!   }
! 
!   if( jownerName != NULL ) {
!     ownerName = (*env)->GetStringUTFChars(env, jownerName, 0);
!     if( !ownerName ) {
! 	throwAFSException( env, JAFSADMNOMEM );
! 	return;    
!     }
!   } else {
!     ownerName = NULL;
!   }
  
!   // make sure the name is within the allowed bounds
!   if( groupName != NULL && strlen( groupName ) > PTS_MAX_NAME_LEN ) {
!     // release converted java strings
!     if( groupName != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
!     }
!     if( ownerName != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jownerName, ownerName);
      }
+     throwAFSException( env, ADMPTSGROUPNAMETOOLONG );
+     return;
+   }
+   
+   if( !pts_GroupCreate( (void *) cellHandle, groupName, ownerName, 
+ 			(int *) &gid, &ast ) ) {
      // release converted java strings
!     if( groupName != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
!     }
!     if( ownerName != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jownerName, ownerName);
!     }
!     throwAFSException( env, ast );
!     return;
!   }
! 
!   // release converted java strings
!   if( groupName != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
!   }
!   if( ownerName != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, jownerName, ownerName);
!   }
! 
  }
  
  /**
***************
*** 131,160 ****
   * cellHandle    the handle of the cell to which the group belongs
   * jgroupName      the name of the group to delete
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Group_delete(JNIEnv * env, jclass cls, jint cellHandle,
! 				   jstring jgroupName)
! {
!     afs_status_t ast;
!     // convert java strings
!     char *groupName;
! 
!     if (jgroupName != NULL) {
! 	groupName = getNativeString(env, jgroupName);
! 	if (!groupName) {
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	throwAFSException(env, JAFSNULLGROUP);
! 	return;
!     }
  
-     if (!pts_GroupDelete((void *)cellHandle, groupName, &ast)) {
- 	throwAFSException(env, ast);
-     }
-     // release converted java strings
-     free(groupName);
  }
  
  /**
--- 141,177 ----
   * cellHandle    the handle of the cell to which the group belongs
   * jgroupName      the name of the group to delete
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Group_delete
!   (JNIEnv *env, jclass cls, jlong cellHandle, jstring jgroupName )
! {
!   afs_status_t ast;
!   // convert java strings
!   const char *groupName;
! 
!   if( jgroupName != NULL ) {
!     groupName = (*env)->GetStringUTFChars(env, jgroupName, 0);
!     if( !groupName ) {
! 	throwAFSException( env, JAFSADMNOMEM );
! 	return;    
!     }
!   } else {
!     groupName = NULL;
!   }
! 
!   if( !pts_GroupDelete( (void *) cellHandle, groupName, &ast ) ) {
!     if( groupName != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
!     }
!     throwAFSException( env, ast );
!     return;
!   }
!   
!   // release converted java strings
!   if( groupName != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
!   }
  
  }
  
  /**
***************
*** 166,256 ****
   * name      the name of the group for which to get the info
   * group      the Group object to populate with the info
   */
! void
! getGroupInfoChar(JNIEnv * env, jint cellHandle, const char *name,
! 		 jobject group)
! {
! 
!     jstring jowner;
!     jstring jcreator;
!     pts_GroupEntry_t entry;
!     afs_status_t ast;
!     // get the field ids if you haven't already
!     if (groupCls == 0) {
! 	internal_getGroupClass(env, group);
!     }
! 
!     if (!pts_GroupGet((void *)cellHandle, name, &entry, &ast)) {
! 	throwAFSException(env, ast);
! 	return;
!     }
!     // set the fields
!     (*env)->SetIntField(env, group, group_nameUidField, entry.nameUid);
!     (*env)->SetIntField(env, group, group_ownerUidField, entry.ownerUid);
!     (*env)->SetIntField(env, group, group_creatorUidField, entry.creatorUid);
!     (*env)->SetIntField(env, group, group_membershipCountField,
! 			entry.membershipCount);
! 
!     if (entry.listStatus == PTS_GROUP_OWNER_ACCESS) {
! 	(*env)->SetIntField(env, group, group_listStatusField,
! 			    org_openafs_jafs_Group_GROUP_OWNER_ACCESS);
!     } else if (entry.listStatus == PTS_GROUP_ACCESS) {
! 	(*env)->SetIntField(env, group, group_listStatusField,
! 			    org_openafs_jafs_Group_GROUP_GROUP_ACCESS);
!     } else {
! 	(*env)->SetIntField(env, group, group_listStatusField,
! 			    org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS);
!     }
  
!     if (entry.listGroupsOwned == PTS_GROUP_OWNER_ACCESS) {
! 	(*env)->SetIntField(env, group, group_listGroupsOwnedField,
! 			    org_openafs_jafs_Group_GROUP_OWNER_ACCESS);
!     } else if (entry.listGroupsOwned == PTS_GROUP_ACCESS) {
! 	(*env)->SetIntField(env, group, group_listGroupsOwnedField,
! 			    org_openafs_jafs_Group_GROUP_GROUP_ACCESS);
!     } else {
! 	(*env)->SetIntField(env, group, group_listGroupsOwnedField,
! 			    org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS);
!     }
  
!     if (entry.listMembership == PTS_GROUP_OWNER_ACCESS) {
! 	(*env)->SetIntField(env, group, group_listMembershipField,
! 			    org_openafs_jafs_Group_GROUP_OWNER_ACCESS);
!     } else if (entry.listMembership == PTS_GROUP_ACCESS) {
! 	(*env)->SetIntField(env, group, group_listMembershipField,
! 			    org_openafs_jafs_Group_GROUP_GROUP_ACCESS);
!     } else {
! 	(*env)->SetIntField(env, group, group_listMembershipField,
! 			    org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS);
!     }
  
!     if (entry.listAdd == PTS_GROUP_OWNER_ACCESS) {
! 	(*env)->SetIntField(env, group, group_listAddField,
! 			    org_openafs_jafs_Group_GROUP_OWNER_ACCESS);
!     } else if (entry.listAdd == PTS_GROUP_ACCESS) {
! 	(*env)->SetIntField(env, group, group_listAddField,
! 			    org_openafs_jafs_Group_GROUP_GROUP_ACCESS);
!     } else {
! 	(*env)->SetIntField(env, group, group_listAddField,
! 			    org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS);
!     }
  
-     if (entry.listDelete == PTS_GROUP_OWNER_ACCESS) {
- 	(*env)->SetIntField(env, group, group_listDeleteField,
- 			    org_openafs_jafs_Group_GROUP_OWNER_ACCESS);
-     } else if (entry.listDelete == PTS_GROUP_ACCESS) {
- 	(*env)->SetIntField(env, group, group_listDeleteField,
- 			    org_openafs_jafs_Group_GROUP_GROUP_ACCESS);
-     } else {
- 	(*env)->SetIntField(env, group, group_listDeleteField,
- 			    org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS);
-     }
- 
-     jowner = (*env)->NewStringUTF(env, entry.owner);
-     jcreator = (*env)->NewStringUTF(env, entry.creator);
- 
-     (*env)->SetObjectField(env, group, group_ownerField, jowner);
-     (*env)->SetObjectField(env, group, group_creatorField, jcreator);
  }
  
  /**
--- 183,274 ----
   * name      the name of the group for which to get the info
   * group      the Group object to populate with the info
   */
! void getGroupInfoChar
!   ( JNIEnv *env, void *cellHandle, const char *name, jobject group )
! {
  
!   jstring jowner;
!   jstring jcreator;
!   pts_GroupEntry_t entry;
!   afs_status_t ast;
! 
!   // get the field ids if you haven't already
!   if( groupCls == 0 ) {
!     internal_getGroupClass( env, group );
!   }
!   if ( !pts_GroupGet( cellHandle, name, &entry, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
! 
!   // set the fields
!   (*env)->SetIntField(env, group, group_nameUidField, entry.nameUid);
!   (*env)->SetIntField(env, group, group_ownerUidField, entry.ownerUid);
!   (*env)->SetIntField(env, group, group_creatorUidField, entry.creatorUid);
!   (*env)->SetIntField(env, group, group_membershipCountField, 
! 		      entry.membershipCount);
! 
!   if( entry.listStatus == PTS_GROUP_OWNER_ACCESS ) {
!       (*env)->SetIntField(env, group, group_listStatusField, 
! 			  org_openafs_jafs_Group_GROUP_OWNER_ACCESS);
!   } else if( entry.listStatus == PTS_GROUP_ACCESS ) {
!       (*env)->SetIntField(env, group, group_listStatusField, 
! 			  org_openafs_jafs_Group_GROUP_GROUP_ACCESS);
!   } else {
!       (*env)->SetIntField(env, group, group_listStatusField, 
! 			  org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS);
!   }
! 
!   if( entry.listGroupsOwned == PTS_GROUP_OWNER_ACCESS ) {
!       (*env)->SetIntField(env, group, group_listGroupsOwnedField, 
! 			  org_openafs_jafs_Group_GROUP_OWNER_ACCESS);
!   } else if( entry.listGroupsOwned == PTS_GROUP_ACCESS ) {
!       (*env)->SetIntField(env, group, group_listGroupsOwnedField, 
! 			  org_openafs_jafs_Group_GROUP_GROUP_ACCESS);
!   } else {
!       (*env)->SetIntField(env, group, group_listGroupsOwnedField, 
! 			  org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS);
!   }
! 
!   if( entry.listMembership == PTS_GROUP_OWNER_ACCESS ) {
!       (*env)->SetIntField(env, group, group_listMembershipField, 
! 			  org_openafs_jafs_Group_GROUP_OWNER_ACCESS);
!   } else if( entry.listMembership == PTS_GROUP_ACCESS ) {
!       (*env)->SetIntField(env, group, group_listMembershipField, 
! 			  org_openafs_jafs_Group_GROUP_GROUP_ACCESS);
!   } else {
!       (*env)->SetIntField(env, group, group_listMembershipField, 
! 			  org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS);
!   }
! 
!   if( entry.listAdd == PTS_GROUP_OWNER_ACCESS ) {
!       (*env)->SetIntField(env, group, group_listAddField, 
! 			  org_openafs_jafs_Group_GROUP_OWNER_ACCESS);
!   } else if( entry.listAdd == PTS_GROUP_ACCESS ) {
!       (*env)->SetIntField(env, group, group_listAddField, 
! 			  org_openafs_jafs_Group_GROUP_GROUP_ACCESS);
!   } else {
!       (*env)->SetIntField(env, group, group_listAddField, 
! 			  org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS);
!   }
! 
!   if( entry.listDelete == PTS_GROUP_OWNER_ACCESS ) {
!       (*env)->SetIntField(env, group, group_listDeleteField, 
! 			  org_openafs_jafs_Group_GROUP_OWNER_ACCESS);
!   } else if( entry.listDelete == PTS_GROUP_ACCESS ) {
!       (*env)->SetIntField(env, group, group_listDeleteField, 
! 			  org_openafs_jafs_Group_GROUP_GROUP_ACCESS);
!   } else {
!       (*env)->SetIntField(env, group, group_listDeleteField, 
! 			  org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS);
!   }
  
!   jowner = (*env)->NewStringUTF(env, entry.owner);
!   jcreator =  (*env)->NewStringUTF(env, entry.creator);
  
!   (*env)->SetObjectField(env, group, group_ownerField, jowner);
!   (*env)->SetObjectField(env, group, group_creatorField, jcreator);
  
  }
  
  /**
***************
*** 264,296 ****
   * group     the Group object in which to fill in the 
   *                  information
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Group_getGroupInfo(JNIEnv * env, jclass cls,
! 					 jint cellHandle, jstring jname,
! 					 jobject group)
! {
!     char *name;
! 
!     if (jname != NULL) {
! 	name = getNativeString(env, jname);
! 	if (!name) {
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	throwAFSException(env, JAFSNULLGROUP);
! 	return;
!     }
!     getGroupInfoChar(env, cellHandle, name, group);
! 
!     // get class fields if need be
!     if (groupCls == 0) {
! 	internal_getGroupClass(env, group);
!     }
!     // set name in case blank object
!     (*env)->SetObjectField(env, group, group_nameField, jname);
  
-     free(name);
  }
  
  /**
--- 282,317 ----
   * group     the Group object in which to fill in the 
   *                  information
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Group_getGroupInfo
!   (JNIEnv *env, jclass cls, jlong cellHandle, jstring jname, jobject group)
! {
! 
!   const char *name;
! 
!   if( jname != NULL ) {
!     name = (*env)->GetStringUTFChars(env, jname, 0);
!     if( !name ) {
! 	throwAFSException( env, JAFSADMNOMEM );
! 	return;    
!     }
!   } else {
!     name = NULL;
!   }
!   getGroupInfoChar( env, (void *)cellHandle, name, group );
! 
!   // get class fields if need be
!   if( groupCls == 0 ) {
!     internal_getGroupClass( env, group );
!   }
! 
!   // set name in case blank object
!   (*env)->SetObjectField(env, group, group_nameField, jname);
! 
!   if( name != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, jname, name);
!   }
  
  }
  
  /**
***************
*** 302,387 ****
   * name     the name of the user for which to set the information
   * theGroup   the group object containing the desired information
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Group_setGroupInfo(JNIEnv * env, jclass cls,
! 					 jint cellHandle, jstring jname,
! 					 jobject group)
! {
!     char *name;
!     pts_GroupUpdateEntry_t ptsEntry;
!     afs_status_t ast;
! 
!     jint jlistStatus;
!     jint jlistGroupsOwned;
!     jint jlistMembership;
!     jint jlistAdd;
!     jint jlistDelete;
! 
!     // get the field ids if you haven't already
!     if (groupCls == 0) {
! 	internal_getGroupClass(env, group);
!     }
! 
!     jlistStatus = (*env)->GetIntField(env, group, group_listStatusField);
!     jlistGroupsOwned =
! 	(*env)->GetIntField(env, group, group_listGroupsOwnedField);
!     jlistMembership =
! 	(*env)->GetIntField(env, group, group_listMembershipField);
!     jlistAdd = (*env)->GetIntField(env, group, group_listAddField);
!     jlistDelete = (*env)->GetIntField(env, group, group_listDeleteField);
! 
!     if (jname != NULL) {
! 	name = getNativeString(env, jname);
! 	if (name == NULL) {
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	throwAFSException(env, JAFSNULLGROUP);
! 	return;
!     }
! 
!     if (jlistStatus == org_openafs_jafs_Group_GROUP_OWNER_ACCESS) {
! 	ptsEntry.listStatus = PTS_GROUP_OWNER_ACCESS;
!     } else if (jlistStatus == org_openafs_jafs_Group_GROUP_GROUP_ACCESS) {
! 	ptsEntry.listStatus = PTS_GROUP_ACCESS;
!     } else {
! 	ptsEntry.listStatus = PTS_GROUP_ANYUSER_ACCESS;
!     }
!     if (jlistGroupsOwned == org_openafs_jafs_Group_GROUP_OWNER_ACCESS) {
! 	ptsEntry.listGroupsOwned = PTS_GROUP_OWNER_ACCESS;
!     } else if (jlistGroupsOwned == org_openafs_jafs_Group_GROUP_GROUP_ACCESS) {
! 	ptsEntry.listGroupsOwned = PTS_GROUP_ACCESS;
!     } else {
! 	ptsEntry.listGroupsOwned = PTS_GROUP_ANYUSER_ACCESS;
!     }
!     if (jlistMembership == org_openafs_jafs_Group_GROUP_OWNER_ACCESS) {
! 	ptsEntry.listMembership = PTS_GROUP_OWNER_ACCESS;
!     } else if (jlistMembership == org_openafs_jafs_Group_GROUP_GROUP_ACCESS) {
! 	ptsEntry.listMembership = PTS_GROUP_ACCESS;
!     } else {
! 	ptsEntry.listMembership = PTS_GROUP_ANYUSER_ACCESS;
!     }
!     if (jlistAdd == org_openafs_jafs_Group_GROUP_OWNER_ACCESS) {
! 	ptsEntry.listAdd = PTS_GROUP_OWNER_ACCESS;
!     } else if (jlistAdd == org_openafs_jafs_Group_GROUP_GROUP_ACCESS) {
! 	ptsEntry.listAdd = PTS_GROUP_ACCESS;
!     } else {
! 	ptsEntry.listAdd = PTS_GROUP_ANYUSER_ACCESS;
!     }
!     if (jlistDelete == org_openafs_jafs_Group_GROUP_OWNER_ACCESS) {
! 	ptsEntry.listDelete = PTS_GROUP_OWNER_ACCESS;
!     } else if (jlistDelete == org_openafs_jafs_Group_GROUP_GROUP_ACCESS) {
! 	ptsEntry.listDelete = PTS_GROUP_ACCESS;
!     } else {
! 	ptsEntry.listDelete = PTS_GROUP_ANYUSER_ACCESS;
!     }
  
-     if (!pts_GroupModify((void *)cellHandle, name, &ptsEntry, &ast)) {
- 	throwAFSException(env, ast);
-     }
- 
-     free(name);
  }
  
  /**
--- 323,413 ----
   * name     the name of the user for which to set the information
   * theGroup   the group object containing the desired information
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Group_setGroupInfo
!   (JNIEnv *env, jclass cls, jlong cellHandle, jstring jname, jobject group)
! {
!   const char *name;
!   pts_GroupUpdateEntry_t ptsEntry;
!   afs_status_t ast;
! 
!   jint jlistStatus;
!   jint jlistGroupsOwned;
!   jint jlistMembership;
!   jint jlistAdd;
!   jint jlistDelete;
! 
!   // get the field ids if you haven't already
!   if( groupCls == 0 ) {
!     internal_getGroupClass( env, group );
!   }
! 
!   jlistStatus = (*env)->GetIntField(env, group, group_listStatusField);
!   jlistGroupsOwned = (*env)->GetIntField(env, group, 
! 					 group_listGroupsOwnedField);
!   jlistMembership = (*env)->GetIntField(env, group, group_listMembershipField);
!   jlistAdd = (*env)->GetIntField(env, group, group_listAddField);
!   jlistDelete = (*env)->GetIntField(env, group, group_listDeleteField);
! 
!   if( jname != NULL ) {
!     name = (*env)->GetStringUTFChars(env, jname, 0);
!     if( !name ) {
! 	throwAFSException( env, JAFSADMNOMEM );
! 	return;    
!     }
!   } else {
!     name = NULL;
!   }
! 
!   if( jlistStatus == org_openafs_jafs_Group_GROUP_OWNER_ACCESS ) {
!     ptsEntry.listStatus = PTS_GROUP_OWNER_ACCESS;
!   } else if( jlistStatus == org_openafs_jafs_Group_GROUP_GROUP_ACCESS ) {
!     ptsEntry.listStatus = PTS_GROUP_ACCESS;
!   } else {
!     ptsEntry.listStatus = PTS_GROUP_ANYUSER_ACCESS;
!   }
!   if( jlistGroupsOwned == org_openafs_jafs_Group_GROUP_OWNER_ACCESS ) {
!     ptsEntry.listGroupsOwned = PTS_GROUP_OWNER_ACCESS;
!   } else if( jlistGroupsOwned == 
! 	     org_openafs_jafs_Group_GROUP_GROUP_ACCESS ) {
!     ptsEntry.listGroupsOwned = PTS_GROUP_ACCESS;
!   } else {
!     ptsEntry.listGroupsOwned = PTS_GROUP_ANYUSER_ACCESS;
!   }
!   if( jlistMembership == org_openafs_jafs_Group_GROUP_OWNER_ACCESS ) {
!     ptsEntry.listMembership = PTS_GROUP_OWNER_ACCESS;
!   } else if( jlistMembership == 
! 	     org_openafs_jafs_Group_GROUP_GROUP_ACCESS ) {
!     ptsEntry.listMembership = PTS_GROUP_ACCESS;
!   } else {
!     ptsEntry.listMembership = PTS_GROUP_ANYUSER_ACCESS;
!   }
!   if( jlistAdd == org_openafs_jafs_Group_GROUP_OWNER_ACCESS ) {
!     ptsEntry.listAdd = PTS_GROUP_OWNER_ACCESS;
!   } else if( jlistAdd == org_openafs_jafs_Group_GROUP_GROUP_ACCESS ) {
!     ptsEntry.listAdd = PTS_GROUP_ACCESS;
!   } else {
!     ptsEntry.listAdd = PTS_GROUP_ANYUSER_ACCESS;
!   }
!   if( jlistDelete == org_openafs_jafs_Group_GROUP_OWNER_ACCESS ) {
!     ptsEntry.listDelete = PTS_GROUP_OWNER_ACCESS;
!   } else if( jlistDelete == org_openafs_jafs_Group_GROUP_GROUP_ACCESS ) {
!     ptsEntry.listDelete = PTS_GROUP_ACCESS;
!   } else {
!     ptsEntry.listDelete = PTS_GROUP_ANYUSER_ACCESS;
!   }
!   if( !pts_GroupModify( (void *) cellHandle, name, &ptsEntry, &ast ) ) {
!     if( name != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jname, name);
!     }
!     throwAFSException( env, ast );
!     return;    
!   }
! 
!   if( name != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, jname, name);
!   }
  
  }
  
  /**
***************
*** 395,428 ****
   * jname          the name of the group for which to get the members
   * returns an iteration ID
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Group_getGroupMembersBegin(JNIEnv * env, jclass cls,
! 						 jint cellHandle,
! 						 jstring jname)
! {
!     char *name;
!     afs_status_t ast;
!     void *iterationId;
! 
!     if (jname != NULL) {
! 	name = getNativeString(env, jname);
! 	if (name == NULL) {
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return 0;
! 	}
!     } else {
! 	throwAFSException(env, JAFSNULLGROUP);
! 	return 0;
!     }
! 
!     if (!pts_GroupMemberListBegin
! 	((void *)cellHandle, name, &iterationId, &ast)) {
! 	throwAFSException(env, ast);
!     }
  
!     free(name);
  
-     return (jint) iterationId;
  }
  
  /**
--- 421,459 ----
   * jname          the name of the group for which to get the members
   * returns an iteration ID
   */
! JNIEXPORT jlong JNICALL 
! Java_org_openafs_jafs_Group_getGroupMembersBegin
!   (JNIEnv *env, jclass cls, jlong cellHandle, jstring jname)
! {
!   const char *name;
!   afs_status_t ast;
!   void *iterationId;
! 
!   if( jname != NULL ) {
!     name = (*env)->GetStringUTFChars(env, jname, 0);
!     if( !name ) {
! 	throwAFSException( env, JAFSADMNOMEM );
! 	return;    
!     }
!   } else {
!     name = NULL;
!   }
! 
!   if( !pts_GroupMemberListBegin( (void *) cellHandle, name, &iterationId, 
! 				 &ast ) ) {
!     if( name != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jname, name);
!     }
!     throwAFSException( env, ast );
!     return;
!   }
! 
!   if( name != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, jname, name);
!   }
  
!   return (jlong) iterationId;
  
  }
  
  /**
***************
*** 434,466 ****
   * iterationId   the iteration ID of this iteration
   * returns the name of the next member
   */
! JNIEXPORT jstring JNICALL
! Java_org_openafs_jafs_Group_getGroupMembersNextString(JNIEnv * env,
! 						      jclass cls,
! 						      jint iterationId)
! {
!     afs_status_t ast;
!     char *userName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN);
!     jstring juser;
! 
!     if (!userName) {
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return;
!     }
! 
!     if (!pts_GroupMemberListNext((void *)iterationId, userName, &ast)) {
! 	free(userName);
! 	if (ast == ADMITERATORDONE) {
! 	    return NULL;
! 	} else {
! 	    throwAFSException(env, ast);
! 	    return;
! 	}
!     }
! 
!     juser = (*env)->NewStringUTF(env, userName);
!     free(userName);
!     return juser;
  }
  
  /**
--- 465,496 ----
   * iterationId   the iteration ID of this iteration
   * returns the name of the next member
   */
! JNIEXPORT jstring JNICALL 
! Java_org_openafs_jafs_Group_getGroupMembersNextString
!   (JNIEnv *env, jclass cls, jlong iterationId)
! {
!   afs_status_t ast;
!   char *userName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN);
!   jstring juser;
! 
!   if( !userName ) {
!     throwAFSException( env, JAFSADMNOMEM );
!     return;    
!   }
! 
!   if( !pts_GroupMemberListNext( (void *) iterationId, userName, &ast ) ) {
!     free( userName );
!     if( ast == ADMITERATORDONE ) {
!       return NULL;
!     } else {
!       throwAFSException( env, ast );
!       return;
!     }
!   }
!   
!   juser = (*env)->NewStringUTF(env, userName);
!   free( userName );
!   return juser;
  }
  
  /**
***************
*** 475,520 ****
   *                  next user
   * returns 0 if there are no more users, != 0 otherwise
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Group_getGroupMembersNext(JNIEnv * env, jclass cls,
! 						jint cellHandle,
! 						jint iterationId,
! 						jobject juserObject)
  {
!     afs_status_t ast;
!     char *userName;
!     jstring juser;
  
!     userName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN);
  
!     if (!userName) {
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return;
!     }
  
!     if (!pts_GroupMemberListNext((void *)iterationId, userName, &ast)) {
! 	free(userName);
! 	if (ast == ADMITERATORDONE) {
! 	    return 0;
! 	} else {
! 	    throwAFSException(env, ast);
! 	    return 0;
! 	}
      }
  
!     juser = (*env)->NewStringUTF(env, userName);
  
!     if (userCls == 0) {
! 	internal_getUserClass(env, juserObject);
!     }
  
!     (*env)->SetObjectField(env, juserObject, user_nameField, juser);
  
!     getUserInfoChar(env, (void *)cellHandle, userName, juserObject);
!     (*env)->SetBooleanField(env, juserObject, user_cachedInfoField, TRUE);
  
!     free(userName);
!     return 1;
  
  }
  
--- 505,549 ----
   *                  next user
   * returns 0 if there are no more users, != 0 otherwise
   */
! JNIEXPORT jint JNICALL 
! Java_org_openafs_jafs_Group_getGroupMembersNext
!   (JNIEnv *env, jclass cls, jlong cellHandle, jlong iterationId,
!    jobject juserObject)
  {
!   afs_status_t ast;
!   char *userName;
!   jstring juser;
  
!   userName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN);
  
!   if( !userName ) {
!     throwAFSException( env, JAFSADMNOMEM );
!     return;    
!   }
  
!   if( !pts_GroupMemberListNext( (void *) iterationId, userName, &ast ) ) {
!     free( userName );
!     if( ast == ADMITERATORDONE ) {
!       return 0;
!     } else {
!       throwAFSException( env, ast );
!       return 0;
      }
+   }
  
!   juser = (*env)->NewStringUTF(env, userName);
  
!   if( userCls == 0 ) {
!     internal_getUserClass( env, juserObject );
!   }
  
!   (*env)->SetObjectField(env, juserObject, user_nameField, juser);
  
!   getUserInfoChar( env, (void *) cellHandle, userName, juserObject );
!   (*env)->SetBooleanField( env, juserObject, user_cachedInfoField, TRUE );
  
!   free( userName );
!   return 1;
  
  }
  
***************
*** 525,540 ****
   * cls      the current Java class
   * iterationId   the iteration ID of this iteration
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Group_getGroupMembersDone(JNIEnv * env, jclass cls,
! 						jint iterationId)
! {
!     afs_status_t ast;
! 
!     if (!pts_GroupMemberListDone((void *)iterationId, &ast)) {
! 	throwAFSException(env, ast);
! 	return;
!     }
  }
  
  /**
--- 554,570 ----
   * cls      the current Java class
   * iterationId   the iteration ID of this iteration
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Group_getGroupMembersDone
!   (JNIEnv *env, jclass cls, jlong iterationId)
! {
!   afs_status_t ast;
! 
!   if( !pts_GroupMemberListDone( (void *) iterationId, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
! 
  }
  
  /**
***************
*** 546,590 ****
   * jgroupName          the name of the group to which to add a member
   * juserName      the name of the user to add
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Group_addMember(JNIEnv * env, jclass cls,
! 				      jint cellHandle, jstring jgroupName,
! 				      jstring juserName)
! {
!     afs_status_t ast;
!     char *groupName;
!     char *userName;
! 
!     if (jgroupName != NULL) {
! 	groupName = getNativeString(env, jgroupName);
! 	if (groupName == NULL) {
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	throwAFSException(env, JAFSNULLGROUP);
! 	return;
!     }
! 
!     if (juserName != NULL) {
! 	userName = getNativeString(env, juserName);
! 	if (userName == NULL) {
! 	    free(groupName);
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	free(groupName);
! 	throwAFSException(env, JAFSNULLUSER);
! 	return;
!     }
! 
!     if (!pts_GroupMemberAdd((void *)cellHandle, userName, groupName, &ast)) {
! 	throwAFSException(env, ast);
!     }
! 
!     free(userName);
!     free(groupName);
  }
  
  /**
--- 576,630 ----
   * jgroupName          the name of the group to which to add a member
   * juserName      the name of the user to add
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Group_addMember
!   (JNIEnv *env, jclass cls, jlong cellHandle, jstring jgroupName,
!    jstring juserName )
! {
!   afs_status_t ast;
!   const char *groupName;
!   const char *userName;
! 
!   if( jgroupName != NULL ) {
!     groupName = (*env)->GetStringUTFChars(env, jgroupName, 0);
!     if( !groupName ) {
! 	throwAFSException( env, JAFSADMNOMEM );
! 	return;    
!     }
!   } else {
!     groupName = NULL;
!   }
! 
!   if( juserName != NULL ) {
!     userName = (*env)->GetStringUTFChars(env, juserName, 0);
!     if( !userName ) {
!       if( groupName != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
!       }
!       throwAFSException( env, JAFSADMNOMEM );
!       return;    
!     }
!   } else {
!     userName = NULL;
!   }
! 
!   if( !pts_GroupMemberAdd( (void *) cellHandle, userName, groupName, &ast ) ) {
!     if( groupName != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
!     }
!     if( userName != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, juserName, userName);
!     }
!     throwAFSException( env, ast );
!     return;
!   }
! 
!   if( groupName != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
!   }
!   if( userName != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, juserName, userName);
!   }
  }
  
  /**
***************
*** 597,641 ****
   *                           member
   * juserName      the name of the user to remove
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Group_removeMember(JNIEnv * env, jclass cls,
! 					 jint cellHandle, jstring jgroupName,
! 					 jstring juserName)
! {
!     afs_status_t ast;
!     char *groupName;
!     char *userName;
! 
!     if (jgroupName != NULL) {
! 	groupName = getNativeString(env, jgroupName);
! 	if (groupName == NULL) {
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	throwAFSException(env, JAFSNULLGROUP);
! 	return;
!     }
! 
!     if (juserName != NULL) {
! 	userName = getNativeString(env, juserName);
! 	if (userName == NULL) {
! 	    free(groupName);
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	free(groupName);
! 	throwAFSException(env, JAFSNULLUSER);
! 	return;
!     }
! 
!     if (!pts_GroupMemberRemove((void *)cellHandle, userName, groupName, &ast)) {
! 	throwAFSException(env, ast);
!     }
! 
!     free(groupName);
!     free(userName);
  }
  
  /**
--- 637,692 ----
   *                           member
   * juserName      the name of the user to remove
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Group_removeMember
!   (JNIEnv *env, jclass cls, jlong cellHandle, jstring jgroupName,
!    jstring juserName)
! {
!   afs_status_t ast;
!   const char *groupName;
!   const char *userName;
! 
!   if( jgroupName != NULL ) {
!     groupName = (*env)->GetStringUTFChars(env, jgroupName, 0);
!     if( !groupName ) {
! 	throwAFSException( env, JAFSADMNOMEM );
! 	return;    
!     }
!   } else {
!     groupName = NULL;
!   }
! 
!   if( juserName != NULL ) {
!     userName = (*env)->GetStringUTFChars(env, juserName, 0);
!     if( !userName ) {
!       if( groupName != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
!       }
!       throwAFSException( env, JAFSADMNOMEM );
!       return;    
!     }
!   } else {
!     userName = NULL;
!   }
! 
!   if( !pts_GroupMemberRemove( (void *)cellHandle, userName, 
! 			      groupName, &ast ) ) {
!     if( groupName != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
!     }
!     if( userName != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, juserName, userName);
!     }
!     throwAFSException( env, ast );
!     return;
!   }
!   
!   if( groupName != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
!   }
!   if( userName != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, juserName, userName);
!   }
  }
  
  /**
***************
*** 648,692 ****
   *                           owner
   * jownerName      the name of the new owner
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Group_changeOwner(JNIEnv * env, jclass cls,
! 					jint cellHandle, jstring jgroupName,
! 					jstring jownerName)
! {
!     afs_status_t ast;
!     char *groupName;
!     char *ownerName;
! 
!     if (jgroupName != NULL) {
! 	groupName = getNativeString(env, jgroupName);
! 	if (groupName == NULL) {
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	throwAFSException(env, JAFSNULLGROUP);
! 	return;
!     }
! 
!     if (jownerName != NULL) {
! 	ownerName = getNativeString(env, jownerName);
! 	if (ownerName == NULL) {
! 	    free(groupName);
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	free(groupName);
! 	throwAFSException(env, JAFSNULLOWNER);
! 	return;
!     }
! 
!     if (!pts_GroupOwnerChange((void *)cellHandle, groupName, ownerName, &ast)) {
! 	throwAFSException(env, ast);
!     }
! 
!     free(groupName);
!     free(ownerName);
  }
  
  /**
--- 699,755 ----
   *                           owner
   * jownerName      the name of the new owner
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Group_changeOwner
!   (JNIEnv *env, jclass cls, jlong cellHandle, jstring jgroupName,
!    jstring jownerName )
! {
!   afs_status_t ast;
!   const char *groupName;
!   const char *ownerName;
! 
!   if( jgroupName != NULL ) {
!     groupName = (*env)->GetStringUTFChars(env, jgroupName, 0);
!     if( !groupName ) {
! 	throwAFSException( env, JAFSADMNOMEM );
! 	return;    
!     }
!   } else {
!     groupName = NULL;
!   }
! 
!   if( jownerName != NULL ) {
!     ownerName = (*env)->GetStringUTFChars(env, jownerName, 0);
!     if( !ownerName ) {
!       if( groupName != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
!       }
!       throwAFSException( env, JAFSADMNOMEM );
!       return;    
!     }
!   } else {
!     ownerName = NULL;
!   }
! 
!   if( !pts_GroupOwnerChange( (void *)cellHandle, groupName, 
! 			     ownerName, &ast ) ) {
!     if( groupName != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
!     }
!     if( ownerName != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, jownerName, ownerName);
!     }
!     throwAFSException( env, ast );
!     return; 
!   }
! 
!   if( groupName != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
!   }
!   if( ownerName != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, jownerName, ownerName);
!   }
!   
  }
  
  /**
***************
*** 698,751 ****
   * joldGroupName          the old name of the group
   * jnewGroupName      the new name for the group
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Group_rename(JNIEnv * env, jclass cls, jint cellHandle,
! 				   jstring jgroupOldName,
! 				   jstring jgroupNewName)
! {
!     afs_status_t ast;
!     char *groupOldName;
!     char *groupNewName;
! 
!     if (jgroupOldName != NULL) {
! 	groupOldName = getNativeString(env, jgroupOldName);
! 	if (groupOldName == NULL) {
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	throwAFSException(env, JAFSNULLGROUP);
! 	return;
!     }
! 
!     if (jgroupNewName != NULL) {
! 	groupNewName = getNativeString(env, jgroupNewName);
! 	if (groupNewName == NULL) {
! 	    free(groupOldName);
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	free(groupOldName);
! 	throwAFSException(env, JAFSNULLGROUP);
! 	return;
!     }
! 
!     if (!pts_GroupRename
! 	((void *)cellHandle, groupOldName, groupNewName, &ast)) {
! 	throwAFSException(env, ast);
!     }
! 
!     free(groupOldName);
!     free(groupNewName);
  }
  
  // reclaim global memory used by this portion
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Group_reclaimGroupMemory(JNIEnv * env, jclass cls)
  {
!     if (groupCls) {
! 	(*env)->DeleteGlobalRef(env, groupCls);
! 	groupCls = 0;
!     }
  }
--- 761,827 ----
   * joldGroupName          the old name of the group
   * jnewGroupName      the new name for the group
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Group_rename
!   (JNIEnv *env, jclass cls, jlong cellHandle, jstring jgroupOldName, 
!    jstring jgroupNewName )
! {
!   afs_status_t ast;
!   const char *groupOldName;
!   const char *groupNewName;
! 
!   if( jgroupOldName != NULL ) {
!     groupOldName = (*env)->GetStringUTFChars(env, jgroupOldName, 0);
!     if( !groupOldName ) {
! 	throwAFSException( env, JAFSADMNOMEM );
! 	return;    
!     }
!   } else {
!     groupOldName = NULL;
!   }
! 
!   if( jgroupNewName != NULL ) {
!     groupNewName = (*env)->GetStringUTFChars(env, jgroupNewName, 0);
!     if( !groupNewName ) {
!       if( groupOldName != NULL ) {
!         (*env)->ReleaseStringUTFChars(env, jgroupOldName, groupOldName);
!       }
!       throwAFSException( env, JAFSADMNOMEM );
!       return;    
!     }
!   } else {
!     groupNewName = NULL;
!   }
! 
!   if( !pts_GroupRename( (void *)cellHandle, groupOldName, 
! 			groupNewName, &ast ) ) {
!     if( groupOldName != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jgroupOldName, groupOldName);
!     }
!     if( groupNewName != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jgroupNewName, groupNewName);
!     }
!     throwAFSException( env, ast );
!     return;
!   }
! 
!   if( groupOldName != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, jgroupOldName, groupOldName);
!   }
!   if( groupNewName != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, jgroupNewName, groupNewName);
!   }
  }
  
  // reclaim global memory used by this portion
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Group_reclaimGroupMemory (JNIEnv *env, jclass cls)
  {
!   if( groupCls ) {
!       (*env)->DeleteGlobalRef(env, groupCls);
!       groupCls = 0;
!   }
  }
+ 
+ 
+ 
Index: openafs/src/JAVA/libjafs/Internal.c
diff -c openafs/src/JAVA/libjafs/Internal.c:1.4 openafs/src/JAVA/libjafs/Internal.c:1.4.2.1
*** openafs/src/JAVA/libjafs/Internal.c:1.4	Fri Aug  8 17:54:30 2003
--- openafs/src/JAVA/libjafs/Internal.c	Fri Oct 14 22:14:12 2005
***************
*** 27,42 ****
  
  extern int errno;
  
- jmethodID MID_String_getBytes = 0;
- 
  #ifndef LIBJUAFS
! /* User Class and Fields */
  jclass userCls = 0;
  jfieldID user_ptsField = 0;
  jfieldID user_kasField = 0;
  jfieldID user_nameField = 0;
  jfieldID user_cachedInfoField = 0;
! /* PTS Fields */
  jfieldID user_nameUidField = 0;
  jfieldID user_ownerUidField = 0;
  jfieldID user_creatorUidField = 0;
--- 27,41 ----
  
  extern int errno;
  
  #ifndef LIBJUAFS
! // user class and fields //
  jclass userCls = 0;
  jfieldID user_ptsField = 0;
  jfieldID user_kasField = 0;
  jfieldID user_nameField = 0;
+ //jfieldID user_cellHandleField = 0;
  jfieldID user_cachedInfoField = 0;
! //pts fields
  jfieldID user_nameUidField = 0;
  jfieldID user_ownerUidField = 0;
  jfieldID user_creatorUidField = 0;
***************
*** 47,53 ****
  jfieldID user_groupMembershipCountField = 0;
  jfieldID user_ownerField = 0;
  jfieldID user_creatorField = 0;
! /* KAS Fields */
  jfieldID user_adminSettingField = 0;
  jfieldID user_tgsSettingField = 0;
  jfieldID user_encSettingField = 0;
--- 46,52 ----
  jfieldID user_groupMembershipCountField = 0;
  jfieldID user_ownerField = 0;
  jfieldID user_creatorField = 0;
! // kas fields
  jfieldID user_adminSettingField = 0;
  jfieldID user_tgsSettingField = 0;
  jfieldID user_encSettingField = 0;
***************
*** 66,74 ****
  jfieldID user_lockTimeField = 0;
  jfieldID user_lockedUntilField = 0;
  
! /* Group Class and Fields */
  jclass groupCls = 0;
  jfieldID group_nameField = 0;
  jfieldID group_cachedInfoField = 0;
  jfieldID group_nameUidField = 0;
  jfieldID group_ownerUidField = 0;
--- 65,74 ----
  jfieldID user_lockTimeField = 0;
  jfieldID user_lockedUntilField = 0;
  
! // group class and fields //
  jclass groupCls = 0;
  jfieldID group_nameField = 0;
+ //jfieldID group_cellHandleField = 0;
  jfieldID group_cachedInfoField = 0;
  jfieldID group_nameUidField = 0;
  jfieldID group_ownerUidField = 0;
***************
*** 82,90 ****
  jfieldID group_ownerField = 0;
  jfieldID group_creatorField = 0;
  
! /* Server Class and Fields */
  jclass serverCls = 0;
  jfieldID server_nameField = 0;
  jfieldID server_cachedInfoField = 0;
  jfieldID server_databaseField = 0;
  jfieldID server_fileServerField = 0;
--- 82,91 ----
  jfieldID group_ownerField = 0;
  jfieldID group_creatorField = 0;
  
! // server class and fields //
  jclass serverCls = 0;
  jfieldID server_nameField = 0;
+ //jfieldID server_cellHandleField = 0;
  jfieldID server_cachedInfoField = 0;
  jfieldID server_databaseField = 0;
  jfieldID server_fileServerField = 0;
***************
*** 92,98 ****
  jfieldID server_badFileServerField = 0;
  jfieldID server_IPAddressField = 0;
  
! /* Executable Time Class and Fields */
  jclass exectimeCls = 0;
  jfieldID exectime_HourField = 0;
  jfieldID exectime_MinField = 0;
--- 93,99 ----
  jfieldID server_badFileServerField = 0;
  jfieldID server_IPAddressField = 0;
  
! // executable time class and fields //
  jclass exectimeCls = 0;
  jfieldID exectime_HourField = 0;
  jfieldID exectime_MinField = 0;
***************
*** 101,107 ****
  jfieldID exectime_NowField = 0;
  jfieldID exectime_NeverField = 0;
  
! /* Partition Class and Fields */
  jclass partitionCls = 0;
  jfieldID partition_nameField = 0;
  jfieldID partition_cachedInfoField = 0;
--- 102,108 ----
  jfieldID exectime_NowField = 0;
  jfieldID exectime_NeverField = 0;
  
! // partition class and fields //
  jclass partitionCls = 0;
  jfieldID partition_nameField = 0;
  jfieldID partition_cachedInfoField = 0;
***************
*** 111,117 ****
  jfieldID partition_totalSpaceField = 0;
  jfieldID partition_totalFreeSpaceField = 0;
  
! /* Volume Class and Fields */
  jclass volumeCls = 0;
  jfieldID volume_nameField = 0;
  jfieldID volume_cachedInfoField = 0;
--- 112,118 ----
  jfieldID partition_totalSpaceField = 0;
  jfieldID partition_totalFreeSpaceField = 0;
  
! // volume class and fields //
  jclass volumeCls = 0;
  jfieldID volume_nameField = 0;
  jfieldID volume_cachedInfoField = 0;
***************
*** 132,138 ****
  jfieldID volume_dispositionField = 0;
  jfieldID volume_typeField = 0;
  
! /* Key Class and Fields */
  jclass keyCls = 0;
  jfieldID key_cachedInfoField = 0;
  jfieldID key_versionField = 0;
--- 133,139 ----
  jfieldID volume_dispositionField = 0;
  jfieldID volume_typeField = 0;
  
! // key class and fields //
  jclass keyCls = 0;
  jfieldID key_cachedInfoField = 0;
  jfieldID key_versionField = 0;
***************
*** 141,150 ****
  jfieldID key_lastModMsField = 0;
  jfieldID key_checkSumField = 0;
  
! /* Process Class and Fields */
  jclass processCls = 0;
  jfieldID process_cachedInfoField = 0;
  jfieldID process_nameField = 0;
  jfieldID process_typeField = 0;
  jfieldID process_stateField = 0;
  jfieldID process_goalField = 0;
--- 142,152 ----
  jfieldID key_lastModMsField = 0;
  jfieldID key_checkSumField = 0;
  
! // process class and fields //
  jclass processCls = 0;
  jfieldID process_cachedInfoField = 0;
  jfieldID process_nameField = 0;
+ //jfieldID process_serverHandleField = 0;
  jfieldID process_typeField = 0;
  jfieldID process_stateField = 0;
  jfieldID process_goalField = 0;
***************
*** 157,163 ****
  jfieldID process_stateOkField = 0;
  jfieldID process_stateTooManyErrorsField = 0;
  jfieldID process_stateBadFileAccessField = 0;
- 
  #endif /* !LIBJUAFS */
  
  /**
--- 159,164 ----
***************
*** 165,201 ****
   * for the exception.  See Exceptions.h for the available
   * exceptions.
   */
! void
! throwException(JNIEnv * env, jclass * excCls, char *excClsName,
! 	       jmethodID * initID, int code)
  {
!     jobject exc;
!     if (*excCls == 0) {
! 	*excCls =
! 	    (*env)->NewGlobalRef(env, (*env)->FindClass(env, excClsName));
! 	if (!*excCls) {
! 	    fprintf(stderr,
! 		    "ERROR: Internal::throwException()\n Cannot find class: %s\n",
! 		    excClsName);
! 	    return;
! 	}
! 	*initID = (*env)->GetMethodID(env, *excCls, "<init>", "(I)V");
! 	if (!*initID) {
! 	    fprintf(stderr,
! 		    "ERROR: Internal::throwException()\n Cannot find construction method: %s\n",
! 		    excClsName);
! 	    return;
! 	}
!     }
! 
!     exc = (*env)->NewObject(env, *excCls, *initID, code);
!     if (!exc) {
! 	fprintf(stderr,
! 		"ERROR: Internal::throwException()\n Cannot construct new exception object: %s\n",
! 		excClsName);
! 	return;
!     }
!     (*env)->Throw(env, exc);
  }
  
  /**
--- 166,196 ----
   * for the exception.  See Exceptions.h for the available
   * exceptions.
   */
! void throwException
!   (JNIEnv *env, jclass *excCls, char *excClsName, jmethodID *initID, int code)
  {
!   jobject exc;
!   if( *excCls == 0 ) {
!     *excCls = (*env)->NewGlobalRef(env, (*env)->FindClass(env, excClsName ));
!     if( !*excCls ) {
!       fprintf(stderr, "ERROR: Internal::throwException()\n Cannot find class: %s\n", excClsName);
! 	return;
!     }
!     *initID = (*env)->GetMethodID( env, *excCls, "<init>", "(I)V" );
!     if( !*initID ) {
!       fprintf(stderr, "ERROR: Internal::throwException()\n Cannot find construction method: %s\n",
! 	      excClsName);
! 	return;
!     }
!   }
!   
!   exc = (*env)->NewObject( env, *excCls, *initID, code );
!   if( !exc ) {
!     fprintf(stderr, "ERROR: Internal::throwException()\n Cannot construct new exception object: %s\n",
!                      excClsName);
!     return;
!   }
!   (*env)->Throw(env, exc);
  }
  
  /**
***************
*** 204,220 ****
   * is unavailable and it is necessary to interrupt the Java call with an
   * exception. See Exceptions.h for the available exceptions.
   */
! void
! throwMessageException(JNIEnv * env, char *msg)
  {
!     jclass excCls = (*env)->FindClass(env, afsExceptionName);
!     if (excCls == 0) {
! 	fprintf(stderr,
! 		"ERROR: Internal::throwMessageException()\n Cannot find class: %s\n",
! 		afsExceptionName);
! 	return;
!     }
!     (*env)->ThrowNew(env, excCls, msg);
  }
  
  /**
--- 199,212 ----
   * is unavailable and it is necessary to interrupt the Java call with an
   * exception. See Exceptions.h for the available exceptions.
   */
! void throwMessageException( JNIEnv *env, char *msg )
  {
!   jclass excCls = (*env)->FindClass(env, afsExceptionName);
!   if(excCls == 0) {
!     fprintf(stderr, "ERROR: Internal::throwMessageException()\n Cannot find class: %s\n", afsExceptionName);
!     return;
!   }
!   (*env)->ThrowNew(env, excCls, msg);
  }
  
  /**
***************
*** 222,260 ****
   * for the exception.  See Exceptions.h for the available
   * exceptions.
   */
! void
! throwAFSException(JNIEnv * env, int code)
  {
!     jclass afsExceptionCls;
!     jmethodID afsExceptionInit;
!     jthrowable exc;
! 
!     afsExceptionCls = (*env)->FindClass(env, afsExceptionName);
!     if (!afsExceptionCls) {
! 	fprintf(stderr,
! 		"ERROR: Internal::throwAFSException()\n Cannot find class: %s\n",
! 		afsExceptionName);
! 	return;
!     }
! 
!     afsExceptionInit =
! 	(*env)->GetMethodID(env, afsExceptionCls, "<init>", "(I)V");
!     if (!afsExceptionInit) {
! 	fprintf(stderr,
! 		"ERROR: Internal::throwAFSException()\n Cannot find construction method: %s\n",
! 		afsExceptionName);
! 	return;
!     }
! 
!     exc = (*env)->NewObject(env, afsExceptionCls, afsExceptionInit, code);
! 
!     if (!exc) {
! 	fprintf(stderr,
! 		"ERROR: Internal::throwAFSException()\n Cannot construct new exception object: %s\n",
! 		afsExceptionName);
! 	return;
!     }
!     (*env)->Throw(env, exc);
  }
  
  /**
--- 214,247 ----
   * for the exception.  See Exceptions.h for the available
   * exceptions.
   */
! void throwAFSException( JNIEnv *env, int code )
  {
!   jclass afsExceptionCls;
!   jmethodID afsExceptionInit;
!   jthrowable exc;
! 
!   afsExceptionCls = (*env)->FindClass(env, afsExceptionName);
!   if( !afsExceptionCls ) {
!     fprintf(stderr, "ERROR: Internal::throwAFSException()\n Cannot find class: %s\n", afsExceptionName);
!     return;
!   }
! 
!   afsExceptionInit = (*env)->GetMethodID( env, afsExceptionCls, 
!                              "<init>", "(I)V" );
!   if( !afsExceptionInit ) {
!     fprintf(stderr, "ERROR: Internal::throwAFSException()\n Cannot find construction method: %s\n",
!                      afsExceptionName);
!     return;
!   }
!   
!   exc = (*env)->NewObject( env, afsExceptionCls, afsExceptionInit, code );
! 
!   if( !exc ) {
!     fprintf(stderr, "ERROR: Internal::throwAFSException()\n Cannot construct new exception object: %s\n",
!                      afsExceptionName);
!     return;
!   }
!   (*env)->Throw(env, exc);
  }
  
  /**
***************
*** 262,303 ****
   * for the exception.  See Exceptions.h for the available
   * exceptions.
   */
! void
! throwAFSFileException(JNIEnv * env, int code, char *msg)
  {
!     jclass afsFileExceptionCls;
!     jmethodID afsFileExceptionInit;
!     jthrowable exc;
! 
!     afsFileExceptionCls = (*env)->FindClass(env, afsFileExceptionName);
!     if (!afsFileExceptionCls) {
! 	fprintf(stderr,
! 		"ERROR: Internal::throwAFSFileException()\n Cannot find class: %s\n",
! 		afsFileExceptionName);
! 	return;
!     }
! 
!     afsFileExceptionInit =
! 	(*env)->GetMethodID(env, afsFileExceptionCls, "<init>",
! 			    "(Ljava/lang/String;I)V");
! 
!     if (!afsFileExceptionInit) {
! 	fprintf(stderr,
! 		"ERROR: Internal::throwAFSFileException()\n Cannot find construction method: %s\n",
! 		afsFileExceptionName);
! 	return;
!     }
! 
!     exc =
! 	(*env)->NewObject(env, afsFileExceptionCls, afsFileExceptionInit, msg,
! 			  code);
!     if (!exc) {
! 	fprintf(stderr,
! 		"ERROR: Internal::throwAFSFileException()\n Cannot construct new exception object: %s\n",
! 		afsFileExceptionName);
! 	return;
!     }
!     (*env)->Throw(env, exc);
  }
  
  /**
--- 249,282 ----
   * for the exception.  See Exceptions.h for the available
   * exceptions.
   */
! void throwAFSFileException( JNIEnv *env, int code, char *msg )
  {
!   jclass afsFileExceptionCls;
!   jmethodID afsFileExceptionInit;
!   jthrowable exc;
! 
!   afsFileExceptionCls = (*env)->FindClass(env, afsFileExceptionName);
!   if( !afsFileExceptionCls ) {
!     fprintf(stderr, "ERROR: Internal::throwAFSFileException()\n Cannot find class: %s\n", afsFileExceptionName);
!     return;
!   }
! 
!   afsFileExceptionInit = (*env)->GetMethodID( env, afsFileExceptionCls, 
!                          "<init>", "(Ljava/lang/String;I)V" );
!   if( !afsFileExceptionInit ) {
!     fprintf(stderr, "ERROR: Internal::throwAFSFileException()\n Cannot find construction method: %s\n",
!                      afsFileExceptionName);
!     return;
!   }
!   
!   exc = (*env)->NewObject( env, afsFileExceptionCls,
!                            afsFileExceptionInit, msg, code );
!   if( !exc ) {
!     fprintf(stderr, "ERROR: Internal::throwAFSFileException()\n Cannot construct new exception object: %s\n",
!                      afsFileExceptionName);
!     return;
!   }
!   (*env)->Throw(env, exc);
  }
  
  /**
***************
*** 305,460 ****
   * for the exception.  See Exceptions.h for the available
   * exceptions.
   */
! void
! throwAFSSecurityException(JNIEnv * env, int code)
! {
!     jclass afsSecurityExceptionCls;
!     jmethodID afsSecurityExceptionInit;
!     jthrowable exc;
! 
!     afsSecurityExceptionCls =
! 	(*env)->FindClass(env, afsSecurityExceptionName);
!     if (!afsSecurityExceptionCls) {
! 	fprintf(stderr,
! 		"ERROR: Internal::throwAFSSecurityException()\n Cannot find class: %s\n",
! 		afsSecurityExceptionName);
! 	return;
!     }
! 
!     afsSecurityExceptionInit =
! 	(*env)->GetMethodID(env, afsSecurityExceptionCls, "<init>", "(I)V");
!     if (!afsSecurityExceptionInit) {
! 	fprintf(stderr,
! 		"ERROR: Internal::throwAFSSecurityException()\n Cannot find construction method: %s\n",
! 		afsSecurityExceptionName);
! 	return;
!     }
! 
!     exc =
! 	(*env)->NewObject(env, afsSecurityExceptionCls,
! 			  afsSecurityExceptionInit, code);
! 
!     if (!exc) {
! 	fprintf(stderr,
! 		"ERROR: Internal::throwAFSSecurityException()\n Cannot construct new exception object: %s\n",
! 		afsSecurityExceptionName);
! 	return;
!     }
!     (*env)->Throw(env, exc);
! }
! 
! int
! setError(JNIEnv * env, jobject * obj, int code)
! {
!     jfieldID fid;
!     jclass cls = (*env)->GetObjectClass(env, *obj);
!     if (cls != NULL) {
! 	fid = (*env)->GetFieldID(env, cls, "errno", "I");
! 	if (fid) {
! 	    (*env)->SetIntField(env, *obj, fid, code);
! 	    return 0;
! 	}
!     }
!     return -1;
! }
! 
! int
! setString(JNIEnv * env, jobject * obj, char *field, char *string)
! {
!     jclass cls;
!     jstring jstr;
!     jfieldID fid;
! 
!     cls = (*env)->GetObjectClass(env, *obj);
!     /*fprintf(stderr, "setString: env=0x%x, obj=0x%x, cls=0x%x\n", env, obj, cls); */
!     if (cls != NULL) {
! 	fid = (*env)->GetFieldID(env, cls, field, "Ljava/lang/String;");
! 	/*fprintf(stderr, "setString: field=%s, fid=0x%x\n", field, fid); */
! 	if (fid) {
! 	    jstr = (*env)->NewStringUTF(env, (string));
! 	    /*fprintf(stderr, "jstr = 0x%x\n", jstr); */
! 	    (*env)->SetObjectField(env, *obj, fid, jstr);
! 	    return 0;
! 	}
!     }
!     return -1;
! }
! 
! /**
!  * Translates a jstring to a locale-specific native C string.
!  * Use in place of "GetStringUTFChars()" for internationalization
!  * purposes.
!  * 
!  * Make sure to "free()" any strings created by this function.
!  *
!  * A NULL (zero) return indicates a critical error has occurred and 
!  * relies on the caller of this function to throw a Java exception.
!  *
!  * This function does not throw any Java exceptions.
!  * 
!  *  env         the Java environment
!  *  jstr        the Java string (UTF) to translate
!  *
!  * @returns	    native C string with the appropriate locale-specific 
!  *              representation
!  */
! char *
! getNativeString(JNIEnv * env, const jstring jstr)
  {
!     jbyteArray bytes = 0;
!     char *result = NULL;
!     jint len = 0;
! 
!     if ((*env)->EnsureLocalCapacity(env, 2) < 0) {
! 	// Out of memory error
! 	fprintf(stderr, "Internal::getNativeString(): ");
! 	fprintf(stderr,
! 		"EnsureLocalCapacity() failed: Most likely out of memory\n");
! 	return NULL;
!     }
! 
!     if (!MID_String_getBytes) {
! 	jclass stringClass = (*env)->FindClass(env, "java/lang/String");
! 	if (!stringClass) {
! 	    fprintf(stderr, "Internal::getNativeString(): ");
! 	    fprintf(stderr,
! 		    "Could not locate Java class: java.lang.String.\n");
! 	    return NULL;
! 	}
! 
! 	MID_String_getBytes =
! 	    (*env)->GetMethodID(env, stringClass, "getBytes", "()[B");
! 	if (!MID_String_getBytes) {
! 	    fprintf(stderr, "Internal::getNativeString(): ");
! 	    fprintf(stderr,
! 		    "Could not get Java method id for java.lang.String method \"getBytes()\".\n");
! 	    return NULL;
! 	}
!     }
! 
!     bytes = (*env)->CallObjectMethod(env, jstr, MID_String_getBytes);
!     if (!bytes) {
! 	fprintf(stderr, "Internal::getNativeString(): ");
! 	fprintf(stderr,
! 		"CallObjectMethod() failed for java.lang.String.getBytes().\n");
! 	fprintf(stderr, "\tMID_String_getBytes = %d\n", MID_String_getBytes);
! 	return NULL;
!     }
! 
!     len = (*env)->GetArrayLength(env, bytes);
!     result = (char *)malloc(len + 1);
! 
!     if (!result) {
! 	fprintf(stderr, "Internal::getNativeString(): ");
! 	fprintf(stderr, "Could not allocate memory for byte array.\n");
! 	(*env)->DeleteLocalRef(env, bytes);
! 	return NULL;
      }
!     (*env)->GetByteArrayRegion(env, bytes, 0, len, (jbyte *) result);
!     result[len] = '\0';		// NULL-terminate
! 
!     (*env)->DeleteLocalRef(env, bytes);
!     return result;
  }
  
  #ifdef LIBJUAFS
--- 284,332 ----
   * for the exception.  See Exceptions.h for the available
   * exceptions.
   */
! void throwAFSSecurityException( JNIEnv *env, int code )
  {
!   jclass afsSecurityExceptionCls;
!   jmethodID afsSecurityExceptionInit;
!   jthrowable exc;
! 
!   afsSecurityExceptionCls = (*env)->FindClass(env, afsSecurityExceptionName);
!   if( !afsSecurityExceptionCls ) {
!     fprintf(stderr, "ERROR: Internal::throwAFSSecurityException()\n Cannot find class: %s\n", afsSecurityExceptionName);
!     return;
!   }
! 
!   afsSecurityExceptionInit = (*env)->GetMethodID( env, afsSecurityExceptionCls, 
!                              "<init>", "(I)V" );
!   if( !afsSecurityExceptionInit ) {
!     fprintf(stderr, "ERROR: Internal::throwAFSSecurityException()\n Cannot find construction method: %s\n",
!                      afsSecurityExceptionName);
!     return;
!   }
!   
!   exc = (*env)->NewObject( env, afsSecurityExceptionCls,
!                            afsSecurityExceptionInit, code );
!   if( !exc ) {
!     fprintf(stderr, "ERROR: Internal::throwAFSSecurityException()\n Cannot construct new exception object: %s\n",
!                      afsSecurityExceptionName);
!     return;
!   }
!   (*env)->Throw(env, exc);
! }
! 
! int setError(JNIEnv *env, jobject *obj, int code)
! {
!   jfieldID fid;
!   jclass cls = (*env)->GetObjectClass(env, *obj);
!   if (cls != NULL) {
!     fid = (*env)->GetFieldID(env, cls, "errno", "I");
!     if (fid)
!     {
!       (*env)->SetIntField(env, *obj, fid, code);
!       return 0;
      }
!   }
!   return -1;
  }
  
  #ifdef LIBJUAFS
***************
*** 471,591 ****
   *
   * @returns		file descriptor
   */
! int
! openAFSFile(JNIEnv * env, jstring filenameUTF, int flags, int mode, int *err)
  {
!     char *filename;
      int fd = -1;
  
      *err = 0;
      errno = 0;
!     filename = getNativeString(env, filenameUTF);
!     if (filename == NULL) {
! 	fprintf(stderr, "Internal::openAFSFile(): failed to get filename\n");
! 	*err = -1;
! 	return fd;
      }
!     fd = uafs_open(filename, flags, mode);
!     free(filename);
      *err = errno;
      if (errno != 0) {
! 	fprintf(stderr, "Internal::openAFSFile(): errno=%d\n", errno);
! 	fprintf(stderr, "Internal::openAFSFile(): fd=%d\n", fd);
      }
      if (fd < 0) {
! 	fprintf(stderr, "Internal::openAFSFile(): failed to open filename\n");
! 	fprintf(stderr, "Internal::openAFSFile(): fd=%d\n", fd);
! 	return -1;
      }
      return fd;
  }
  
! /**
!  * Reads the "CacheConfig" file for user space configuration.
!  * By default, this file resides in "/usr/afswsp/etc/CacheConfig",
!  * however if the environment variable "LIBJAFS_CACHE_CONFIG" is
!  * set this function will use that value instead.
!  *
!  * The CacheConfig file contains several cache tuning parameters 
!  * as well as a few parameters that define the runtime environment 
!  * for the user space client, including: mount point location, 
!  * configuration directory (where to find ThisCell and CellServDB), 
!  * cache directory, debug and verbose options, and log file location.
!  */
! int
! readCacheParms(char *afsMountPoint, char *afsConfDir, char *afsCacheDir,
! 	       int *cacheBlocks, int *cacheFiles, int *cacheStatEntries,
! 	       int *dCacheSize, int *vCacheSize, int *chunkSize,
! 	       int *closeSynch, int *debug, int *nDaemons, int *cacheFlags,
! 	       char *logFile)
! {
!     FILE *f;
!     char line[100];
!     char *p;
!     int len1, len2, n;
!     char cacheConfigFile[100];
! 
!     p = (char *)getenv("LIBJAFS_CACHE_CONFIG");
!     if (p) {
! 	strcpy(cacheConfigFile, p);
!     } else {
! 	strcpy(cacheConfigFile, "/usr/afswsp/etc/CacheConfig");
!     }
! 
!     f = fopen(cacheConfigFile, "r");
!     if (!f) {
! 	fprintf(stderr, "Could not open cache config file: %s\n",
! 		cacheConfigFile);
! 	return -1;
!     }
! 
!     while (1) {
! 	fgets(line, 100, f);
! 	if (feof(f))
! 	    break;
! 	p = (char *)strchr(line, '\n');
! 	if (p)
! 	    *p = '\0';
! 	if (strncmp(line, "#", 1) == 0)
! 	    continue;		/* comment */
! 
! 	p = (char *)strchr(line, ' ');
! 	if (!p)
! 	    continue;
! 	len1 = p - line;
! 	p++;
! 	len2 = strlen(p);
! 
! 	if (strncmp(line, "MountPoint", len1) == 0)
! 	    strcpy(afsMountPoint, p);
! 	else if (strncmp(line, "ConfDir", len1) == 0)
! 	    strcpy(afsConfDir, p);
! 	else if (strncmp(line, "CacheDir", len1) == 0)
! 	    strcpy(afsCacheDir, p);
! 	else if (strncmp(line, "CacheBlocks", len1) == 0)
! 	    *cacheBlocks = atoi(p);
! 	else if (strncmp(line, "CacheFiles", len1) == 0)
! 	    *cacheFiles = atoi(p);
! 	else if (strncmp(line, "CacheStatEntries", len1) == 0)
! 	    *cacheStatEntries = atoi(p);
! 	else if (strncmp(line, "DCacheSize", len1) == 0)
! 	    *dCacheSize = atoi(p);
! 	else if (strncmp(line, "VCacheSize", len1) == 0)
! 	    *vCacheSize = atoi(p);
! 	else if (strncmp(line, "ChunkSize", len1) == 0)
! 	    *chunkSize = atoi(p);
! 	else if (strncmp(line, "CloseSynch", len1) == 0)
! 	    *closeSynch = atoi(p);
! 	else if (strncmp(line, "Debug", len1) == 0)
! 	    *debug = atoi(p);
! 	else if (strncmp(line, "NDaemons", len1) == 0)
! 	    *nDaemons = atoi(p);
! 	else if (strncmp(line, "CacheFlags", len1) == 0)
! 	    *cacheFlags = atoi(p);
! 	else if (strncmp(line, "LogFile", len1) == 0)
! 	    strcpy(logFile, p);
      }
!     return 0;
  }
  
  #else
--- 343,466 ----
   *
   * @returns		file descriptor
   */
! int openAFSFile
!   (JNIEnv *env, jstring fileNameUTF, int flags, int mode, int *err)
  {
!     char *fileName;
      int fd = -1;
  
      *err = 0;
      errno = 0;
!     fileName=(char*) (*env)->GetStringUTFChars(env, fileNameUTF, 0);
!     if(fileName == NULL) {
!       fprintf(stderr, "Internal::openAFSFile(): failed to get fileName\n");
!       *err = -1;
!       return fd;
      }
!     fd  = uafs_open(fileName, flags, mode);
      *err = errno;
      if (errno != 0) {
!       fprintf(stderr, "Internal::openAFSFile(): errno=%d\n", errno);
!       fprintf(stderr, "Internal::openAFSFile(): fd=%d\n", fd);
      }
+     (*env)->ReleaseStringUTFChars(env, fileNameUTF, fileName);
      if (fd < 0) {
!       fprintf(stderr, "Internal::openAFSFile(): failed to open fileName\n");
!       fprintf(stderr, "Internal::openAFSFile(): fd=%d\n", fd);
!       return -1;
      }
      return fd;
  }
  
! int readCacheParms(char *afsMountPoint, char *afsConfDir, char *afsCacheDir,
!                    int *cacheBlocks, int *cacheFiles, int *cacheStatEntries,
!                    int *dCacheSize, int *vCacheSize, int *chunkSize,
!                    int *closeSynch, int *debug, int *nDaemons, int *cacheFlags,
!                    char *logFile)
! {
!   FILE *f;
!   char line[100];
!   char *p;
!   int len1, len2, n;
!   char cacheConfigFile[100];
!   
!   p = (char *)getenv("LIBJAFS_CACHE_CONFIG");
!   if (p) {
!     strcpy(cacheConfigFile, p);
!   } else {
!     strcpy(cacheConfigFile, "/usr/afswsp/etc/CacheConfig");
!   }
! 
!   f = fopen(cacheConfigFile, "r");
!   if (!f) {
!     fprintf(stderr, "Could not open cache config file: %s\n",
!             cacheConfigFile);
!     return -1;
!   }
! 
!   while (1) {
!     fgets(line, 100, f);
!     if (feof(f)) break;
!     p = (char *)strchr(line, '\n');
!     if (p) *p = '\0';
!     if (strncmp(line, "#", 1) == 0) continue;  /* comment */
! 
!     p = (char *)strchr(line, ' ');
!     if (!p) continue;
!     len1 = p - line;
!     p++; len2 = strlen(p);
! 
!     if (strncmp(line, "MountPoint", len1) == 0)
!        strcpy(afsMountPoint, p);
!     else if (strncmp(line, "ConfDir", len1) == 0)
!        strcpy(afsConfDir, p);
!     else if (strncmp(line, "CacheDir", len1) == 0)
!        strcpy(afsCacheDir, p);
!     else if (strncmp(line, "CacheBlocks", len1) == 0)
!        *cacheBlocks = atoi(p);
!     else if (strncmp(line, "CacheFiles", len1) == 0)
!        *cacheFiles = atoi(p);
!     else if (strncmp(line, "CacheStatEntries", len1) == 0)
!        *cacheStatEntries = atoi(p);
!     else if (strncmp(line, "DCacheSize", len1) == 0)
!        *dCacheSize = atoi(p);
!     else if (strncmp(line, "VCacheSize", len1) == 0)
!        *vCacheSize = atoi(p);
!     else if (strncmp(line, "ChunkSize", len1) == 0)
!        *chunkSize = atoi(p);
!     else if (strncmp(line, "CloseSynch", len1) == 0)
!        *closeSynch = atoi(p);
!     else if (strncmp(line, "Debug", len1) == 0)
!        *debug = atoi(p);
!     else if (strncmp(line, "NDaemons", len1) == 0)
!        *nDaemons = atoi(p);
!     else if (strncmp(line, "CacheFlags", len1) == 0)
!        *cacheFlags = atoi(p);
!     else if (strncmp(line, "LogFile", len1) == 0)
!        strcpy(logFile, p);
!   }
!   return 0;
! }
! 
! int setString(JNIEnv *env, jobject *obj, char *field, char *string)
! {
!   jclass cls;
!   jstring jstr;
!   jfieldID fid;
! 
!   cls = (*env)->GetObjectClass(env, *obj);
!   /*fprintf(stderr, "setString: env=0x%x, obj=0x%x, cls=0x%x\n", env, obj, cls);*/
!   if (cls != NULL) {
!     fid = (*env)->GetFieldID(env, cls, field, "Ljava/lang/String;");
!     /*fprintf(stderr, "setString: field=%s, fid=0x%x\n", field, fid);*/
!     if (fid) {
!       jstr = (*env)->NewStringUTF(env, (string));
!       /*fprintf(stderr, "jstr = 0x%x\n", jstr);*/
!       (*env)->SetObjectField(env, *obj, fid, jstr);
!       return 0;
      }
!   }
!   return -1;
  }
  
  #else
***************
*** 597,810 ****
   * the instance is the empty string.  The memory for who 
   * that's passed in should be fully allocated in advance.
   */
! void
! internal_makeKasIdentity(const char *fullName, kas_identity_p who)
! {
!     char *period;
  
-     if ((period = (char *)strchr(fullName, '.')) != NULL) {
- 	strncpy(who->principal, fullName, period - fullName);
- 	who->principal[period - fullName] = '\0';
- 	strncpy(who->instance, period + 1,
- 		strlen(fullName) - (period - fullName));
-     } else {
- 	strcpy(who->principal, fullName);
- 	strcpy(who->instance, "");
-     }
  }
  
  /**
   * Given a Java environment and an instance of a user, gets the object and
   * field information for the user object from the Java environment.
   */
! void
! internal_getUserClass(JNIEnv * env, jobject user)
! {
!     if (userCls == 0) {
! 	userCls =
! 	    (*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, user));
! 	if (!userCls) {
! 	    throwAFSException(env, JAFSADMCLASSNOTFOUND);
! 	    return;
! 	}
! 	user_ptsField = (*env)->GetFieldID(env, userCls, "pts", "Z");
! 	user_kasField = (*env)->GetFieldID(env, userCls, "kas", "Z");
! 	user_nameField =
! 	    (*env)->GetFieldID(env, userCls, "name", "Ljava/lang/String;");
! 	user_cachedInfoField =
! 	    (*env)->GetFieldID(env, userCls, "cachedInfo", "Z");
! 	// pts fields
! 	user_nameUidField = (*env)->GetFieldID(env, userCls, "nameUID", "I");
! 	user_ownerUidField =
! 	    (*env)->GetFieldID(env, userCls, "ownerUID", "I");
! 	user_creatorUidField =
! 	    (*env)->GetFieldID(env, userCls, "creatorUID", "I");
! 	user_listStatusField =
! 	    (*env)->GetFieldID(env, userCls, "listStatus", "I");
! 	user_listGroupsOwnedField =
! 	    (*env)->GetFieldID(env, userCls, "listGroupsOwned", "I");
! 	user_listMembershipField =
! 	    (*env)->GetFieldID(env, userCls, "listMembership", "I");
! 	user_groupCreationQuotaField =
! 	    (*env)->GetFieldID(env, userCls, "groupCreationQuota", "I");
! 	user_groupMembershipCountField =
! 	    (*env)->GetFieldID(env, userCls, "groupMembershipCount", "I");
! 	user_ownerField =
! 	    (*env)->GetFieldID(env, userCls, "owner", "Ljava/lang/String;");
! 	user_creatorField =
! 	    (*env)->GetFieldID(env, userCls, "creator", "Ljava/lang/String;");
! 	// kas fields
! 	user_adminSettingField =
! 	    (*env)->GetFieldID(env, userCls, "adminSetting", "I");
! 	user_tgsSettingField =
! 	    (*env)->GetFieldID(env, userCls, "tgsSetting", "I");
! 	user_encSettingField =
! 	    (*env)->GetFieldID(env, userCls, "encSetting", "I");
! 	user_cpwSettingField =
! 	    (*env)->GetFieldID(env, userCls, "cpwSetting", "I");
! 	user_rpwSettingField =
! 	    (*env)->GetFieldID(env, userCls, "rpwSetting", "I");
! 	user_userExpirationField =
! 	    (*env)->GetFieldID(env, userCls, "userExpiration", "I");
! 	user_lastModTimeField =
! 	    (*env)->GetFieldID(env, userCls, "lastModTime", "I");
! 	user_lastModNameField =
! 	    (*env)->GetFieldID(env, userCls, "lastModName",
! 			       "Ljava/lang/String;");
! 	user_lastChangePasswordTimeField =
! 	    (*env)->GetFieldID(env, userCls, "lastChangePasswordTime", "I");
! 	user_maxTicketLifetimeField =
! 	    (*env)->GetFieldID(env, userCls, "maxTicketLifetime", "I");
! 	user_keyVersionField =
! 	    (*env)->GetFieldID(env, userCls, "keyVersion", "I");
! 	user_encryptionKeyField =
! 	    (*env)->GetFieldID(env, userCls, "encryptionKey",
! 			       "Ljava/lang/String;");
! 	user_keyCheckSumField =
! 	    (*env)->GetFieldID(env, userCls, "keyCheckSum", "J");
! 	user_daysToPasswordExpireField =
! 	    (*env)->GetFieldID(env, userCls, "daysToPasswordExpire", "I");
! 	user_failLoginCountField =
! 	    (*env)->GetFieldID(env, userCls, "failLoginCount", "I");
! 	user_lockTimeField =
! 	    (*env)->GetFieldID(env, userCls, "lockTime", "I");
! 	user_lockedUntilField =
! 	    (*env)->GetFieldID(env, userCls, "lockedUntil", "I");
! 	if (!user_ptsField || !user_kasField || !user_nameField
! 	    || !user_cachedInfoField || !user_nameUidField
! 	    || !user_ownerUidField || !user_creatorUidField
! 	    || !user_listStatusField || !user_listGroupsOwnedField
! 	    || !user_listMembershipField || !user_groupCreationQuotaField
! 	    || !user_groupMembershipCountField || !user_ownerField
! 	    || !user_creatorField || !user_adminSettingField
! 	    || !user_tgsSettingField || !user_encSettingField
! 	    || !user_cpwSettingField || !user_rpwSettingField
! 	    || !user_userExpirationField || !user_lastModTimeField
! 	    || !user_lastModNameField || !user_lastChangePasswordTimeField
! 	    || !user_maxTicketLifetimeField || !user_keyVersionField
! 	    || !user_encryptionKeyField || !user_keyCheckSumField
! 	    || !user_daysToPasswordExpireField || !user_failLoginCountField
! 	    || !user_lockTimeField || !user_lockedUntilField) {
! 
! 	    throwAFSException(env, JAFSADMFIELDNOTFOUND);
! 	    return;
! 	}
      }
  }
  
  /**
   * Given a Java environment and an instance of a group, gets the object and
   * field information for the group object from the Java environment.
   */
! void
! internal_getGroupClass(JNIEnv * env, jobject group)
! {
!     if (groupCls == 0) {
! 	groupCls =
! 	    (*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, group));
! 	if (!groupCls) {
! 	    throwAFSException(env, JAFSADMCLASSNOTFOUND);
! 	    return;
! 	}
! 	group_nameField =
! 	    (*env)->GetFieldID(env, groupCls, "name", "Ljava/lang/String;");
! 	group_cachedInfoField =
! 	    (*env)->GetFieldID(env, groupCls, "cachedInfo", "Z");
! 	group_nameUidField =
! 	    (*env)->GetFieldID(env, groupCls, "nameUID", "I");
! 	group_ownerUidField =
! 	    (*env)->GetFieldID(env, groupCls, "ownerUID", "I");
! 	group_creatorUidField =
! 	    (*env)->GetFieldID(env, groupCls, "creatorUID", "I");
! 	group_listStatusField =
! 	    (*env)->GetFieldID(env, groupCls, "listStatus", "I");
! 	group_listGroupsOwnedField =
! 	    (*env)->GetFieldID(env, groupCls, "listGroupsOwned", "I");
! 	group_listMembershipField =
! 	    (*env)->GetFieldID(env, groupCls, "listMembership", "I");
! 	group_listAddField =
! 	    (*env)->GetFieldID(env, groupCls, "listAdd", "I");
! 	group_listDeleteField =
! 	    (*env)->GetFieldID(env, groupCls, "listDelete", "I");
! 	group_membershipCountField =
! 	    (*env)->GetFieldID(env, groupCls, "membershipCount", "I");
! 	group_ownerField =
! 	    (*env)->GetFieldID(env, groupCls, "owner", "Ljava/lang/String;");
! 	group_creatorField =
! 	    (*env)->GetFieldID(env, groupCls, "creator",
! 			       "Ljava/lang/String;");
! 	if (!group_nameField || !group_cachedInfoField || !group_nameUidField
! 	    || !group_ownerUidField || !group_creatorUidField
! 	    || !group_listStatusField || !group_listGroupsOwnedField
! 	    || !group_listMembershipField || !group_listAddField
! 	    || !group_listDeleteField || !group_membershipCountField
! 	    || !group_ownerField || !group_creatorField) {
! 
! 	    throwAFSException(env, JAFSADMFIELDNOTFOUND);
! 	    return;
! 	}
      }
  }
  
  /**
   * Given a Java environment and an instance of a server, gets the object and
   * field information for the server object from the Java environment.
   */
! void
! internal_getServerClass(JNIEnv * env, jobject server)
! {
!     if (serverCls == 0) {
! 	serverCls =
! 	    (*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, server));
! 	if (!serverCls) {
! 	    throwAFSException(env, JAFSADMCLASSNOTFOUND);
! 	    return;
! 	}
! 	server_nameField =
! 	    (*env)->GetFieldID(env, serverCls, "name", "Ljava/lang/String;");
! 	server_cachedInfoField =
! 	    (*env)->GetFieldID(env, serverCls, "cachedInfo", "Z");
! 	server_databaseField =
! 	    (*env)->GetFieldID(env, serverCls, "database", "Z");
! 	server_fileServerField =
! 	    (*env)->GetFieldID(env, serverCls, "fileServer", "Z");
! 	server_badDatabaseField =
! 	    (*env)->GetFieldID(env, serverCls, "badDatabase", "Z");
! 	server_badFileServerField =
! 	    (*env)->GetFieldID(env, serverCls, "badFileServer", "Z");
! 	server_IPAddressField =
! 	    (*env)->GetFieldID(env, serverCls, "ipAddresses",
! 			       "[Ljava/lang/String;");
! 	if (!server_nameField || !server_cachedInfoField
! 	    || !server_databaseField || !server_fileServerField
! 	    || !server_badDatabaseField || !server_badFileServerField
! 	    || !server_IPAddressField) {
  
! 	    throwAFSException(env, JAFSADMFIELDNOTFOUND);
! 	    return;
  
- 	}
      }
  }
  
  /**
--- 472,675 ----
   * the instance is the empty string.  The memory for who 
   * that's passed in should be fully allocated in advance.
   */
! void internal_makeKasIdentity( const char *fullName, 
! 				       kas_identity_p who ) {
! 
!   char *period;
! 
!   if( (period = (char *) strchr( fullName, '.' )) != NULL ) {
!     strncpy( who->principal, fullName, period - fullName );
!     who->principal[period - fullName] = '\0';
!     strncpy( who->instance, period + 1, 
! 	     strlen(fullName) - (period - fullName) );
!   } else {
!     strcpy( who->principal, fullName);
!     strcpy( who->instance, "" );
!   }
  
  }
  
  /**
   * Given a Java environment and an instance of a user, gets the object and
   * field information for the user object from the Java environment.
   */
! void internal_getUserClass( JNIEnv *env, jobject user ) {
!   if( userCls == 0 ) {
!     userCls = (*env)->NewGlobalRef( env, (*env)->GetObjectClass(env, user) );
!     if( !userCls ) {
! 	throwAFSException( env, JAFSADMCLASSNOTFOUND );
! 	return;
!     }
!     user_ptsField = (*env)->GetFieldID( env, userCls, "pts", "Z" );
!     user_kasField = (*env)->GetFieldID( env, userCls, "kas", "Z" );
!     user_nameField = (*env)->GetFieldID( env, userCls, "name", 
! 					 "Ljava/lang/String;" );
!     user_cachedInfoField = (*env)->GetFieldID( env, userCls, "cachedInfo", 
! 					       "Z" );
!     // pts fields
!     user_nameUidField = (*env)->GetFieldID( env, userCls, "nameUID", "I" );
!     user_ownerUidField = (*env)->GetFieldID( env, userCls, "ownerUID", "I" );
!     user_creatorUidField = (*env)->GetFieldID( env, userCls, "creatorUID", 
! 					       "I" );
!     user_listStatusField = (*env)->GetFieldID( env, userCls, "listStatus", 
! 					       "I" );
!     user_listGroupsOwnedField = (*env)->GetFieldID( env, userCls, 
! 						    "listGroupsOwned", "I" );
!     user_listMembershipField = (*env)->GetFieldID( env, userCls, 
! 						   "listMembership", "I" );
!     user_groupCreationQuotaField = (*env)->GetFieldID( env, userCls, 
! 						       "groupCreationQuota", 
! 						       "I" );
!     user_groupMembershipCountField = (*env)->GetFieldID( env, userCls, 
! 							"groupMembershipCount",
! 							 "I" );
!     user_ownerField = (*env)->GetFieldID( env, userCls, "owner", 
! 					  "Ljava/lang/String;" );
!     user_creatorField = (*env)->GetFieldID( env, userCls, "creator", 
! 					    "Ljava/lang/String;" );
!     // kas fields
!     user_adminSettingField = (*env)->GetFieldID( env, userCls, "adminSetting",
! 						 "I" );
!     user_tgsSettingField = (*env)->GetFieldID( env, userCls, "tgsSetting", 
! 					       "I" );
!     user_encSettingField = (*env)->GetFieldID( env, userCls, "encSetting", 
! 					       "I" );
!     user_cpwSettingField = (*env)->GetFieldID( env, userCls, "cpwSetting", 
! 					       "I" );
!     user_rpwSettingField = (*env)->GetFieldID( env, userCls, "rpwSetting", 
! 					       "I" );
!     user_userExpirationField = (*env)->GetFieldID( env, userCls, 
! 						   "userExpiration", "I" );
!     user_lastModTimeField = (*env)->GetFieldID( env, userCls, "lastModTime", 
! 						"I" );
!     user_lastModNameField = (*env)->GetFieldID( env, userCls, "lastModName", 
! 						"Ljava/lang/String;" );
!     user_lastChangePasswordTimeField = (*env)->GetFieldID( env, userCls, 
! 						      "lastChangePasswordTime",
! 							   "I" );
!     user_maxTicketLifetimeField = (*env)->GetFieldID( env, userCls, 
! 						      "maxTicketLifetime", 
! 						      "I" );
!     user_keyVersionField = (*env)->GetFieldID( env, userCls, "keyVersion", 
! 					       "I" );
!     user_encryptionKeyField = (*env)->GetFieldID( env, userCls, 
! 						  "encryptionKey", 
! 						  "Ljava/lang/String;" );
!     user_keyCheckSumField = (*env)->GetFieldID( env, userCls, "keyCheckSum", 
! 						"J" );
!     user_daysToPasswordExpireField = (*env)->GetFieldID( env, userCls, 
! 							"daysToPasswordExpire",
! 							 "I" );
!     user_failLoginCountField = (*env)->GetFieldID( env, userCls, 
! 						   "failLoginCount", "I" );
!     user_lockTimeField = (*env)->GetFieldID( env, userCls, "lockTime", "I" );
!     user_lockedUntilField = (*env)->GetFieldID( env, userCls, "lockedUntil", 
! 						"I" );
!     if( !user_ptsField || !user_kasField || !user_nameField || 
! 	!user_cachedInfoField || !user_nameUidField || !user_ownerUidField || 
! 	!user_creatorUidField || !user_listStatusField || 
! 	!user_listGroupsOwnedField || !user_listMembershipField || 
! 	!user_groupCreationQuotaField || !user_groupMembershipCountField || 
! 	!user_ownerField || !user_creatorField || !user_adminSettingField || 
! 	!user_tgsSettingField || !user_encSettingField || 
! 	!user_cpwSettingField || !user_rpwSettingField || 
! 	!user_userExpirationField || !user_lastModTimeField || 
! 	!user_lastModNameField || !user_lastChangePasswordTimeField || 
! 	!user_maxTicketLifetimeField || !user_keyVersionField || 
! 	!user_encryptionKeyField || !user_keyCheckSumField || 
! 	!user_daysToPasswordExpireField || !user_failLoginCountField || 
! 	!user_lockTimeField || !user_lockedUntilField ) {
! 
! 	throwAFSException( env, JAFSADMFIELDNOTFOUND );
! 	return;
! 
      }
+   } 
  }
  
  /**
   * Given a Java environment and an instance of a group, gets the object and
   * field information for the group object from the Java environment.
   */
! void internal_getGroupClass( JNIEnv *env, jobject group ) {
!   if( groupCls == 0 ) {
!     groupCls = (*env)->NewGlobalRef( env, (*env)->GetObjectClass(env, group) );
!     if( !groupCls ) {
! 	throwAFSException( env, JAFSADMCLASSNOTFOUND );
! 	return;
!     }
!     group_nameField = (*env)->GetFieldID( env, groupCls, "name", 
! 					  "Ljava/lang/String;" );
!     group_cachedInfoField = (*env)->GetFieldID( env, groupCls, "cachedInfo", 
! 						"Z" );
!     group_nameUidField = (*env)->GetFieldID( env, groupCls, "nameUID", "I" );
!     group_ownerUidField = (*env)->GetFieldID( env, groupCls, "ownerUID", "I" );
!     group_creatorUidField = (*env)->GetFieldID( env, groupCls, "creatorUID", 
! 						"I" );
!     group_listStatusField = (*env)->GetFieldID( env, groupCls, "listStatus", 
! 						"I" );
!     group_listGroupsOwnedField = (*env)->GetFieldID( env, groupCls, 
! 						     "listGroupsOwned", "I" );
!     group_listMembershipField = (*env)->GetFieldID( env, groupCls, 
! 						    "listMembership", "I" );
!     group_listAddField = (*env)->GetFieldID( env, groupCls, "listAdd", "I" );
!     group_listDeleteField = (*env)->GetFieldID( env, groupCls, "listDelete", 
! 						"I" );
!     group_membershipCountField = (*env)->GetFieldID( env, groupCls, 
! 						     "membershipCount", "I" );
!     group_ownerField = (*env)->GetFieldID( env, groupCls, "owner", 
! 					   "Ljava/lang/String;" );
!     group_creatorField = (*env)->GetFieldID( env, groupCls, "creator", 
! 					     "Ljava/lang/String;" );
!     if( !group_nameField || !group_cachedInfoField || !group_nameUidField || 
! 	!group_ownerUidField || !group_creatorUidField || 
! 	!group_listStatusField || !group_listGroupsOwnedField || 
! 	!group_listMembershipField || !group_listAddField || 
! 	!group_listDeleteField || !group_membershipCountField || 
! 	!group_ownerField || !group_creatorField ) {
! 
! 	throwAFSException( env, JAFSADMFIELDNOTFOUND );
! 	return;
! 
      }
+   }
  }
  
  /**
   * Given a Java environment and an instance of a server, gets the object and
   * field information for the server object from the Java environment.
   */
! void internal_getServerClass( JNIEnv *env, jobject server ) {
!   if( serverCls == 0 ) {
!     serverCls = (*env)->NewGlobalRef( env,
!                                       (*env)->GetObjectClass(env, server) );
!     if( !serverCls ) {
! 	throwAFSException( env, JAFSADMCLASSNOTFOUND );
! 	return;
!     }
!     server_nameField = (*env)->GetFieldID( env, serverCls, "name", 
! 					   "Ljava/lang/String;" );
!     server_cachedInfoField = (*env)->GetFieldID( env, serverCls, "cachedInfo",
! 						 "Z" );
!     server_databaseField = (*env)->GetFieldID( env, serverCls, "database", 
! 					       "Z" );
!     server_fileServerField = (*env)->GetFieldID( env, serverCls, "fileServer", 
! 						 "Z" );
!     server_badDatabaseField = (*env)->GetFieldID( env, serverCls, 
! 						  "badDatabase", "Z" );
!     server_badFileServerField = (*env)->GetFieldID( env, serverCls, 
! 						    "badFileServer", "Z" );
!     server_IPAddressField = (*env)->GetFieldID( env, serverCls, "ipAddresses",
! 						"[Ljava/lang/String;" );
!     if( !server_nameField || !server_cachedInfoField || !server_databaseField 
! 	|| !server_fileServerField || !server_badDatabaseField || 
! 	!server_badFileServerField || !server_IPAddressField ) {
  
! 	throwAFSException( env, JAFSADMFIELDNOTFOUND );
! 	return;
  
      }
+   }
  }
  
  /**
***************
*** 812,1042 ****
   * object and field information for the executableTime object from the 
   * Java environment.
   */
! void
! internal_getExecTimeClass(JNIEnv * env, jobject exectime)
! {
!     if (exectimeCls == 0) {
! 	exectimeCls =
! 	    (*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, exectime));
! 	if (!exectimeCls) {
! 	    throwAFSException(env, JAFSADMCLASSNOTFOUND);
! 	    return;
! 	}
! 	exectime_HourField =
! 	    (*env)->GetFieldID(env, exectimeCls, "hour", "S");
! 	exectime_MinField =
! 	    (*env)->GetFieldID(env, exectimeCls, "minute", "S");
! 	exectime_SecField =
! 	    (*env)->GetFieldID(env, exectimeCls, "second", "S");
! 	exectime_DayField = (*env)->GetFieldID(env, exectimeCls, "day", "S");
! 	exectime_NowField = (*env)->GetFieldID(env, exectimeCls, "now", "Z");
! 	exectime_NeverField =
! 	    (*env)->GetFieldID(env, exectimeCls, "never", "Z");
! 	if (!exectime_HourField || !exectime_MinField || !exectime_SecField
! 	    || !exectime_DayField || !exectime_NowField
! 	    || !exectime_NeverField) {
  
! 	    throwAFSException(env, JAFSADMFIELDNOTFOUND);
! 	    return;
  
- 	}
      }
  }
  
  /**
   * Given a Java environment and an instance of a partition, gets the object and
   * field information for the partition object from the Java environment.
   */
! void
! internal_getPartitionClass(JNIEnv * env, jobject partition)
! {
!     if (partitionCls == 0) {
! 	partitionCls =
! 	    (*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, partition));
! 	if (!partitionCls) {
! 	    throwAFSException(env, JAFSADMCLASSNOTFOUND);
! 	    return;
! 	}
! 	partition_nameField =
! 	    (*env)->GetFieldID(env, partitionCls, "name",
! 			       "Ljava/lang/String;");
! 	partition_deviceNameField =
! 	    (*env)->GetFieldID(env, partitionCls, "deviceName",
! 			       "Ljava/lang/String;");
! 	partition_idField = (*env)->GetFieldID(env, partitionCls, "id", "I");
! 	partition_cachedInfoField =
! 	    (*env)->GetFieldID(env, partitionCls, "cachedInfo", "Z");
! 	partition_lockFileDescriptorField =
! 	    (*env)->GetFieldID(env, partitionCls, "lockFileDescriptor", "I");
! 	partition_totalSpaceField =
! 	    (*env)->GetFieldID(env, partitionCls, "totalSpace", "I");
! 	partition_totalFreeSpaceField =
! 	    (*env)->GetFieldID(env, partitionCls, "totalFreeSpace", "I");
! 	if (!partition_nameField || !partition_cachedInfoField
! 	    || !partition_idField || !partition_deviceNameField
! 	    || !partition_lockFileDescriptorField
! 	    || !partition_totalSpaceField || !partition_totalFreeSpaceField) {
  
! 	    throwAFSException(env, JAFSADMFIELDNOTFOUND);
! 	    return;
  
- 	}
      }
  }
  
  /**
   * Given a Java environment and an instance of a volume, gets the object and
   * field information for the volume object from the Java environment.
   */
! void
! internal_getVolumeClass(JNIEnv * env, jobject volume)
! {
!     if (volumeCls == 0) {
! 	volumeCls =
! 	    (*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, volume));
! 	if (!volumeCls) {
! 	    throwAFSException(env, JAFSADMCLASSNOTFOUND);
! 	    return;
! 	}
! 	volume_nameField =
! 	    (*env)->GetFieldID(env, volumeCls, "name", "Ljava/lang/String;");
! 	volume_cachedInfoField =
! 	    (*env)->GetFieldID(env, volumeCls, "cachedInfo", "Z");
! 	volume_idField = (*env)->GetFieldID(env, volumeCls, "id", "I");
! 	volume_readWriteIdField =
! 	    (*env)->GetFieldID(env, volumeCls, "readWriteID", "I");
! 	volume_readOnlyIdField =
! 	    (*env)->GetFieldID(env, volumeCls, "readOnlyID", "I");
! 	volume_backupIdField =
! 	    (*env)->GetFieldID(env, volumeCls, "backupID", "I");
! 	volume_creationDateField =
! 	    (*env)->GetFieldID(env, volumeCls, "creationDate", "J");
! 	volume_lastAccessDateField =
! 	    (*env)->GetFieldID(env, volumeCls, "lastAccessDate", "J");
! 	volume_lastUpdateDateField =
! 	    (*env)->GetFieldID(env, volumeCls, "lastUpdateDate", "J");
! 	volume_lastBackupDateField =
! 	    (*env)->GetFieldID(env, volumeCls, "lastBackupDate", "J");
! 	volume_copyCreationDateField =
! 	    (*env)->GetFieldID(env, volumeCls, "copyCreationDate", "J");
! 	volume_accessesSinceMidnightField =
! 	    (*env)->GetFieldID(env, volumeCls, "accessesSinceMidnight", "I");
! 	volume_fileCountField =
! 	    (*env)->GetFieldID(env, volumeCls, "fileCount", "I");
! 	volume_maxQuotaField =
! 	    (*env)->GetFieldID(env, volumeCls, "maxQuota", "I");
! 	volume_currentSizeField =
! 	    (*env)->GetFieldID(env, volumeCls, "currentSize", "I");
! 	volume_statusField =
! 	    (*env)->GetFieldID(env, volumeCls, "status", "I");
! 	volume_dispositionField =
! 	    (*env)->GetFieldID(env, volumeCls, "disposition", "I");
! 	volume_typeField = (*env)->GetFieldID(env, volumeCls, "type", "I");
! 	if (!volume_nameField || !volume_cachedInfoField || !volume_idField
! 	    || !volume_readWriteIdField || !volume_readOnlyIdField
! 	    || !volume_backupIdField || !volume_creationDateField
! 	    || !volume_lastAccessDateField || !volume_lastUpdateDateField
! 	    || !volume_lastBackupDateField || !volume_copyCreationDateField
! 	    || !volume_accessesSinceMidnightField || !volume_fileCountField
! 	    || !volume_maxQuotaField || !volume_currentSizeField
! 	    || !volume_statusField || !volume_dispositionField
! 	    || !volume_typeField) {
  
! 	    throwAFSException(env, JAFSADMFIELDNOTFOUND);
! 	    return;
  
- 	}
      }
  }
  
  /**
   * Given a Java environment and an instance of a key, gets the object and
   * field information for the key object from the Java environment.
   */
! void
! internal_getKeyClass(JNIEnv * env, jobject key)
! {
!     if (keyCls == 0) {
! 	keyCls = (*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, key));
! 	if (!keyCls) {
! 	    throwAFSException(env, JAFSADMCLASSNOTFOUND);
! 	    return;
! 	}
! 	key_encryptionKeyField =
! 	    (*env)->GetFieldID(env, keyCls, "encryptionKey",
! 			       "Ljava/lang/String;");
! 	key_cachedInfoField =
! 	    (*env)->GetFieldID(env, keyCls, "cachedInfo", "Z");
! 	key_versionField = (*env)->GetFieldID(env, keyCls, "version", "I");
! 	key_lastModDateField =
! 	    (*env)->GetFieldID(env, keyCls, "lastModDate", "I");
! 	key_lastModMsField =
! 	    (*env)->GetFieldID(env, keyCls, "lastModMs", "I");
! 	key_checkSumField = (*env)->GetFieldID(env, keyCls, "checkSum", "J");
! 	if (!key_cachedInfoField || !key_versionField
! 	    || !key_encryptionKeyField || !key_lastModDateField
! 	    || !key_lastModMsField || !key_checkSumField) {
  
! 	    throwAFSException(env, JAFSADMFIELDNOTFOUND);
! 	    return;
  
- 	}
      }
  }
  
  /**
   * Given a Java environment and an instance of a process, gets the object and
   * field information for the process object from the Java environment.
   */
! void
! internal_getProcessClass(JNIEnv * env, jobject process)
! {
!     if (processCls == 0) {
! 	processCls =
! 	    (*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, process));
! 	if (!processCls) {
! 	    throwAFSException(env, JAFSADMCLASSNOTFOUND);
! 	    return;
! 	}
! 	process_cachedInfoField =
! 	    (*env)->GetFieldID(env, processCls, "cachedInfo", "Z");
! 	process_nameField =
! 	    (*env)->GetFieldID(env, processCls, "name", "Ljava/lang/String;");
! 	process_typeField = (*env)->GetFieldID(env, processCls, "type", "I");
! 	process_stateField =
! 	    (*env)->GetFieldID(env, processCls, "state", "I");
! 	process_goalField = (*env)->GetFieldID(env, processCls, "goal", "I");
! 	process_startTimeField =
! 	    (*env)->GetFieldID(env, processCls, "startTime", "J");
! 	process_numberStartsField =
! 	    (*env)->GetFieldID(env, processCls, "numberStarts", "J");
! 	process_exitTimeField =
! 	    (*env)->GetFieldID(env, processCls, "exitTime", "J");
! 	process_exitErrorTimeField =
! 	    (*env)->GetFieldID(env, processCls, "exitErrorTime", "J");
! 	process_errorCodeField =
! 	    (*env)->GetFieldID(env, processCls, "errorCode", "J");
! 	process_errorSignalField =
! 	    (*env)->GetFieldID(env, processCls, "errorSignal", "J");
! 	process_stateOkField =
! 	    (*env)->GetFieldID(env, processCls, "stateOk", "Z");
! 	process_stateTooManyErrorsField =
! 	    (*env)->GetFieldID(env, processCls, "stateTooManyErrors", "Z");
! 	process_stateBadFileAccessField =
! 	    (*env)->GetFieldID(env, processCls, "stateBadFileAccess", "Z");
! 	if (!process_cachedInfoField || !process_nameField
! 	    || !process_typeField || !process_stateField || !process_goalField
! 	    || !process_startTimeField || !process_numberStartsField
! 	    || !process_exitTimeField || !process_exitErrorTimeField
! 	    || !process_errorCodeField || !process_errorSignalField
! 	    || !process_stateOkField || !process_stateTooManyErrorsField
! 	    || !process_stateBadFileAccessField) {
  
! 	    throwAFSException(env, JAFSADMFIELDNOTFOUND);
! 	    return;
  
- 	}
      }
  }
  
  #endif /* LIBJUAFS */
--- 677,896 ----
   * object and field information for the executableTime object from the 
   * Java environment.
   */
! void internal_getExecTimeClass( JNIEnv *env, jobject exectime ) {
!   if( exectimeCls == 0 ) {
!     exectimeCls = (*env)->NewGlobalRef( env, 
! 				       (*env)->GetObjectClass(env, exectime) );
!     if( !exectimeCls ) {
! 	throwAFSException( env, JAFSADMCLASSNOTFOUND );
! 	return;
!     }
!     exectime_HourField  = (*env)->GetFieldID( env, exectimeCls, "hour", "S" );
!     exectime_MinField   = (*env)->GetFieldID( env, exectimeCls, "minute", 
! 					      "S" );
!     exectime_SecField   = (*env)->GetFieldID( env, exectimeCls, "second", 
! 					      "S" );
!     exectime_DayField   = (*env)->GetFieldID( env, exectimeCls, "day", "S" );
!     exectime_NowField   = (*env)->GetFieldID( env, exectimeCls, "now", "Z" );
!     exectime_NeverField = (*env)->GetFieldID( env, exectimeCls, "never", "Z" );
!     if( !exectime_HourField || !exectime_MinField || !exectime_SecField || 
! 	!exectime_DayField || !exectime_NowField || !exectime_NeverField ) {
  
! 	throwAFSException( env, JAFSADMFIELDNOTFOUND );
! 	return;
  
      }
+   }
  }
  
  /**
   * Given a Java environment and an instance of a partition, gets the object and
   * field information for the partition object from the Java environment.
   */
! void internal_getPartitionClass( JNIEnv *env, jobject partition ) {
!   if( partitionCls == 0 ) {
!     partitionCls = (*env)->NewGlobalRef( env, 
! 				      (*env)->GetObjectClass(env, partition) );
!     if( !partitionCls ) {
! 	throwAFSException( env, JAFSADMCLASSNOTFOUND );
! 	return;
!     }
!     partition_nameField = (*env)->GetFieldID( env, partitionCls, "name", 
! 					      "Ljava/lang/String;" );
!     partition_deviceNameField = (*env)->GetFieldID( env, partitionCls, 
! 						    "deviceName", 
! 						    "Ljava/lang/String;" );
!     partition_idField = (*env)->GetFieldID( env, partitionCls, "id", "I" );
!     partition_cachedInfoField = (*env)->GetFieldID( env, partitionCls, 
! 						    "cachedInfo", "Z" );
!     partition_lockFileDescriptorField = (*env)->GetFieldID( env, partitionCls,
! 							  "lockFileDescriptor",
! 							    "I" );
!     partition_totalSpaceField = (*env)->GetFieldID( env, partitionCls, 
! 						    "totalSpace", "I" );
!     partition_totalFreeSpaceField = (*env)->GetFieldID( env, partitionCls, 
! 							"totalFreeSpace", "I");
!     if( !partition_nameField || !partition_cachedInfoField || 
! 	!partition_idField || !partition_deviceNameField || 
! 	!partition_lockFileDescriptorField || !partition_totalSpaceField || 
! 	!partition_totalFreeSpaceField ) {
  
! 	throwAFSException( env, JAFSADMFIELDNOTFOUND );
! 	return;
  
      }
+   }
  }
  
  /**
   * Given a Java environment and an instance of a volume, gets the object and
   * field information for the volume object from the Java environment.
   */
! void internal_getVolumeClass( JNIEnv *env, jobject volume ) {
!   if( volumeCls == 0 ) {
!     volumeCls = (*env)->NewGlobalRef( env, 
! 				      (*env)->GetObjectClass(env, volume) );
!     if( !volumeCls ) {
! 	throwAFSException( env, JAFSADMCLASSNOTFOUND );
! 	return;
!     }
!     volume_nameField = (*env)->GetFieldID( env, volumeCls, "name", 
! 					   "Ljava/lang/String;" );
!     volume_cachedInfoField = (*env)->GetFieldID( env, volumeCls, "cachedInfo", 
! 						 "Z" );
!     volume_idField = (*env)->GetFieldID( env, volumeCls, "id", "I" );
!     volume_readWriteIdField = (*env)->GetFieldID( env, volumeCls, 
! 						  "readWriteID", "I" );
!     volume_readOnlyIdField = (*env)->GetFieldID( env, volumeCls, "readOnlyID", 
! 						 "I" );
!     volume_backupIdField = (*env)->GetFieldID( env, volumeCls, "backupID", 
! 					       "I" );
!     volume_creationDateField = (*env)->GetFieldID( env, volumeCls, 
! 						   "creationDate", "J" );
!     volume_lastAccessDateField = (*env)->GetFieldID( env, volumeCls, 
! 						     "lastAccessDate", "J" );
!     volume_lastUpdateDateField = (*env)->GetFieldID( env, volumeCls, 
! 						     "lastUpdateDate", "J" );
!     volume_lastBackupDateField = (*env)->GetFieldID( env, volumeCls, 
! 						     "lastBackupDate", "J" );
!     volume_copyCreationDateField = (*env)->GetFieldID( env, volumeCls, 
! 						       "copyCreationDate", 
! 						       "J" );
!     volume_accessesSinceMidnightField = (*env)->GetFieldID( env, volumeCls, 
! 						       "accessesSinceMidnight",
! 							    "I" );
!     volume_fileCountField = (*env)->GetFieldID( env, volumeCls, "fileCount", 
! 						"I" );
!     volume_maxQuotaField = (*env)->GetFieldID( env, volumeCls, "maxQuota", 
! 					       "I" );
!     volume_currentSizeField = (*env)->GetFieldID( env, volumeCls, 
! 						  "currentSize", "I" );
!     volume_statusField = (*env)->GetFieldID( env, volumeCls, "status", "I" );
!     volume_dispositionField = (*env)->GetFieldID( env, volumeCls, 
! 						  "disposition", "I" );
!     volume_typeField = (*env)->GetFieldID( env, volumeCls, "type", "I" );
!     if( !volume_nameField || !volume_cachedInfoField || !volume_idField || 
! 	!volume_readWriteIdField || !volume_readOnlyIdField || 
! 	!volume_backupIdField || !volume_creationDateField || 
! 	!volume_lastAccessDateField || !volume_lastUpdateDateField || 
! 	!volume_lastBackupDateField || !volume_copyCreationDateField || 
! 	!volume_accessesSinceMidnightField || !volume_fileCountField || 
! 	!volume_maxQuotaField || !volume_currentSizeField || 
! 	!volume_statusField || !volume_dispositionField || 
! 	!volume_typeField ) {
  
! 	throwAFSException( env, JAFSADMFIELDNOTFOUND );
! 	return;
  
      }
+   }
  }
  
  /**
   * Given a Java environment and an instance of a key, gets the object and
   * field information for the key object from the Java environment.
   */
! void internal_getKeyClass( JNIEnv *env, jobject key ) {
!   if( keyCls == 0 ) {
!     keyCls = (*env)->NewGlobalRef( env, (*env)->GetObjectClass(env, key) );
!     if( !keyCls ) {
! 	throwAFSException( env, JAFSADMCLASSNOTFOUND );
! 	return;
!     }
!     key_encryptionKeyField = (*env)->GetFieldID( env, keyCls, 
! 						 "encryptionKey", 
! 						 "Ljava/lang/String;" );
!     key_cachedInfoField = (*env)->GetFieldID( env, keyCls, "cachedInfo", "Z" );
!     key_versionField = (*env)->GetFieldID( env, keyCls, "version", "I" );
!     key_lastModDateField = (*env)->GetFieldID( env, keyCls, "lastModDate", 
! 					       "I" );
!     key_lastModMsField = (*env)->GetFieldID( env, keyCls, "lastModMs", "I" );
!     key_checkSumField = (*env)->GetFieldID( env, keyCls, "checkSum", "J" );
!     if( !key_cachedInfoField || !key_versionField || !key_encryptionKeyField 
! 	|| !key_lastModDateField || !key_lastModMsField || 
! 	!key_checkSumField ) {
  
! 	throwAFSException( env, JAFSADMFIELDNOTFOUND );
! 	return;
  
      }
+   }
  }
  
  /**
   * Given a Java environment and an instance of a process, gets the object and
   * field information for the process object from the Java environment.
   */
! void internal_getProcessClass( JNIEnv *env, jobject process ) {
!   if( processCls == 0 ) {
!     processCls = (*env)->NewGlobalRef( env, 
! 				       (*env)->GetObjectClass(env, process) );
!     if( !processCls ) {
! 	throwAFSException( env, JAFSADMCLASSNOTFOUND );
! 	return;
!     }
!     process_cachedInfoField = (*env)->GetFieldID( env, processCls, 
! 						  "cachedInfo", "Z" );
!     process_nameField = (*env)->GetFieldID( env, processCls, "name", 
! 					    "Ljava/lang/String;" );
!     process_typeField = (*env)->GetFieldID( env, processCls, "type", "I" );
!     process_stateField = (*env)->GetFieldID( env, processCls, "state", "I" );
!     process_goalField = (*env)->GetFieldID( env, processCls, "goal", "I" );
!     process_startTimeField = (*env)->GetFieldID( env, processCls, "startTime", 
! 						 "J" ); 
!     process_numberStartsField = (*env)->GetFieldID( env, processCls, 
! 						    "numberStarts", "J" ); 
!     process_exitTimeField = (*env)->GetFieldID( env, processCls, "exitTime", 
! 						"J" ); 
!     process_exitErrorTimeField = (*env)->GetFieldID( env, processCls, 
! 						     "exitErrorTime", "J" ); 
!     process_errorCodeField = (*env)->GetFieldID( env, processCls, "errorCode", 
! 						 "J" ); 
!     process_errorSignalField = (*env)->GetFieldID( env, processCls, 
! 						   "errorSignal", "J" ); 
!     process_stateOkField = (*env)->GetFieldID( env, processCls, "stateOk", 
! 					       "Z" ); 
!     process_stateTooManyErrorsField = (*env)->GetFieldID( env, processCls, 
! 							  "stateTooManyErrors",
! 							  "Z" ); 
!     process_stateBadFileAccessField = (*env)->GetFieldID( env, processCls, 
! 							  "stateBadFileAccess",
! 							  "Z" ); 
!     if( !process_cachedInfoField || !process_nameField || !process_typeField 
! 	|| !process_stateField || !process_goalField || 
! 	!process_startTimeField || !process_numberStartsField || 
! 	!process_exitTimeField || !process_exitErrorTimeField || 
! 	!process_errorCodeField || !process_errorSignalField || 
! 	!process_stateOkField || !process_stateTooManyErrorsField || 
! 	!process_stateBadFileAccessField ) {
  
! 	throwAFSException( env, JAFSADMFIELDNOTFOUND );
! 	return;
  
      }
+   }
  }
  
  #endif /* LIBJUAFS */
+ 
+ 
Index: openafs/src/JAVA/libjafs/Internal.h
diff -c openafs/src/JAVA/libjafs/Internal.h:1.3 openafs/src/JAVA/libjafs/Internal.h:1.3.2.1
*** openafs/src/JAVA/libjafs/Internal.h:1.3	Tue Jul 15 19:11:26 2003
--- openafs/src/JAVA/libjafs/Internal.h	Fri Oct 14 22:14:12 2005
***************
*** 4,80 ****
  #include <jni.h>
  #include "Exceptions.h"
  
- /** 
-  * ERROR CODES
-  *
-  * Please add any internal error codes to the ErrorMessages.properties
-  * file located in src/JAVA/classes/
-  */
- #define JAFSADMNOMEM          1050	// Memory problems
- #define JAFSADMCLASSNOTFOUND  1051	// Trouble finding a Java class
- #define JAFSADMMETHODNOTFOUND 1052	// Trouble finding a Java method
- #define JAFSADMFIELDNOTFOUND  1053	// Trouble finding a Java field
- #define JAFSNULLARG           1054	// Null argument (general)
- #define JAFSNULLUSER          1055	// User argument null
- #define JAFSNULLPASS          1056	// Password argument null
- #define JAFSNULLGROUP         1057	// Group name argument null
- #define JAFSNULLOWNER         1058	// Group owner name argument null
- #define JAFSNULLVOLUME        1059	// Volume name argument null
- #define JAFSNULLPART          1060	// Partition name argument null
- #define JAFSNULLPROCESS       1061	// Process name argument null
- #define JAFSNULLSERVER        1062	// Server name argument null
- #define JAFSNULLCELL          1063	// Cell name argument null
- #define JAFSNULLPATH          1064	// Path argument null
- #define JAFSNULLACL           1065	// ACL string argument null
- 
  #ifndef LIBJUAFS
  #include <afs_Admin.h>
  #include <afs_kasAdmin.h>
  
  // make an identity out of a full name (possibly including an instance ) 
! void internal_makeKasIdentity(const char *fullName, kas_identity_p who);
  
! void internal_getUserClass(JNIEnv * env, jobject user);
! void internal_getGroupClass(JNIEnv * env, jobject group);
! void internal_getServerClass(JNIEnv * env, jobject server);
! void internal_getPartitionClass(JNIEnv * env, jobject partition);
! void internal_getVolumeClass(JNIEnv * env, jobject volume);
! void internal_getKeyClass(JNIEnv * env, jobject key);
! void internal_getProcessClass(JNIEnv * env, jobject process);
  #else
! int openAFSFile(JNIEnv * env, jstring fileNameUTF, int flags, int mode,
! 		int *err);
  int readCacheParms(char *afsMountPoint, char *afsConfDir, char *afsCacheDir,
! 		   int *cacheBlocks, int *cacheFiles, int *cacheStatEntries,
! 		   int *dCacheSize, int *vCacheSize, int *chunkSize,
! 		   int *closeSynch, int *debug, int *nDaemons,
! 		   int *cacheFlags, char *logFile);
  #endif /* !LIBJUAFS */
  
  // throw a non-AFS exception with a message
! void throwMessageException(JNIEnv * env, char *msg);
  
  // throw an AFS exception with a message
! void throwAFSException(JNIEnv * env, int code);
  
  // throw an AFS Admin exception with a message
! void throwAFSException(JNIEnv * env, int code);
  
  // throw an AFS File or I/O related exception with a message
! void throwFileAdminException(JNIEnv * env, int code, char *msg);
  
  // throw an AFS Security exception with a message
! void throwAFSSecurityException(JNIEnv * env, int code);
  
  // throw an exception with an error code
! void throwException(JNIEnv * env, jclass * excCls, char *excClsName,
! 		    jmethodID * initID, int code);
  
  // reclaim global memory used by exceptions 
! void reclaimExceptionMemory(JNIEnv * env, jclass cls);
  
! int setError(JNIEnv * env, jobject * obj, int code);
! int setString(JNIEnv * env, jobject * obj, char *field, char *string);
! char *getNativeString(JNIEnv * env, jstring jstr);
  
  #endif
--- 4,63 ----
  #include <jni.h>
  #include "Exceptions.h"
  
  #ifndef LIBJUAFS
  #include <afs_Admin.h>
  #include <afs_kasAdmin.h>
  
+ // error codes
+ #define JAFSADMNOMEM 1050             // Memory problems
+ #define JAFSADMCLASSNOTFOUND  1051    // Trouble finding a Java class
+ #define JAFSADMMETHODNOTFOUND 1052    // Trouble finding a Java method
+ #define JAFSADMFIELDNOTFOUND  1053    // Trouble finding a Java field
+ 
  // make an identity out of a full name (possibly including an instance ) 
! void internal_makeKasIdentity( const char *fullName, kas_identity_p who );
  
! void internal_getUserClass( JNIEnv *env, jobject user );
! void internal_getGroupClass( JNIEnv *env, jobject group );
! void internal_getServerClass( JNIEnv *env, jobject server );
! void internal_getPartitionClass( JNIEnv *env, jobject partition );
! void internal_getVolumeClass( JNIEnv *env, jobject volume );
! void internal_getKeyClass( JNIEnv *env, jobject key );
! void internal_getProcessClass( JNIEnv *env, jobject process );
  #else
! int openAFSFile(JNIEnv *env, jstring fileNameUTF, int flags, int mode, int *err);
  int readCacheParms(char *afsMountPoint, char *afsConfDir, char *afsCacheDir,
!                    int *cacheBlocks, int *cacheFiles, int *cacheStatEntries,
!                    int *dCacheSize, int *vCacheSize, int *chunkSize,
!                    int *closeSynch, int *debug, int *nDaemons, int *cacheFlags,
!                    char *logFile);
  #endif /* !LIBJUAFS */
  
  // throw a non-AFS exception with a message
! void throwMessageException( JNIEnv *env, char *msg );
  
  // throw an AFS exception with a message
! void throwAFSException( JNIEnv *env, int code );
  
  // throw an AFS Admin exception with a message
! void throwAFSException( JNIEnv *env, int code );
  
  // throw an AFS File or I/O related exception with a message
! void throwFileAdminException( JNIEnv *env, int code, char *msg );
  
  // throw an AFS Security exception with a message
! void throwAFSSecurityException( JNIEnv *env, int code );
  
  // throw an exception with an error code
! void throwException( JNIEnv *env, jclass *excCls, char *excClsName, jmethodID *initID, int code );
  
  // reclaim global memory used by exceptions 
! void reclaimExceptionMemory( JNIEnv *env, jclass cls );
  
! int setError(JNIEnv *env, jobject *obj, int code);
! int setString(JNIEnv *env, jobject *obj, char *field, char *string);
  
  #endif
+ 
+ 
+ 
Index: openafs/src/JAVA/libjafs/JAFS_Version.h
diff -c /dev/null openafs/src/JAVA/libjafs/JAFS_Version.h:1.1.2.2
*** /dev/null	Sat Oct 22 02:14:46 2005
--- openafs/src/JAVA/libjafs/JAFS_Version.h	Fri Oct 14 22:14:12 2005
***************
*** 0 ****
--- 1,10 ----
+ #ifndef __JAFS_VERSION_H_1234__
+ #define __JAFS_VERSION_H_1234__
+ 
+ #include "Internal.h"
+ 
+ #define VERSION_LIB_JAVA_OPENAFS "20050928_01"
+ 
+ extern char cml_version_number[]; /* from AFS_component_number.c */
+ 
+ #endif /* __JAFS_VERSION_H_1234__ */
Index: openafs/src/JAVA/libjafs/Key.c
diff -c openafs/src/JAVA/libjafs/Key.c:1.3 openafs/src/JAVA/libjafs/Key.c:1.3.2.1
*** openafs/src/JAVA/libjafs/Key.c:1.3	Tue Jul 15 19:11:26 2003
--- openafs/src/JAVA/libjafs/Key.c	Fri Oct 14 22:14:12 2005
***************
*** 44,84 ****
   * key      the Key object to populate with the info
   * keyEntry     the container of the key's information
   */
! void
! fillKeyInfo(JNIEnv * env, jobject key, bos_KeyInfo_t keyEntry)
  {
!     jstring jencryptionKey;
!     char *convertedKey;
!     int i;
! 
!     // get the class fields if need be
!     if (keyCls == 0) {
! 	internal_getKeyClass(env, key);
!     }
!     // set all the fields
!     (*env)->SetIntField(env, key, key_versionField,
! 			keyEntry.keyVersionNumber);
! 
!     convertedKey =
! 	(char *)malloc(sizeof(char *) * (sizeof(keyEntry.key.key) * 4 + 1));
!     if (!convertedKey) {
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return;
!     }
!     for (i = 0; i < sizeof(keyEntry.key.key); i++) {
! 	sprintf(&(convertedKey[i * 4]), "\\%0.3o", keyEntry.key.key[i]);
!     }
!     jencryptionKey = (*env)->NewStringUTF(env, convertedKey);
!     (*env)->SetObjectField(env, key, key_encryptionKeyField, jencryptionKey);
  
!     (*env)->SetIntField(env, key, key_lastModDateField,
! 			keyEntry.keyStatus.lastModificationDate);
!     (*env)->SetIntField(env, key, key_lastModMsField,
! 			keyEntry.keyStatus.lastModificationMicroSeconds);
!     (*env)->SetLongField(env, key, key_checkSumField,
! 			 (unsigned int)keyEntry.keyStatus.checkSum);
! 
!     free(convertedKey);
  }
  
  /**
--- 44,83 ----
   * key      the Key object to populate with the info
   * keyEntry     the container of the key's information
   */
! void fillKeyInfo( JNIEnv *env, jobject key, bos_KeyInfo_t keyEntry )
  {
!   jstring jencryptionKey;
!   char *convertedKey;
!   int i;
! 
!   // get the class fields if need be
!   if( keyCls == 0 ) {
!     internal_getKeyClass( env, key );
!   }
! 
!   // set all the fields
!   (*env)->SetIntField( env, key, key_versionField, keyEntry.keyVersionNumber );
!   
!   convertedKey = (char *) malloc( sizeof(char *)*
! 				  (sizeof(keyEntry.key.key)*4+1) );
!   if( !convertedKey ) {
!     throwAFSException( env, JAFSADMNOMEM );
!     return;    
!   }
!   for( i = 0; i < sizeof(keyEntry.key.key); i++ ) {
!     sprintf( &(convertedKey[i*4]), "\\%0.3o", keyEntry.key.key[i] );
!   }
!   jencryptionKey = (*env)->NewStringUTF(env, convertedKey);
!   (*env)->SetObjectField( env, key, key_encryptionKeyField, jencryptionKey );
!   
!   (*env)->SetIntField( env, key, key_lastModDateField, 
! 		       keyEntry.keyStatus.lastModificationDate );
!   (*env)->SetIntField( env, key, key_lastModMsField, 
! 		       keyEntry.keyStatus.lastModificationMicroSeconds );
!   (*env)->SetLongField( env, key, key_checkSumField, 
! 			(unsigned int) keyEntry.keyStatus.checkSum );
  
!   free( convertedKey );
  }
  
  /**
***************
*** 92,147 ****
   * key     the Key object in which to fill in the 
   *                information
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Key_getKeyInfo(JNIEnv * env, jclass cls,
! 				     jint serverHandle, jint version,
! 				     jobject key)
  {
!     afs_status_t ast;
!     bos_KeyInfo_t keyEntry;
!     void *iterationId;
!     int done;
! 
!     if (!bos_KeyGetBegin((void *)serverHandle, &iterationId, &ast)) {
! 	throwAFSException(env, ast);
! 	return;
!     }
! 
!     done = FALSE;
! 
!     // there's no KeyGet function, so we must iterate and find the 
!     // one with the matching version
!     while (!done) {
! 
! 	if (!bos_KeyGetNext(iterationId, &keyEntry, &ast)) {
! 	    // no matching key
! 	    if (ast == ADMITERATORDONE) {
! 		afs_status_t astnew;
! 		if (!bos_KeyGetDone(iterationId, &astnew)) {
! 		    throwAFSException(env, astnew);
! 		    return;
! 		}
! 		throwAFSException(env, KAUNKNOWNKEY);
! 		return;
! 		// other
! 	    } else {
! 		throwAFSException(env, ast);
! 		return;
! 	    }
! 	}
! 
! 	if (keyEntry.keyVersionNumber == version) {
! 	    done = TRUE;
! 	}
! 
!     }
! 
!     fillKeyInfo(env, key, keyEntry);
! 
!     if (!bos_KeyGetDone(iterationId, &ast)) {
! 	throwAFSException(env, ast);
! 	return;
!     }
  
  }
  
--- 91,145 ----
   * key     the Key object in which to fill in the 
   *                information
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Key_getKeyInfo
!   (JNIEnv *env, jclass cls, jlong serverHandle, jint version, jobject key)
  {
!   afs_status_t ast;
!   bos_KeyInfo_t keyEntry;
!   void *iterationId;
!   int done;
! 
!   if( !bos_KeyGetBegin( (void *) serverHandle, &iterationId, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
! 
!   done = FALSE;
! 
!   // there's no KeyGet function, so we must iterate and find the 
!   // one with the matching version
!   while( !done ) {
! 
!     if( !bos_KeyGetNext( iterationId, &keyEntry, &ast ) ) {
!       // no matching key
!       if( ast == ADMITERATORDONE ) {
!         afs_status_t astnew;
!         if( !bos_KeyGetDone( iterationId, &astnew ) ) {
!           throwAFSException( env, astnew );
!           return;
!         }
!         throwAFSException( env, KAUNKNOWNKEY );
!         return;
!         // other
!       } else {
!         throwAFSException( env, ast );
!         return;
!       }
!     }
! 
!     if( keyEntry.keyVersionNumber == version ) {
!       done = TRUE;
!     }
! 
!   }
! 
!   fillKeyInfo( env, key, keyEntry );
! 
!   if( !bos_KeyGetDone( iterationId, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
  }
  
***************
*** 157,216 ****
   * jkeyString     the String version of the key that will
   *                      be encrypted
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Key_create(JNIEnv * env, jclass cls, jint cellHandle,
! 				 jint serverHandle, jint version,
! 				 jstring jkeyString)
  {
      afs_status_t ast;
!     char *keyString;
      char *cellName;
!     kas_encryptionKey_p key =
! 	(kas_encryptionKey_p) malloc(sizeof(kas_encryptionKey_t));
! 
!     if (!key) {
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return;
      }
  
!     if (jkeyString != NULL) {
! 	keyString = getNativeString(env, jkeyString);
! 	if (keyString == NULL) {
! 	    free(key);
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
      } else {
! 	keyString = NULL;
      }
  
!     if (!afsclient_CellNameGet((void *)cellHandle, &cellName, &ast)) {
! 	free(key);
! 	if (keyString != NULL)
! 	    free(keyString);
! 	throwAFSException(env, ast);
  	return;
!     }
  
!     if (!kas_StringToKey(cellName, keyString, key, &ast)) {
! 	free(key);
! 	if (keyString != NULL)
! 	    free(keyString);
! 	throwAFSException(env, ast);
  	return;
      }
  
!     if (!bos_KeyCreate((void *)serverHandle, version, key, &ast)) {
! 	free(key);
! 	if (keyString != NULL)
! 	    free(keyString);
! 	throwAFSException(env, ast);
  	return;
      }
  
!     free(key);
!     if (keyString != NULL)
! 	free(keyString);
  }
  
  /**
--- 155,217 ----
   * jkeyString     the String version of the key that will
   *                      be encrypted
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Key_create
!   (JNIEnv *env, jclass cls, jlong cellHandle, jlong serverHandle, jint version, 
!    jstring jkeyString)
  {
      afs_status_t ast;
!     const char *keyString;
      char *cellName;
!     kas_encryptionKey_p key = 
!       (kas_encryptionKey_p) malloc( sizeof(kas_encryptionKey_t) );
!     
!     if( !key ) {
!       throwAFSException( env, JAFSADMNOMEM );
!       return;    
      }
  
!     if( jkeyString != NULL ) {
!       keyString = (*env)->GetStringUTFChars(env, jkeyString, 0);
!       if( !keyString ) {
! 	  throwAFSException( env, JAFSADMNOMEM );
! 	  return;    
!       }
      } else {
!       keyString = NULL;
      }
  
!     if( !afsclient_CellNameGet( (void *) cellHandle, &cellName, &ast ) ) {
! 	free( key );
! 	if( keyString != NULL ) {
! 	  (*env)->ReleaseStringUTFChars(env, jkeyString, keyString);
! 	}
! 	throwAFSException( env, ast );
  	return;
!     }   
  
!     if( !kas_StringToKey( cellName, keyString, key, &ast ) ) {
! 	free( key );
! 	if( keyString != NULL ) {
! 	  (*env)->ReleaseStringUTFChars(env, jkeyString, keyString);
! 	}
! 	throwAFSException( env, ast );
  	return;
      }
  
!     if( !bos_KeyCreate( (void *) serverHandle, version, key, &ast ) ) {
! 	free( key );
! 	if( keyString != NULL ) {
! 	  (*env)->ReleaseStringUTFChars(env, jkeyString, keyString);
! 	}
! 	throwAFSException( env, ast );
  	return;
      }
  
!     free( key );
!     if( keyString != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jkeyString, keyString);
!     }
  }
  
  /**
***************
*** 221,244 ****
   * serverHandle  the bos handle of the server to which the key belongs
   * versionNumber   the version number of the key to remove (0 to 255)
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Key_delete(JNIEnv * env, jclass cls, jint serverHandle,
! 				 jint version)
  {
      afs_status_t ast;
  
!     if (!bos_KeyDelete((void *)serverHandle, version, &ast)) {
! 	throwAFSException(env, ast);
  	return;
      }
  }
  
  // reclaim global memory being used by this portion
  JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Key_reclaimKeyMemory(JNIEnv * env, jclass cls)
  {
!     if (keyCls) {
! 	(*env)->DeleteGlobalRef(env, keyCls);
! 	keyCls = 0;
!     }
  }
--- 222,249 ----
   * serverHandle  the bos handle of the server to which the key belongs
   * versionNumber   the version number of the key to remove (0 to 255)
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Key_delete
!   (JNIEnv *env, jclass cls, jlong serverHandle, jint version )
  {
      afs_status_t ast;
  
!     if( !bos_KeyDelete( (void *) serverHandle, version, &ast ) ) {
! 	throwAFSException( env, ast );
  	return;
      }
  }
  
  // reclaim global memory being used by this portion
  JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Key_reclaimKeyMemory (JNIEnv *env, jclass cls)
  {
!   if( keyCls ) {
!       (*env)->DeleteGlobalRef(env, keyCls);
!       keyCls = 0;
!   }
  }
+ 
+ 
+ 
+ 
Index: openafs/src/JAVA/libjafs/Makefile.in
diff -c openafs/src/JAVA/libjafs/Makefile.in:1.3 openafs/src/JAVA/libjafs/Makefile.in:1.3.2.1
*** openafs/src/JAVA/libjafs/Makefile.in:1.3	Thu Jun 19 12:53:15 2003
--- openafs/src/JAVA/libjafs/Makefile.in	Fri Oct 14 22:14:12 2005
***************
*** 5,17 ****
  # License.  For details, see the LICENSE file in the top-level source
  # directory or online at http://www.openafs.org/dl/license10.html
  
  DEST=@DEST@
  TOP_SRCDIR=@TOP_SRCDIR@
  TOP_INCDIR=@TOP_INCDIR@
  TOP_LIBDIR=@TOP_LIBDIR@
! TOP_JLIBDIR=@TOP_JLIBDIR@
! JAVA_HOME=@JAVA_HOME@
! JNI_INC=@JNI_INC@
  prefix=@prefix@
  exec_prefix=@exec_prefix@
  bindir=@bindir@
--- 5,19 ----
  # License.  For details, see the LICENSE file in the top-level source
  # directory or online at http://www.openafs.org/dl/license10.html
  
+ include ../../config/Makefile.config
+ #${SYS_NAME}
+ 
  DEST=@DEST@
  TOP_SRCDIR=@TOP_SRCDIR@
  TOP_INCDIR=@TOP_INCDIR@
  TOP_LIBDIR=@TOP_LIBDIR@
! TOP_JLIBDIR=@TOP_SRCDIR@/JAVA/libjafs
! JNI_INC=${JAVA_HOME}/include
  prefix=@prefix@
  exec_prefix=@exec_prefix@
  bindir=@bindir@
***************
*** 27,62 ****
  RXGEN=${TOP_SRCDIR}/rxgen/rxgen
  SYS_NAME=@AFS_SYSNAME@
  
- include ../../config/Makefile.${SYS_NAME}
  
  CC = ${MT_CC}
! SHARED_FLAGS = -shared
  OBJECT_FLAGS = -fPIC -c
  
  ifeq "$(BUILD_TYPE)" "admin"
! 	INC := -I${TOP_INCDIR} -I${TOP_INCDIR}/afs/ ${JNI_INC}
  	CFLAGS := ${INC} ${DBG} ${OPTMZ} -I${TOP_SRCDIR}/config ${MT_CFLAGS}
  else
! 	INC := -I${TOP_SRCDIR}/libuafs -I${TOP_INCDIR} -I${TOP_SRCDIR} ${JNI_INC}
  	CFLAGS := ${INC} ${DBG} ${OPTMZ} ${FSINCLUDES} -D_REENTRANT -DLIBJUAFS ${MT_CFLAGS}
  endif
  
- ifeq "$(INCREMENT_BUILD)" "false"
- 	INCREMENT_CMD :=
- else
- 	INCREMENT_CMD := ${RM} -f ${LIBJAFSADMDIR}VersionInfo.o; perl buildinfo.pl ${LIBJAFSADMDIR}VersionInfo.h -i;
- endif
  
  LIBJAFSADMDIR = ./
  ROOTPACKAGEDIR = ../classes
  RELPACKAGEDIR = org/openafs/jafs/
  PACKAGEDIR = ${ROOTPACKAGEDIR}/${RELPACKAGEDIR}
! JAVADOCSDIR = ../javadocs/
! BUILD_VERSION = `perl buildinfo.pl ${LIBJAFSADMDIR}VersionInfo.h -version`
  
  JAVAH = ${JAVA_HOME}/bin/javah -classpath ${ROOTPACKAGEDIR} -jni -d ${LIBJAFSADMDIR}
  JAVAC = ${JAVA_HOME}/bin/javac -classpath ${ROOTPACKAGEDIR}
- JAVADOC = ${JAVA_HOME}/bin/javadoc
  
  J_NATIVE_PREFIX = org.openafs.jafs.
  C_NATIVE_PREFIX = org_openafs_jafs_
--- 29,56 ----
  RXGEN=${TOP_SRCDIR}/rxgen/rxgen
  SYS_NAME=@AFS_SYSNAME@
  
  
  CC = ${MT_CC}
! SHARED_FLAGS = -shared -Xlinker -Bsymbolic
  OBJECT_FLAGS = -fPIC -c
  
  ifeq "$(BUILD_TYPE)" "admin"
! 	INC := -I${TOP_INCDIR} -I${TOP_INCDIR}/afs/ -I${JAVA_HOME}/include -I ${JNI_INC}
  	CFLAGS := ${INC} ${DBG} ${OPTMZ} -I${TOP_SRCDIR}/config ${MT_CFLAGS}
  else
! 	INC := -I${TOP_SRCDIR}/libuafs -I${TOP_INCDIR} -I${JAVA_HOME}/include -I ${JNI_INC}
  	CFLAGS := ${INC} ${DBG} ${OPTMZ} ${FSINCLUDES} -D_REENTRANT -DLIBJUAFS ${MT_CFLAGS}
  endif
  
  
  LIBJAFSADMDIR = ./
  ROOTPACKAGEDIR = ../classes
  RELPACKAGEDIR = org/openafs/jafs/
  PACKAGEDIR = ${ROOTPACKAGEDIR}/${RELPACKAGEDIR}
! JAVADOCSDIR = javadocs/
  
  JAVAH = ${JAVA_HOME}/bin/javah -classpath ${ROOTPACKAGEDIR} -jni -d ${LIBJAFSADMDIR}
  JAVAC = ${JAVA_HOME}/bin/javac -classpath ${ROOTPACKAGEDIR}
  
  J_NATIVE_PREFIX = org.openafs.jafs.
  C_NATIVE_PREFIX = org_openafs_jafs_
***************
*** 77,95 ****
  	${PACKAGEDIR}Server.class \
  	${PACKAGEDIR}Token.class \
  	${PACKAGEDIR}User.class \
! 	${PACKAGEDIR}VersionInfo.class \
! 	${PACKAGEDIR}Volume.class
  
  LIBJAFS_OBJS =\
! 	${LIBJAFSADMDIR}ACL.o \
  	${LIBJAFSADMDIR}File.o \
  	${LIBJAFSADMDIR}FileInputStream.o \
  	${LIBJAFSADMDIR}FileOutputStream.o \
  	${LIBJAFSADMDIR}Internal.o \
  	${LIBJAFSADMDIR}UserToken.o \
! 	${LIBJAFSADMDIR}VersionInfo.o
  
  LIBJAFSADM_OBJS =\
  	${LIBJAFSADMDIR}AdminToken.o \
  	${LIBJAFSADMDIR}Cell.o \
  	${LIBJAFSADMDIR}Group.o \
--- 71,117 ----
  	${PACKAGEDIR}Server.class \
  	${PACKAGEDIR}Token.class \
  	${PACKAGEDIR}User.class \
! 	${PACKAGEDIR}Volume.class \
! 	${PACKAGEDIR}VersionInfo.class
  
+ ifeq (${SYS_NAME}, ppc64_linux26)
+ LIBJAFS_OBJS =
+ else
+ ifeq (${SYS_NAME}, s390x_linux26)
+ LIBJAFS_OBJS =
+ else
  LIBJAFS_OBJS =\
!         ${LIBJAFSADMDIR}GetNativeString.o \
!         ${LIBJAFSADMDIR}ACL.o
! endif
! endif
! 
! LIBJAFS_OBJS +=\
  	${LIBJAFSADMDIR}File.o \
  	${LIBJAFSADMDIR}FileInputStream.o \
  	${LIBJAFSADMDIR}FileOutputStream.o \
  	${LIBJAFSADMDIR}Internal.o \
  	${LIBJAFSADMDIR}UserToken.o \
! 	${LIBJAFSADMDIR}VersionInfo.o \
! 	${TOP_SRCDIR}/libuafs/UAFS/AFS_component_version_number.o \
! 	${TOP_SRCDIR}/libuafs/UAFS/xdr_int32.o \
!         ${TOP_SRCDIR}/util/rxkstats.o
  
+ ifeq (${SYS_NAME}, ppc64_linux26)
+ LIBJAFSADM_OBJS =\
+         ${LIBJAFSADMDIR}GetNativeString.o \
+         ${LIBJAFSADMDIR}ACL.o
+ else
+ ifeq (${SYS_NAME}, s390x_linux26)
  LIBJAFSADM_OBJS =\
+         ${LIBJAFSADMDIR}GetNativeString.o \
+         ${LIBJAFSADMDIR}ACL.o
+ else
+ LIBJAFSADM_OBJS =
+ endif
+ endif
+ 
+ LIBJAFSADM_OBJS +=\
  	${LIBJAFSADMDIR}AdminToken.o \
  	${LIBJAFSADMDIR}Cell.o \
  	${LIBJAFSADMDIR}Group.o \
***************
*** 99,105 ****
  	${LIBJAFSADMDIR}Process.o \
  	${LIBJAFSADMDIR}Server.o \
  	${LIBJAFSADMDIR}User.o \
! 	${LIBJAFSADMDIR}VersionInfo.o \
  	${LIBJAFSADMDIR}Volume.o
  
  CORRELATING_SOURCE_FILES =\
--- 121,128 ----
  	${LIBJAFSADMDIR}Process.o \
  	${LIBJAFSADMDIR}Server.o \
  	${LIBJAFSADMDIR}User.o \
! 	${LIBJAFSADMDIR}Version2.o \
! 	${TOP_SRCDIR}/libuafs/UAFS/AFS_component_version_number.o \
  	${LIBJAFSADMDIR}Volume.o
  
  CORRELATING_SOURCE_FILES =\
***************
*** 114,121 ****
  	${LIBJAFSADMDIR}Process.c \
  	${LIBJAFSADMDIR}Server.c \
  	${LIBJAFSADMDIR}User.c \
! 	${LIBJAFSADMDIR}VersionInfo.c \
! 	${LIBJAFSADMDIR}Volume.c
  
  JAVA_HEADERS = ${PACKAGE:${PACKAGEDIR}%.class=${C_NATIVE_PREFIX}%.h}
  
--- 137,145 ----
  	${LIBJAFSADMDIR}Process.c \
  	${LIBJAFSADMDIR}Server.c \
  	${LIBJAFSADMDIR}User.c \
! 	${LIBJAFSADMDIR}Volume.c \
! 	${LIBJAFSADMDIR}VersionInfo.c
! 
  
  JAVA_HEADERS = ${PACKAGE:${PACKAGEDIR}%.class=${C_NATIVE_PREFIX}%.h}
  
***************
*** 151,157 ****
  
  JARFILE = jafs.jar
  
! all:  ${TOP_JLIBDIR} libjafs libjafsadm ${PACKAGE} jar
  
  install:  all ${DESTDIR}${libdir}/libjafs.so ${DESTDIR}${libdir}/libjafsadm.so ${PACKAGE} install_jar
  	if [ ! -e /usr/afswsp ]; then \
--- 175,181 ----
  
  JARFILE = jafs.jar
  
! all:  ${TOP_JLIBDIR} libjafs libjafsadm ${PACKAGE} all_jar
  
  install:  all ${DESTDIR}${libdir}/libjafs.so ${DESTDIR}${libdir}/libjafsadm.so ${PACKAGE} install_jar
  	if [ ! -e /usr/afswsp ]; then \
***************
*** 174,212 ****
  	  ln -s /usr/vice/etc/ThisCell /usr/afswsp/etc/; \
  	fi
  
- ### Clean "C" and Java objects
  clean:
! 	${RM} -f ${PACKAGEDIR}*.class ${LIBJAFSADMDIR}*.o ${LIBJAFSADMDIR}${C_NATIVE_PREFIX}*.h ${LIBJAFSADMDIR}acltest
! 	${RM} -fR ${JAVADOCSDIR}
! 
! ### Clean just "C" objects
! cleanc:
! 	${RM} -f ${LIBJAFSADMDIR}*.o ${LIBJAFSADMDIR}acltest
! 
! increment-build:
! 	${INCREMENT_CMD} \
!         export INCREMENT_BUILD=false;
  
  setup:	FORCE
  
  ${TOP_JLIBDIR}:
  	mkdir -p $@
  
  FORCE: ;
  
- ############# Test program   ###############################
- 
- acltest: ${LIBJAFSADMDIR}/acltest.c
- 	${CC} ${CFLAGS} -o $@ $^ ${LIBJAFS_LIBS}
- 
  ############# Shared library ###############################
  
! libjafs: setup increment-build
  	${RM} -f ${LIBJAFSADMDIR}Internal.o; \
  	export BUILD_TYPE=user; \
  	${MAKE} ${TOP_LIBDIR}/libjafs.so
  
! libjafsadm: increment-build
  	${RM} -f ${LIBJAFSADMDIR}Internal.o; \
  	export BUILD_TYPE=admin; \
  	${MAKE} ${TOP_LIBDIR}/libjafsadm.so
--- 198,224 ----
  	  ln -s /usr/vice/etc/ThisCell /usr/afswsp/etc/; \
  	fi
  
  clean:
! 	${RM} -f ${PACKAGEDIR}*.class ${LIBJAFSADMDIR}*.o ${LIBJAFSADMDIR}${C_NATIVE_PREFIX}*.h
  
  setup:	FORCE
+ 	if [ ! -e ./h ]; then \
+ 	  ln -s /usr/include/sys h; \
+ 	fi; \
  
  ${TOP_JLIBDIR}:
  	mkdir -p $@
  
  FORCE: ;
  
  ############# Shared library ###############################
  
! libjafs: setup
  	${RM} -f ${LIBJAFSADMDIR}Internal.o; \
  	export BUILD_TYPE=user; \
  	${MAKE} ${TOP_LIBDIR}/libjafs.so
  
! libjafsadm:
  	${RM} -f ${LIBJAFSADMDIR}Internal.o; \
  	export BUILD_TYPE=admin; \
  	${MAKE} ${TOP_LIBDIR}/libjafsadm.so
***************
*** 214,220 ****
  ${TOP_LIBDIR}/libjafs.so: ${LIBJAFS_OBJS}
  	${CC} ${CFLAGS} ${SHARED_FLAGS} -o $@ $^ ${LIBJAFS_LIBS}
  
! ${DESTDIR}${libdir}/libjafs.so: ${LIBJAFS_OBJS}
  	${CC} ${CFLAGS} ${SHARED_FLAGS} -o $@ $^ ${LIBJAFS_LIBS}
  
  ${TOP_LIBDIR}/libjafsadm.so: ${LIBJAFSADM_OBJS}
--- 226,232 ----
  ${TOP_LIBDIR}/libjafs.so: ${LIBJAFS_OBJS}
  	${CC} ${CFLAGS} ${SHARED_FLAGS} -o $@ $^ ${LIBJAFS_LIBS}
  
! ${DESTDIR}${libdir}/libjafs.so: ${LIBJAFS_OBJS}192.168.13.10
  	${CC} ${CFLAGS} ${SHARED_FLAGS} -o $@ $^ ${LIBJAFS_LIBS}
  
  ${TOP_LIBDIR}/libjafsadm.so: ${LIBJAFSADM_OBJS}
***************
*** 230,244 ****
  
  ############## C files #####################################
  
! ${CORRELATING_SOURCE_FILES}: ${LIBJAFSADMDIR}%.c: ${LIBJAFSADMDIR}${C_NATIVE_PREFIX}%.h ${LIBJAFSADMDIR}Internal.h ${LIBJAFSADMDIR}VersionInfo.h
  
  ${LIBJAFSADMDIR}AdminToken.c: ${LIBJAFSADMDIR}${C_NATIVE_PREFIX}Token.h ${LIBJAFSADMDIR}${C_NATIVE_PREFIX}Cell.h
  
  ${LIBJAFSADMDIR}Internal.c: ${LIBJAFSADMDIR}Internal.h
  
! ${LIBJAFSADMDIR}UserToken.c: ${LIBJAFSADMDIR}${C_NATIVE_PREFIX}Token.h
  
! ${LIBJAFSADMDIR}VersionInfo.c: ${LIBJAFSADMDIR}VersionInfo.h ${LIBJAFSADMDIR}${C_NATIVE_PREFIX}VersionInfo.h
  
  ############## Package javac section #########################
  
--- 242,256 ----
  
  ############## C files #####################################
  
! ${CORRELATING_SOURCE_FILES}: ${LIBJAFSADMDIR}%.c: ${LIBJAFSADMDIR}${C_NATIVE_PREFIX}%.h ${LIBJAFSADMDIR}Internal.h
  
  ${LIBJAFSADMDIR}AdminToken.c: ${LIBJAFSADMDIR}${C_NATIVE_PREFIX}Token.h ${LIBJAFSADMDIR}${C_NATIVE_PREFIX}Cell.h
  
  ${LIBJAFSADMDIR}Internal.c: ${LIBJAFSADMDIR}Internal.h
  
! ${LIBJAFSADMDIR}Version2.c: ${LIBJAFSADMDIR}${C_NATIVE_PREFIX}VersionInfo.h ${LIBJAFSADMDIR}JAFS_Version.h
  
! ${LIBJAFSADMDIR}UserToken.c: ${LIBJAFSADMDIR}${C_NATIVE_PREFIX}Token.h
  
  ############## Package javac section #########################
  
***************
*** 250,271 ****
  ${JAVA_HEADERS}: ${C_NATIVE_PREFIX}%.h: ${PACKAGEDIR}%.class
  	${JAVAH} ${J_NATIVE_PREFIX}$*
  
- ############## Javadoc section ###############################
- 
- javadocs:
- 	echo "Preparing Javadoc API documentation..."
- 	${JAVADOC} -version -breakiterator \
- 	-link http://java.sun.com/j2se/1.4/docs/api/ \
- 	-windowtitle "Java AFS API" -header "<B>JAFS API v${BUILD_VERSION}</B>" \
- 	-doctitle "<B>JAFS</B> API v${BUILD_VERSION}" \
- 	-use -d ${JAVADOCSDIR} \
- 	-sourcepath ${ROOTPACKAGEDIR} \
- 	-classpath ${ROOTPACKAGEDIR} \
- 	-package org.openafs.jafs
- 
  ############# JAR file #####################################
  
! jar: clean_jar
  	cd ${ROOTPACKAGEDIR}; ${JAVA_HOME}/bin/jar -cMf ${TOP_JLIBDIR}/${JARFILE} *.properties ${RELPACKAGEDIR}*.class
  
  install_jar: clean_jar
--- 262,270 ----
  ${JAVA_HEADERS}: ${C_NATIVE_PREFIX}%.h: ${PACKAGEDIR}%.class
  	${JAVAH} ${J_NATIVE_PREFIX}$*
  
  ############# JAR file #####################################
  
! all_jar: clean_jar
  	cd ${ROOTPACKAGEDIR}; ${JAVA_HOME}/bin/jar -cMf ${TOP_JLIBDIR}/${JARFILE} *.properties ${RELPACKAGEDIR}*.class
  
  install_jar: clean_jar
***************
*** 274,279 ****
  clean_jar:
  	${RM} -f ${TOP_JLIBDIR}/${JARFILE}
  
! clean_libs:
! 	${RM} -f ${TOP_LIBDIR}/libjafs.so ${TOP_LIBDIR}/libjafsadm.so
  
--- 273,277 ----
  clean_jar:
  	${RM} -f ${TOP_JLIBDIR}/${JARFILE}
  
! 
  
Index: openafs/src/JAVA/libjafs/Partition.c
diff -c openafs/src/JAVA/libjafs/Partition.c:1.3 openafs/src/JAVA/libjafs/Partition.c:1.3.2.1
*** openafs/src/JAVA/libjafs/Partition.c:1.3	Tue Jul 15 19:11:26 2003
--- openafs/src/JAVA/libjafs/Partition.c	Fri Oct 14 22:14:12 2005
***************
*** 40,49 ****
  
  //////////////////////////////////////////////////////////
  
! ///// Definition in jafs_Volume.c /////////////////
  
! extern void fillVolumeInfo(JNIEnv * env, jobject volume,
! 			   vos_volumeEntry_t volEntry);
  
  ///////////////////////////////////////////////////
  
--- 40,49 ----
  
  //////////////////////////////////////////////////////////
  
! ///// definition in jafs_Volume.c /////////////////
  
! extern void fillVolumeInfo
!             ( JNIEnv *env, jobject volume, vos_volumeEntry_t volEntry );
  
  ///////////////////////////////////////////////////
  
***************
*** 56,95 ****
   * partition      the Partition object to populate with the info
   * partEntry     the container of the partition's information
   */
! void
! fillPartitionInfo(JNIEnv * env, jobject partition,
! 		  vos_partitionEntry_t partEntry)
! {
!     jstring jdeviceName;
!     jstring jpartition;
!     jint id;
!     afs_status_t ast;
! 
!     // get the class fields if need be
!     if (partitionCls == 0) {
! 	internal_getPartitionClass(env, partition);
!     }
!     // fill name and id in case it's a blank object
!     jpartition = (*env)->NewStringUTF(env, partEntry.name);
!     // get the id
!     if (!vos_PartitionNameToId(partEntry.name, (int *)&id, &ast)) {
! 	throwAFSException(env, ast);
! 	return;
!     }
!     (*env)->SetObjectField(env, partition, partition_nameField, jpartition);
!     (*env)->SetIntField(env, partition, partition_idField, id);
! 
!     jdeviceName = (*env)->NewStringUTF(env, partEntry.deviceName);
!     (*env)->SetObjectField(env, partition, partition_deviceNameField,
! 			   jdeviceName);
! 
!     (*env)->SetIntField(env, partition, partition_lockFileDescriptorField,
! 			partEntry.lockFileDescriptor);
!     (*env)->SetIntField(env, partition, partition_totalSpaceField,
! 			partEntry.totalSpace);
!     (*env)->SetIntField(env, partition, partition_totalFreeSpaceField,
! 			partEntry.totalFreeSpace);
! 
  }
  
  /**
--- 56,95 ----
   * partition      the Partition object to populate with the info
   * partEntry     the container of the partition's information
   */
! void fillPartitionInfo
!   (JNIEnv *env, jobject partition, vos_partitionEntry_t partEntry)
! {
!   jstring jdeviceName;
!   jstring jpartition;
!   jint id;
!   afs_status_t ast;
! 
!   // get the class fields if need be
!   if( partitionCls == 0 ) {
!     internal_getPartitionClass( env, partition );
!   }
! 
!   // fill name and id in case it's a blank object
!   jpartition = (*env)->NewStringUTF(env, partEntry.name);
!   // get the id
!   if( !vos_PartitionNameToId( partEntry.name, (int *) &id, &ast ) ) {
!       throwAFSException( env, ast );
!       return;
!   } 
!   (*env)->SetObjectField(env, partition, partition_nameField, jpartition);
!   (*env)->SetIntField(env, partition, partition_idField, id);
! 
!   jdeviceName = (*env)->NewStringUTF(env, partEntry.deviceName);
!   (*env)->SetObjectField(env, partition, partition_deviceNameField, 
! 			 jdeviceName);
! 
!   (*env)->SetIntField(env, partition, partition_lockFileDescriptorField, 
! 		      partEntry.lockFileDescriptor);
!   (*env)->SetIntField(env, partition, partition_totalSpaceField, 
! 		      partEntry.totalSpace);
!   (*env)->SetIntField(env, partition, partition_totalFreeSpaceField, 
! 		      partEntry.totalFreeSpace);
!   
  }
  
  /**
***************
*** 105,129 ****
   * jpartitionObject   the Partition object in which to 
   *                    fill in the information
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Partition_getPartitionInfo(JNIEnv * env, jclass cls,
! 						 jint cellHandle,
! 						 jint serverHandle,
! 						 jint partition,
! 						 jobject jpartitionObject)
! {
!     afs_status_t ast;
!     vos_partitionEntry_t partEntry;
! 
!     // get the partition entry
!     if (!vos_PartitionGet
! 	((void *)cellHandle, (void *)serverHandle, NULL,
! 	 (unsigned int)partition, &partEntry, &ast)) {
! 	throwAFSException(env, ast);
! 	return;
!     }
  
!     fillPartitionInfo(env, jpartitionObject, partEntry);
  
  }
  
--- 105,126 ----
   * jpartitionObject   the Partition object in which to 
   *                    fill in the information
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Partition_getPartitionInfo
!   (JNIEnv *env, jclass cls, jlong cellHandle, jlong serverHandle, 
!    jint partition, jobject jpartitionObject)
! {
!   afs_status_t ast;
!   vos_partitionEntry_t partEntry;
! 
!   // get the partition entry
!   if ( !vos_PartitionGet( (void *) cellHandle, (void *) serverHandle, NULL, 
! 			  (unsigned int) partition, &partEntry, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
!   fillPartitionInfo( env, jpartitionObject, partEntry );
  
  }
  
***************
*** 135,168 ****
   * jname  the name of the partition in question
   * returns   the id of the partition in question
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Partition_translateNameToID(JNIEnv * env, jclass cls,
! 						  jstring jname)
! {
!     afs_status_t ast;
!     jint id;
!     char *name;
! 
!     if (jname != NULL) {
! 	name = getNativeString(env, jname);
! 	if (name == NULL) {
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return -1;
! 	}
!     } else {
! 	throwAFSException(env, JAFSNULLPART);
! 	return -1;
!     }
! 
!     // get the id
!     if (!vos_PartitionNameToId(name, (unsigned int *)&id, &ast)) {
! 	id = -1;
! 	throwAFSException(env, ast);
!     }
  
!     free(name);
  
-     return id;
  }
  
  /**
--- 132,170 ----
   * jname  the name of the partition in question
   * returns   the id of the partition in question
   */
! JNIEXPORT jint JNICALL 
! Java_org_openafs_jafs_Partition_translateNameToID
!   (JNIEnv *env, jclass cls, jstring jname)
! {
!   afs_status_t ast;
!   jint id;
!   const char *name;
! 
!   if( jname != NULL ) {
!     name = (*env)->GetStringUTFChars(env, jname, 0);
!     if( !name ) {
! 	throwAFSException( env, JAFSADMNOMEM );
! 	return;    
!     }
!   } else {
!     name = NULL;
!   }
! 
!   // get the id
!   if( !vos_PartitionNameToId( name, (unsigned int *) &id, &ast ) ) {
!     if( name != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jname, name);
!     }
!     throwAFSException( env, ast );
!     return -1;
!   } 
! 
!   if( name != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, jname, name);
!   }
  
!   return id;
  
  }
  
  /**
***************
*** 173,199 ****
   * id  the id of the partition in question
   * returns   the name of the partition in question
   */
! JNIEXPORT jstring JNICALL
! Java_org_openafs_jafs_Partition_translateIDToName(JNIEnv * env, jclass cls,
! 						  jint id)
! {
!     afs_status_t ast;
!     char *name = (char *)malloc(sizeof(char) * VOS_MAX_PARTITION_NAME_LEN);
!     jstring jname = NULL;
! 
!     if (name == NULL) {
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return NULL;
!     }
!     // get the name
!     if (vos_PartitionIdToName((unsigned int)id, name, &ast)) {
! 	jname = (*env)->NewStringUTF(env, name);
!     } else {
! 	throwAFSException(env, ast);
!     }
      free(name);
  
-     return jname;
  }
  
  /**
--- 175,204 ----
   * id  the id of the partition in question
   * returns   the name of the partition in question
   */
! JNIEXPORT jstring JNICALL 
! Java_org_openafs_jafs_Partition_translateIDToName
!  (JNIEnv *env, jclass cls, jint id)
! {
!   afs_status_t ast;
!   char *name = (char *) malloc( sizeof(char)*VOS_MAX_PARTITION_NAME_LEN);
!   jstring jname;
! 
!   if( !name ) {
!     throwAFSException( env, JAFSADMNOMEM );
!     return NULL;    
!   }
! 
!   // get the name
!   if( !vos_PartitionIdToName( (unsigned int) id, name, &ast ) ) {
      free(name);
+     throwAFSException( env, ast );
+     return NULL;
+   } 
+ 
+   jname = (*env)->NewStringUTF(env, name);
+   free(name);
+   return jname;
  
  }
  
  /**
***************
*** 208,240 ****
   *                    reside
   * returns total number of volumes hosted by this partition
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Partition_getVolumeCount(JNIEnv * env, jclass cls,
! 					       jint cellHandle,
! 					       jint serverHandle,
! 					       jint partition)
! {
!     afs_status_t ast;
!     void *iterationId;
!     vos_volumeEntry_t volEntry;
!     int i = 0;
! 
!     if (!vos_VolumeGetBegin
! 	((void *)cellHandle, (void *)serverHandle, NULL,
! 	 (unsigned int)partition, &iterationId, &ast)) {
! 	throwAFSException(env, ast);
! 	return -1;
!     }
  
!     while (vos_VolumeGetNext((void *)iterationId, &volEntry, &ast))
! 	i++;
! 
!     if (ast != ADMITERATORDONE) {
! 	throwAFSException(env, ast);
! 	return -1;
!     }
! 
!     return i;
  }
  
  /**
--- 213,241 ----
   *                    reside
   * returns total number of volumes hosted by this partition
   */
! JNIEXPORT jint JNICALL 
! Java_org_openafs_jafs_Partition_getVolumeCount
!  (JNIEnv *env, jclass cls, jlong cellHandle, jlong serverHandle, jint partition)
! {
!   afs_status_t ast;
!   void *iterationId;
!   vos_volumeEntry_t volEntry;
!   int i = 0;
! 
!   if( !vos_VolumeGetBegin( (void *) cellHandle, (void *) serverHandle, NULL, 
! 			   (unsigned int) partition, &iterationId, &ast ) ) {
!     throwAFSException( env, ast );
!     return -1;
!   }
! 
!   while ( vos_VolumeGetNext( (void *) iterationId, &volEntry, &ast ) ) i++;
! 
!   if( ast != ADMITERATORDONE ) {
!     throwAFSException( env, ast );
!     return -1;
!   }
  
!   return i;
  }
  
  /**
***************
*** 251,274 ****
   *                    reside
   * returns an iteration ID
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Partition_getVolumesBegin(JNIEnv * env, jclass cls,
! 						jint cellHandle,
! 						jint serverHandle,
! 						jint partition)
  {
  
!     afs_status_t ast;
!     void *iterationId;
! 
!     if (!vos_VolumeGetBegin
! 	((void *)cellHandle, (void *)serverHandle, NULL,
! 	 (unsigned int)partition, &iterationId, &ast)) {
! 	throwAFSException(env, ast);
! 	return -1;
!     }
  
!     return (jint) iterationId;
  }
  
  /**
--- 252,272 ----
   *                    reside
   * returns an iteration ID
   */
! JNIEXPORT jlong JNICALL 
! Java_org_openafs_jafs_Partition_getVolumesBegin
!  (JNIEnv *env, jclass cls, jlong cellHandle, jlong serverHandle, jint partition)
  {
  
!   afs_status_t ast;
!   void *iterationId;
! 
!   if( !vos_VolumeGetBegin( (void *) cellHandle, (void *) serverHandle, NULL, 
! 			   (unsigned int) partition, &iterationId, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
!   return (jlong) iterationId;
  }
  
  /**
***************
*** 285,321 ****
   *                    reside
   * returns an iteration ID
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Partition_getVolumesBeginAt(JNIEnv * env, jclass cls,
! 						  jint cellHandle,
! 						  jint serverHandle,
! 						  jint partition, jint index)
! {
! 
!     afs_status_t ast;
!     void *iterationId;
!     vos_volumeEntry_t volEntry;
!     int i;
! 
!     if (!vos_VolumeGetBegin
! 	((void *)cellHandle, (void *)serverHandle, NULL,
! 	 (unsigned int)partition, &iterationId, &ast)) {
! 	throwAFSException(env, ast);
! 	return -1;
      }
  
!     for (i = 1; i < index; i++) {
! 	if (!vos_VolumeGetNext((void *)iterationId, &volEntry, &ast)) {
! 	    if (ast == ADMITERATORDONE) {
! 		return 0;
! 	    } else {
! 		throwAFSException(env, ast);
! 		return 0;
! 	    }
! 	}
!     }
! 
!     return (jint) iterationId;
  
  }
  
--- 283,317 ----
   *                    reside
   * returns an iteration ID
   */
! JNIEXPORT jlong JNICALL 
! Java_org_openafs_jafs_Partition_getVolumesBeginAt
!   (JNIEnv *env, jclass cls, jlong cellHandle, jlong serverHandle,
!    jint partition, jint index)
! {
! 
!   afs_status_t ast;
!   void *iterationId;
!   vos_volumeEntry_t volEntry;
!   int i;
! 
!   if( !vos_VolumeGetBegin( (void *) cellHandle, (void *) serverHandle, NULL, 
! 			   (unsigned int) partition, &iterationId, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
! 
!   for ( i = 1; i < index; i++) {
!     if( !vos_VolumeGetNext( (void *) iterationId, &volEntry, &ast ) ) {
!       if( ast == ADMITERATORDONE ) {
!         return 0;
!       } else {
!         throwAFSException( env, ast );
!         return 0;
!       }
      }
+   }
  
!   return (jlong) iterationId;
  
  }
  
***************
*** 328,352 ****
   * iterationId   the iteration ID of this iteration
   * returns the name of the next volume of the server
   */
! JNIEXPORT jstring JNICALL
! Java_org_openafs_jafs_Partition_getVolumesNextString(JNIEnv * env, jclass cls,
! 						     jint iterationId)
! {
!     afs_status_t ast;
!     jstring jvolume;
!     vos_volumeEntry_t volEntry;
! 
!     if (!vos_VolumeGetNext((void *)iterationId, &volEntry, &ast)) {
! 	if (ast == ADMITERATORDONE) {
! 	    return NULL;
! 	} else {
! 	    throwAFSException(env, ast);
! 	    return NULL;
! 	}
      }
  
!     jvolume = (*env)->NewStringUTF(env, volEntry.name);
!     return jvolume;
  
  }
  
--- 324,348 ----
   * iterationId   the iteration ID of this iteration
   * returns the name of the next volume of the server
   */
! JNIEXPORT jstring JNICALL 
! Java_org_openafs_jafs_Partition_getVolumesNextString
!   (JNIEnv *env, jclass cls, jlong iterationId)
! {
!   afs_status_t ast;
!   jstring jvolume;
!   vos_volumeEntry_t volEntry;
! 
!   if( !vos_VolumeGetNext( (void *) iterationId, &volEntry, &ast ) ) {
!     if( ast == ADMITERATORDONE ) {
!       return NULL;
!     } else {
!       throwAFSException( env, ast );
!       return;
      }
+   }
  
!   jvolume = (*env)->NewStringUTF(env, volEntry.name);
!   return jvolume;
  
  }
  
***************
*** 361,394 ****
   *                         of the next volume
   * returns 0 if there are no more volumes, != 0 otherwise
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Partition_getVolumesNext(JNIEnv * env, jclass cls,
! 					       jint iterationId,
! 					       jobject jvolumeObject)
! {
!     afs_status_t ast;
!     jstring jvolume;
!     vos_volumeEntry_t volEntry;
! 
!     if (!vos_VolumeGetNext((void *)iterationId, &volEntry, &ast)) {
! 	if (ast == ADMITERATORDONE) {
! 	    return 0;
! 	} else {
! 	    throwAFSException(env, ast);
! 	    return 0;
! 	}
      }
  
  
!     fillVolumeInfo(env, jvolumeObject, volEntry);
  
!     // get the class fields if need be
!     if (volumeCls == 0) {
! 	internal_getVolumeClass(env, jvolumeObject);
!     }
!     (*env)->SetBooleanField(env, jvolumeObject, volume_cachedInfoField, TRUE);
! 
!     return 1;
  
  }
  
--- 357,389 ----
   *                         of the next volume
   * returns 0 if there are no more volumes, != 0 otherwise
   */
! JNIEXPORT jint JNICALL 
! Java_org_openafs_jafs_Partition_getVolumesNext
!   (JNIEnv *env, jclass cls, jlong iterationId, jobject jvolumeObject)
! {
!   afs_status_t ast;
!   jstring jvolume;
!   vos_volumeEntry_t volEntry;
! 
!   if( !vos_VolumeGetNext( (void *) iterationId, &volEntry, &ast ) ) {
!     if( ast == ADMITERATORDONE ) {
!       return 0;
!     } else {
!       throwAFSException( env, ast );
!       return 0;
      }
+   }
  
  
!   fillVolumeInfo( env, jvolumeObject, volEntry );
  
!   // get the class fields if need be
!   if( volumeCls == 0 ) {
!     internal_getVolumeClass( env, jvolumeObject );
!   }
!   (*env)->SetBooleanField( env, jvolumeObject, volume_cachedInfoField, TRUE );
!     
!   return 1;
  
  }
  
***************
*** 404,441 ****
   * advanceCount     the number of volumes to advance past
   * returns 0 if there are no more volumes, != 0 otherwise
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Partition_getVolumesAdvanceTo(JNIEnv * env, jclass cls,
! 						    jint iterationId,
! 						    jobject jvolumeObject,
! 						    jint advanceCount)
! {
!     afs_status_t ast;
!     jstring jvolume;
!     vos_volumeEntry_t volEntry;
!     int i;
! 
!     for (i = 0; i < advanceCount; i++) {
! 	if (!vos_VolumeGetNext((void *)iterationId, &volEntry, &ast)) {
! 	    if (ast == ADMITERATORDONE) {
! 		return 0;
! 	    } else {
! 		throwAFSException(env, ast);
! 		return 0;
! 	    }
! 	}
!     }
! 
! 
!     fillVolumeInfo(env, jvolumeObject, volEntry);
! 
!     // get the class fields if need be
!     if (volumeCls == 0) {
! 	internal_getVolumeClass(env, jvolumeObject);
!     }
!     (*env)->SetBooleanField(env, jvolumeObject, volume_cachedInfoField, TRUE);
! 
!     return 1;
  }
  
  /**
--- 399,435 ----
   * advanceCount     the number of volumes to advance past
   * returns 0 if there are no more volumes, != 0 otherwise
   */
! JNIEXPORT jint JNICALL 
! Java_org_openafs_jafs_Partition_getVolumesAdvanceTo
!   (JNIEnv *env, jclass cls, jlong iterationId, jobject jvolumeObject,
!    jint advanceCount)
! {
!   afs_status_t ast;
!   jstring jvolume;
!   vos_volumeEntry_t volEntry;
!   int i;
! 
!   for ( i = 0; i < advanceCount; i++) {
!     if( !vos_VolumeGetNext( (void *) iterationId, &volEntry, &ast ) ) {
!       if( ast == ADMITERATORDONE ) {
!         return 0;
!       } else {
!         throwAFSException( env, ast );
!         return 0;
!       }
!     }
!   }
! 
! 
!   fillVolumeInfo( env, jvolumeObject, volEntry );
! 
!   // get the class fields if need be
!   if( volumeCls == 0 ) {
!     internal_getVolumeClass( env, jvolumeObject );
!   }
!   (*env)->SetBooleanField( env, jvolumeObject, volume_cachedInfoField, TRUE );
!     
!   return 1;
  }
  
  /**
***************
*** 445,469 ****
   * cls      the current Java class
   * iterationId   the iteration ID of this iteration
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Partition_getVolumesDone(JNIEnv * env, jclass cls,
! 					       jint iterationId)
! {
!     afs_status_t ast;
! 
!     if (!vos_VolumeGetDone((void *)iterationId, &ast)) {
! 	throwAFSException(env, ast);
! 	return;
!     }
  }
  
  // reclaim global memory being used by this portion
  JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Partition_reclaimPartitionMemory(JNIEnv * env,
! 						       jclass cls)
  {
!     if (partitionCls) {
! 	(*env)->DeleteGlobalRef(env, partitionCls);
! 	partitionCls = 0;
!     }
  }
--- 439,482 ----
   * cls      the current Java class
   * iterationId   the iteration ID of this iteration
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Partition_getVolumesDone
!   (JNIEnv *env, jclass cls, jlong iterationId)
! {
!   afs_status_t ast;
! 
!   if( !vos_VolumeGetDone( (void *) iterationId, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  }
  
  // reclaim global memory being used by this portion
  JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Partition_reclaimPartitionMemory
!  (JNIEnv *env, jclass cls)
  {
!   if( partitionCls ) {
!       (*env)->DeleteGlobalRef(env, partitionCls);
!       partitionCls = 0;
!   }
  }
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
Index: openafs/src/JAVA/libjafs/Process.c
diff -c openafs/src/JAVA/libjafs/Process.c:1.3 openafs/src/JAVA/libjafs/Process.c:1.3.2.1
*** openafs/src/JAVA/libjafs/Process.c:1.3	Tue Jul 15 19:11:26 2003
--- openafs/src/JAVA/libjafs/Process.c	Fri Oct 14 22:14:12 2005
***************
*** 52,193 ****
   * processName      the name of the process for which to get the info
   * process      the Process object to populate with the info
   */
! void
! getProcessInfoChar(JNIEnv * env, void *serverHandle, const char *processName,
! 		   jobject process)
! {
!     afs_status_t ast;
!     bos_ProcessType_t type;
!     bos_ProcessInfo_t infoEntry;
!     bos_ProcessExecutionState_t state;
!     char *auxStatus;
! 
!     // get class fields if need be
!     if (processCls == 0) {
! 	internal_getProcessClass(env, process);
!     }
! 
!     if (!bos_ProcessInfoGet
! 	(serverHandle, processName, &type, &infoEntry, &ast)) {
! 	throwAFSException(env, ast);
! 	return;
!     }
!     // set type variable
!     switch (type) {
!     case BOS_PROCESS_SIMPLE:
! 	(*env)->SetIntField(env, process, process_typeField,
! 			    org_openafs_jafs_Process_SIMPLE_PROCESS);
! 	break;
!     case BOS_PROCESS_FS:
! 	(*env)->SetIntField(env, process, process_typeField,
! 			    org_openafs_jafs_Process_FS_PROCESS);
! 	break;
!     case BOS_PROCESS_CRON:
! 	(*env)->SetIntField(env, process, process_typeField,
! 			    org_openafs_jafs_Process_CRON_PROCESS);
! 	break;
!     default:
! 	throwAFSException(env, type);
! 	return;
!     }
! 
!     // set goal variable
!     switch (infoEntry.processGoal) {
!     case BOS_PROCESS_STOPPED:
! 	(*env)->SetIntField(env, process, process_goalField,
! 			    org_openafs_jafs_Process_STOPPED);
! 	break;
!     case BOS_PROCESS_RUNNING:
! 	(*env)->SetIntField(env, process, process_goalField,
! 			    org_openafs_jafs_Process_RUNNING);
! 	break;
!     case BOS_PROCESS_STOPPING:
! 	(*env)->SetIntField(env, process, process_goalField,
! 			    org_openafs_jafs_Process_STOPPING);
! 	break;
!     case BOS_PROCESS_STARTING:
! 	(*env)->SetIntField(env, process, process_goalField,
! 			    org_openafs_jafs_Process_STARTING);
! 	break;
!     default:
! 	throwAFSException(env, infoEntry.processGoal);
! 	return;
!     }
! 
!     // set state variable
!     auxStatus = (char *)malloc(sizeof(char) * BOS_MAX_NAME_LEN);
!     if (!auxStatus) {
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return;
!     }
!     if (!bos_ProcessExecutionStateGet
! 	((void *)serverHandle, processName, &state, auxStatus, &ast)) {
! 	free(auxStatus);
! 	throwAFSException(env, ast);
! 	return;
!     }
!     free(auxStatus);
! 
!     switch (state) {
!     case BOS_PROCESS_STOPPED:
! 	(*env)->SetIntField(env, process, process_stateField,
! 			    org_openafs_jafs_Process_STOPPED);
! 	break;
!     case BOS_PROCESS_RUNNING:
! 	(*env)->SetIntField(env, process, process_stateField,
! 			    org_openafs_jafs_Process_RUNNING);
! 	break;
!     case BOS_PROCESS_STOPPING:
! 	(*env)->SetIntField(env, process, process_stateField,
! 			    org_openafs_jafs_Process_STOPPING);
! 	break;
!     case BOS_PROCESS_STARTING:
! 	(*env)->SetIntField(env, process, process_stateField,
! 			    org_openafs_jafs_Process_STARTING);
! 	break;
!     default:
! 	throwAFSException(env, state);
! 	return;
!     }
! 
!     // set longs
!     (*env)->SetLongField(env, process, process_startTimeField,
! 			 infoEntry.processStartTime);
!     (*env)->SetLongField(env, process, process_numberStartsField,
! 			 infoEntry.numberProcessStarts);
!     (*env)->SetLongField(env, process, process_exitTimeField,
! 			 infoEntry.processExitTime);
!     (*env)->SetLongField(env, process, process_exitErrorTimeField,
! 			 infoEntry.processExitErrorTime);
!     (*env)->SetLongField(env, process, process_errorCodeField,
! 			 infoEntry.processErrorCode);
!     (*env)->SetLongField(env, process, process_errorSignalField,
! 			 infoEntry.processErrorSignal);
! 
!     // set stateOk to true if no core dump
!     if (infoEntry.state & BOS_PROCESS_CORE_DUMPED) {
! 	(*env)->SetBooleanField(env, process, process_stateOkField, FALSE);
!     } else {
! 	(*env)->SetBooleanField(env, process, process_stateOkField, TRUE);
!     }
! 
!     // set stateTooManyErrors
!     if (infoEntry.state & BOS_PROCESS_TOO_MANY_ERRORS) {
! 	(*env)->SetBooleanField(env, process, process_stateTooManyErrorsField,
! 				TRUE);
!     } else {
! 	(*env)->SetBooleanField(env, process, process_stateTooManyErrorsField,
! 				FALSE);
!     }
  
!     // set stateBadFileAccess
!     if (infoEntry.state & BOS_PROCESS_BAD_FILE_ACCESS) {
! 	(*env)->SetBooleanField(env, process, process_stateBadFileAccessField,
! 				TRUE);
!     } else {
! 	(*env)->SetBooleanField(env, process, process_stateBadFileAccessField,
! 				FALSE);
!     }
  
  }
  
--- 52,192 ----
   * processName      the name of the process for which to get the info
   * process      the Process object to populate with the info
   */
! void getProcessInfoChar( JNIEnv *env, void *serverHandle, 
! 			 const char *processName, jobject process ) {
  
!   afs_status_t ast;
!   bos_ProcessType_t type;
!   bos_ProcessInfo_t infoEntry;
!   bos_ProcessExecutionState_t state;
!   char *auxStatus;
! 
!   // get class fields if need be
!   if( processCls == 0 ) {
!     internal_getProcessClass( env, process );
!   }
! 
!   if( !bos_ProcessInfoGet( serverHandle, processName, &type, 
! 			   &infoEntry, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
! 
!   // set type variable
!   switch( type ) {
!   case BOS_PROCESS_SIMPLE :
!       (*env)->SetIntField(env, process, process_typeField, 
! 			  org_openafs_jafs_Process_SIMPLE_PROCESS);
!       break;
!   case BOS_PROCESS_FS :
!       (*env)->SetIntField(env, process, process_typeField, 
! 			  org_openafs_jafs_Process_FS_PROCESS);
!       break;
!   case BOS_PROCESS_CRON :
!       (*env)->SetIntField(env, process, process_typeField, 
! 			  org_openafs_jafs_Process_CRON_PROCESS);
!       break;
!   default:
!       throwAFSException( env, type );
!       return;
!   }
! 
!   // set goal variable
!   switch( infoEntry.processGoal ) {
!   case BOS_PROCESS_STOPPED :
!       (*env)->SetIntField(env, process, process_goalField, 
! 			  org_openafs_jafs_Process_STOPPED);
!       break;
!   case BOS_PROCESS_RUNNING :
!       (*env)->SetIntField(env, process, process_goalField, 
! 			  org_openafs_jafs_Process_RUNNING);
!       break;
!   case BOS_PROCESS_STOPPING :
!       (*env)->SetIntField(env, process, process_goalField, 
! 			  org_openafs_jafs_Process_STOPPING);
!       break;
!   case BOS_PROCESS_STARTING :
!       (*env)->SetIntField(env, process, process_goalField, 
! 			  org_openafs_jafs_Process_STARTING);
!       break;
!   default:
!       throwAFSException( env, infoEntry.processGoal );
!       return;
!   }
! 
!   // set state variable
!   auxStatus = (char *) malloc( sizeof(char)*BOS_MAX_NAME_LEN );
!   if( !auxStatus ) {
!     throwAFSException( env, JAFSADMNOMEM );
!     return;    
!   }
!   if( !bos_ProcessExecutionStateGet( (void *) serverHandle, processName, 
! 				     &state, auxStatus, &ast ) ) {
!       free( auxStatus );
!       throwAFSException( env, ast );
!       return;
!   }
!   free( auxStatus );
!   switch( state ) {
!   case BOS_PROCESS_STOPPED :
!       (*env)->SetIntField(env, process, process_stateField, 
! 			  org_openafs_jafs_Process_STOPPED);
!       break;
!   case BOS_PROCESS_RUNNING :
!       (*env)->SetIntField(env, process, process_stateField, 
! 			  org_openafs_jafs_Process_RUNNING);
!       break;
!   case BOS_PROCESS_STOPPING :
!       (*env)->SetIntField(env, process, process_stateField, 
! 			  org_openafs_jafs_Process_STOPPING);
!       break;
!   case BOS_PROCESS_STARTING :
!       (*env)->SetIntField(env, process, process_stateField, 
! 			  org_openafs_jafs_Process_STARTING);
!       break;
!   default:
!       throwAFSException( env, state );
!       return;
!   }
! 
!   // set longs
!   (*env)->SetLongField(env, process, process_startTimeField, 
! 		       infoEntry.processStartTime );
!   (*env)->SetLongField(env, process, process_numberStartsField, 
! 		       infoEntry.numberProcessStarts );
!   (*env)->SetLongField(env, process, process_exitTimeField, 
! 		       infoEntry.processExitTime );
!   (*env)->SetLongField(env, process, process_exitErrorTimeField, 
! 		       infoEntry.processExitErrorTime );
!   (*env)->SetLongField(env, process, process_errorCodeField, 
! 		       infoEntry.processErrorCode );
!   (*env)->SetLongField(env, process, process_errorSignalField, 
! 		       infoEntry.processErrorSignal );
! 
!   // set stateOk to true if no core dump
!   if( infoEntry.state & BOS_PROCESS_CORE_DUMPED ) {
!     (*env)->SetBooleanField(env, process, process_stateOkField, FALSE );
!   } else {
!     (*env)->SetBooleanField(env, process, process_stateOkField, TRUE );
!   }
! 
!   // set stateTooManyErrors
!   if( infoEntry.state & BOS_PROCESS_TOO_MANY_ERRORS ) {
!     (*env)->SetBooleanField(env, process, 
! 			    process_stateTooManyErrorsField, TRUE );
!   } else {
!     (*env)->SetBooleanField(env, process, 
! 			    process_stateTooManyErrorsField, FALSE );
!   }
! 
!   // set stateBadFileAccess
!   if( infoEntry.state & BOS_PROCESS_BAD_FILE_ACCESS ) {
!     (*env)->SetBooleanField(env, process, 
! 			    process_stateBadFileAccessField, TRUE );
!   } else {
!     (*env)->SetBooleanField(env, process, 
! 			    process_stateBadFileAccessField, FALSE );
!   }
  
  }
  
***************
*** 202,233 ****
   * process     the Process object in which to fill 
   *                    in the information
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Process_getProcessInfo(JNIEnv * env, jclass cls,
! 					     jint serverHandle, jstring jname,
! 					     jobject process)
! {
!     char *name;
! 
!     if (jname != NULL) {
! 	name = getNativeString(env, jname);
! 	if (name == NULL) {
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	throwAFSException(env, JAFSNULLPROCESS);
! 	return;
!     }
! 
!     getProcessInfoChar(env, (void *)serverHandle, name, process);
! 
!     // set name in case blank object
!     if (processCls == NULL) {
! 	internal_getProcessClass(env, process);
      }
      (*env)->SetObjectField(env, process, process_nameField, jname);
!     free(name);
  }
  
  /**
--- 201,235 ----
   * process     the Process object in which to fill 
   *                    in the information
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Process_getProcessInfo (JNIEnv *env, jclass cls, 
! 						 jlong serverHandle, 
! 						 jstring jname, 
! 						 jobject process) {
! 
!   const char *name;
! 
!   if( jname != NULL ) {
!     name = (*env)->GetStringUTFChars(env, jname, 0);
!     if( !name ) {
! 	throwAFSException( env, JAFSADMNOMEM );
! 	return;    
!     }
!   } else {
!     name = NULL;
!   }
! 
!   getProcessInfoChar( env, (void *) serverHandle, name, process );
! 
!   // set name in case blank object
!   if( name != NULL ) {
!     if( processCls == 0 ) {
!       internal_getProcessClass( env, process );
      }
      (*env)->SetObjectField(env, process, process_nameField, jname);
!     (*env)->ReleaseStringUTFChars(env, jname, name);
!   }
! 
  }
  
  /**
***************
*** 255,296 ****
   *                   be called when the process terminates.  Can be 
   *                   null
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Process_create(JNIEnv * env, jclass cls,
! 				     jint serverHandle, jstring jname,
! 				     jint jtype, jstring jpath,
! 				     jstring jcronTime, jstring jnotifier)
! {
      afs_status_t ast;
      bos_ProcessType_t type;
!     char *name;
!     char *path;
!     char *cronTime;
!     char *notifier;
! 
!     if (jname != NULL) {
! 	name = getNativeString(env, jname);
! 	if (name == NULL) {
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	throwAFSException(env, JAFSNULLPROCESS);
! 	return;
!     }
! 
!     if (jpath != NULL) {
! 	path = getNativeString(env, jpath);
! 	if (path == NULL) {
! 	    free(name);
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
  	}
      } else {
! 	path = NULL;
      }
  
!     switch (jtype) {
      case org_openafs_jafs_Process_SIMPLE_PROCESS:
  	type = BOS_PROCESS_SIMPLE;
  	break;
--- 257,300 ----
   *                   be called when the process terminates.  Can be 
   *                   null
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Process_create (JNIEnv *env, jclass cls, 
! 					 jlong serverHandle, jstring jname, 
! 					 jint jtype, jstring jpath, 
! 					 jstring jcronTime, 
! 					 jstring jnotifier) {
! 
      afs_status_t ast;
      bos_ProcessType_t type;
!     const char *name;
!     const char *path;
!     const char *cronTime;
!     const char *notifier;
! 
!     if( jname != NULL ) {
!       name = (*env)->GetStringUTFChars(env, jname, 0);
!       if( !name ) {
! 	  throwAFSException( env, JAFSADMNOMEM );
! 	  return;    
!       }
!     } else {
!       name = NULL;
!     }
! 
!     if( jpath != NULL ) {
!       path = (*env)->GetStringUTFChars(env, jpath, 0);
!       if( !path ) {
! 	if( name != NULL ) {
! 	  (*env)->ReleaseStringUTFChars(env, jname, name);
  	}
+ 	throwAFSException( env, JAFSADMNOMEM );
+ 	return;    
+       }
      } else {
!       path = NULL;
      }
  
!     switch( jtype ) {
      case org_openafs_jafs_Process_SIMPLE_PROCESS:
  	type = BOS_PROCESS_SIMPLE;
  	break;
***************
*** 301,353 ****
  	type = BOS_PROCESS_CRON;
  	break;
      default:
! 	free(name);
! 	if (path != NULL)
! 	    free(path);
! 	throwAFSException(env, jtype);
! 	return;
!     }
! 
!     if (jcronTime != NULL) {
! 	cronTime = getNativeString(env, jcronTime);
! 	if (!cronTime) {
! 	    free(name);
! 	    if (path != NULL)
! 		free(path);
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
  	}
      } else {
  	cronTime = NULL;
      }
  
!     if (jnotifier != NULL) {
! 	notifier = getNativeString(env, jnotifier);
! 	if (!notifier) {
! 	    free(name);
! 	    if (path != NULL)
! 		free(path);
! 	    if (cronTime != NULL)
! 		free(cronTime);
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
  	}
      } else {
  	notifier = NULL;
      }
  
!     if (!bos_ProcessCreate
! 	((void *)serverHandle, name, type, path, cronTime, notifier, &ast)) {
! 	throwAFSException(env, ast);
      }
      // release strings
!     free(name);
!     if (path != NULL)
! 	free(path);
!     if (cronTime != NULL)
! 	free(cronTime);
!     if (notifier != NULL)
! 	free(notifier);
  }
  
  /**
--- 305,389 ----
  	type = BOS_PROCESS_CRON;
  	break;
      default:
!       if( name != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, jname, name);
!       }
!       if( path != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, jpath, path);
!       }
!       throwAFSException( env, jtype );
!       return;
!     }
! 
!     if( jcronTime != NULL ) {
! 	cronTime = (*env)->GetStringUTFChars(env, jcronTime, 0);
! 	if( !cronTime ) {
! 	  if( name != NULL ) {
! 	    (*env)->ReleaseStringUTFChars(env, jname, name);
! 	  }
! 	  if( path != NULL ) {
! 	    (*env)->ReleaseStringUTFChars(env, jpath, path);
! 	  }
! 	  throwAFSException( env, JAFSADMNOMEM );
! 	  return;    
  	}
      } else {
  	cronTime = NULL;
      }
  
!     if( jnotifier != NULL ) {
! 	notifier = (*env)->GetStringUTFChars(env, jnotifier, 0);
! 	if( !notifier ) {
! 	  if( name != NULL ) {
! 	    (*env)->ReleaseStringUTFChars(env, jname, name);
! 	  }
! 	  if( path != NULL ) {
! 	    (*env)->ReleaseStringUTFChars(env, jpath, path);
! 	  }
! 	  if( cronTime != NULL ) {
! 	    (*env)->ReleaseStringUTFChars(env, jcronTime, cronTime);
! 	  }
! 	  throwAFSException( env, JAFSADMNOMEM );
! 	  return;    
  	}
      } else {
  	notifier = NULL;
      }
  
!     if( !bos_ProcessCreate( (void *) serverHandle, name, type, path, 
! 			    cronTime, notifier, &ast ) ) {
! 	// release strings
! 	if( cronTime != NULL ) {
! 	    (*env)->ReleaseStringUTFChars(env, jcronTime, cronTime);
! 	}
! 	if( notifier != NULL ) {
! 	    (*env)->ReleaseStringUTFChars(env, jnotifier, notifier);
! 	}
! 	if( name != NULL ) {
! 	  (*env)->ReleaseStringUTFChars(env, jname, name);
! 	}
! 	if( path != NULL ) {
! 	  (*env)->ReleaseStringUTFChars(env, jpath, path);
! 	}
! 	throwAFSException( env, ast );
! 	return;
      }
+ 
+ 
      // release strings
!     if( cronTime != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, jcronTime, cronTime);
!     }
!     if( notifier != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, jnotifier, notifier);
!     }
!     if( name != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jname, name);
!     }
!     if( path != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jpath, path);
!     }
! 
  }
  
  /**
***************
*** 359,387 ****
   *                      belongs
   * jname   the name of the process to remove
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Process_delete(JNIEnv * env, jclass cls,
! 				     jint serverHandle, jstring jname)
! {
      afs_status_t ast;
!     char *name;
  
!     if (jname != NULL) {
! 	name = getNativeString(env, jname);
! 	if (!name) {
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
      } else {
! 	throwAFSException(env, JAFSNULLPROCESS);
! 	return;
      }
  
!     if (!bos_ProcessDelete((void *)serverHandle, name, &ast)) {
! 	throwAFSException(env, ast);
      }
  
-     free(name);
  }
  
  /**
--- 395,429 ----
   *                      belongs
   * jname   the name of the process to remove
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Process_delete (JNIEnv *env, jclass cls, 
! 					 jlong serverHandle, jstring jname) {
! 
      afs_status_t ast;
!     const char *name;
  
!     if( jname != NULL ) {
!       name = (*env)->GetStringUTFChars(env, jname, 0);
!       if( !name ) {
! 	  throwAFSException( env, JAFSADMNOMEM );
! 	  return;    
!       }
      } else {
!       name = NULL;
      }
  
!     if( !bos_ProcessDelete( (void *) serverHandle, name, &ast ) ) {
!       if( name != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, jname, name);
!       }
!       throwAFSException( env, ast );
!       return;
!     }
! 
!     if( name != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jname, name);
      }
  
  }
  
  /**
***************
*** 393,422 ****
   *                      belongs
   * jname   the name of the process to stop
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Process_stop(JNIEnv * env, jclass cls,
! 				   jint serverHandle, jstring jname)
! {
      afs_status_t ast;
!     char *name;
  
!     if (jname != NULL) {
! 	name = getNativeString(env, jname);
! 	if (!name) {
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
      } else {
! 	throwAFSException(env, JAFSNULLPROCESS);
! 	return;
      }
  
!     if (!bos_ProcessExecutionStateSet
! 	((void *)serverHandle, name, BOS_PROCESS_STOPPED, &ast)) {
! 	throwAFSException(env, ast);
      }
  
-     free(name);
  }
  
  /**
--- 435,470 ----
   *                      belongs
   * jname   the name of the process to stop
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Process_stop (JNIEnv *env, jclass cls, 
! 				       jlong serverHandle, jstring jname) {
! 
      afs_status_t ast;
!     const char *name;
  
!     if( jname != NULL ) {
!       name = (*env)->GetStringUTFChars(env, jname, 0);
!       if( !name ) {
! 	  throwAFSException( env, JAFSADMNOMEM );
! 	  return;    
!       }
      } else {
!       name = NULL;
      }
  
!     if( !bos_ProcessExecutionStateSet( (void *) serverHandle, name, 
! 				       BOS_PROCESS_STOPPED, &ast ) ) {
!       if( name != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, jname, name);
!       }
!       throwAFSException( env, ast );
!       return;
!     }
! 
!     if( name != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jname, name);
      }
  
  }
  
  /**
***************
*** 428,457 ****
   *                      belongs
   * jname   the name of the process to start
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Process_start(JNIEnv * env, jclass cls,
! 				    jint serverHandle, jstring jname)
! {
      afs_status_t ast;
!     char *name;
  
!     if (jname != NULL) {
! 	name = getNativeString(env, jname);
! 	if (!name) {
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
      } else {
! 	throwAFSException(env, JAFSNULLPROCESS);
! 	return;
      }
  
!     if (!bos_ProcessExecutionStateSet
! 	((void *)serverHandle, name, BOS_PROCESS_RUNNING, &ast)) {
! 	throwAFSException(env, ast);
      }
  
-     free(name);
  }
  
  /**
--- 476,511 ----
   *                      belongs
   * jname   the name of the process to start
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Process_start (JNIEnv *env, jclass cls, 
! 					jlong serverHandle, jstring jname) {
! 
      afs_status_t ast;
!     const char *name;
  
!     if( jname != NULL ) {
!       name = (*env)->GetStringUTFChars(env, jname, 0);
!       if( !name ) {
! 	  throwAFSException( env, JAFSADMNOMEM );
! 	  return;    
!       }
      } else {
!       name = NULL;
!     }
! 
!     if( !bos_ProcessExecutionStateSet( (void *) serverHandle, name, 
! 				       BOS_PROCESS_RUNNING, &ast ) ) {
!       if( name != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, jname, name);
!       }
!       throwAFSException( env, ast );
!       return;
      }
  
!     if( name != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jname, name);
      }
  
  }
  
  /**
***************
*** 463,499 ****
   *                      belongs
   * jname   the name of the process to restart
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Process_restart(JNIEnv * env, jclass cls,
! 				      jint serverHandle, jstring jname)
! {
      afs_status_t ast;
!     char *name;
  
!     if (jname != NULL) {
! 	name = getNativeString(env, jname);
! 	if (!name) {
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
      } else {
! 	throwAFSException(env, JAFSNULLPROCESS);
! 	return;
      }
  
!     if (!bos_ProcessRestart((void *)serverHandle, name, &ast)) {
! 	throwAFSException(env, ast);
      }
  
-     free(name);
  }
  
  // reclaim global memory being used by this portion
  JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Process_reclaimProcessMemory(JNIEnv * env, jclass cls)
! {
!     if (processCls) {
! 	(*env)->DeleteGlobalRef(env, processCls);
! 	processCls = 0;
!     }
  }
--- 517,567 ----
   *                      belongs
   * jname   the name of the process to restart
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Process_restart (JNIEnv *env, jclass cls, 
! 					  jlong serverHandle, jstring jname) {
! 
      afs_status_t ast;
!     const char *name;
  
!     if( jname != NULL ) {
!       name = (*env)->GetStringUTFChars(env, jname, 0);
!       if( !name ) {
! 	  throwAFSException( env, JAFSADMNOMEM );
! 	  return;    
!       }
      } else {
!       name = NULL;
!     }
! 
!     if( !bos_ProcessRestart( (void *) serverHandle, name, &ast ) ) {
!       if( name != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, jname, name);
!       }
!       throwAFSException( env, ast );
!       return;
      }
  
!     if( name != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jname, name);
      }
  
  }
  
  // reclaim global memory being used by this portion
  JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Process_reclaimProcessMemory (JNIEnv *env, 
! 						       jclass cls) {
! 
!   if( processCls ) {
!       (*env)->DeleteGlobalRef(env, processCls);
!       processCls = 0;
!   }
! 
  }
+ 
+ 
+ 
+ 
+ 
+ 
Index: openafs/src/JAVA/libjafs/README
diff -c /dev/null openafs/src/JAVA/libjafs/README:1.1.2.2
*** /dev/null	Sat Oct 22 02:14:46 2005
--- openafs/src/JAVA/libjafs/README	Fri Oct 14 22:14:12 2005
***************
*** 0 ****
--- 1,259 ----
+ Java API for OpenAFS (JAFS) README
+ Current as of June 4, 2003
+ 
+ ##########################################################################
+ # Copyright (c) 2001-2002 International Business Machines Corp.          #
+ # All rights reserved.                                                   #
+ #                                                                        #
+ # This software has been released under the terms of the IBM Public      #
+ # License.  For details, see the LICENSE file in the top-level source    #
+ # directory or online at http://www.openafs.org/dl/license10.html        #
+ #                                                                        #
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS    #
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT      #
+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR  #
+ # A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR #
+ # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,  #
+ # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,    #
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR     #
+ # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF #
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING   #
+ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS     #
+ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.           #
+ ##########################################################################
+ 
+ ---------------------------------------------------------------------------
+ *
+ * INTRODUCTION
+ *
+ ---------------------------------------------------------------------------
+ 
+ JAFS is an open source API designed to allow Java programmers the ability
+ to create applications for the administration or use of OpenAFS file systems.
+ It works by accessing libadmin and libuafs (administrative and user-level 
+ libraries that come with OpenAFS) through JNI.  It consists of a Java package 
+ called org.openafs.jafs, and two shared libraries libjafsadm.so and libjafs.so.
+ 
+ ---------------------------------------------------------------------------
+ *
+ * USE
+ *
+ ---------------------------------------------------------------------------
+ 
+ There is a version of JAFS that has been compiled on Red Hat Linux 7.3, 
+ and can be directly used without compilation.  It was compiled using
+ OpenAFS 1.2.10a libraries (with a modified version of libjuafs.a).  It 
+ consists of a JAR file (jafs-1.2.10a.jar) and two shared libraries 
+ (libjafsadm.so and libjafs.so).  It was compiled using the 
+ --enable-transarc-paths on compilation (for use with the OpenAFS RPMs), 
+ gcc 2.96, and Java Classic VM version 1.4.1_02.
+ 
+ When you write Java code to use this API, import the
+ org.openafs.jafs package. During compilation of your Java code, 
+ ensure one of the following conditions are met:
+   - Use the "-classpath" option to javac to specify the jafs.jar file.
+   - Change your $CLASSPATH environment variable to include the
+     jafs.jar file (e.g. export CLASSPATH=$CLASSPATH:jafs.jar
+ 
+ When running an application that uses JAFS, the shared libraries
+ need to be found by Java's library loader.  The easiest way to
+ accomplish this is to copy these files into the /usr/local/lib/ directory,
+ or create symbolic links from that directory to the files.  Alternatively, 
+ the directory containing the libraries can also be added to the
+ LD_LIBRARY_PATH environment variable.
+ 
+ You also need to have an OpenAFS client set up on your machine
+ (preferably version 1.2.10a, but it should work for some past versions as well).
+ You can obtain the OpenAFS client and view installation documentation at 
+ http://www.openafs.org (the RPMs are easiest to use for Linux).  Also any 
+ cells you plan to access through the API must have entries in your
+ client's CellServDB file (located in the /usr/vice/etc/ directory in most
+ setups).
+ 
+ This API is most effective when used with a cell that uses the kaserver
+ for authentication.  It does not currently support alternative methods of
+ authentication such as Kerberos V.
+ 
+ If you have successfully set up your Linux 7.3 environment as described
+ above, you will be able to develop and execute applications that use
+ the JAFS API.
+ 
+ ---------------------------------------------------------------------------
+ *
+ * BUILD
+ *
+ ---------------------------------------------------------------------------
+ 
+  ** DOWNLOAD SOURCE
+   The first step in compiling your own versions of the library and jar file
+   is to download the OpenAFS source code.  Please follow the directions for
+   for the source you download:
+ 
+  ** APPLY THE APPROPRIATE PATCH
+   You can apply the appropriate JAFS patch with the following command, 
+   executed from the root directory of the download code 
+   (i.e. openafs-1.2.10a/):
+ 
+       patch -p1 < xxx.diff
+       (where xxx.diff is one of the following patch files)
+ 
+   Use the patch respective to the source you are using:
+   * OpenAFS 1.2.6 Source (openafs-1.2.6-src.tar.gz)
+     OpenAFS 1.2.7 Source (openafs-1.2.7-src.tar.gz)
+     OpenAFS 1.2.8 Source (openafs-1.2.8-src.tar.gz)
+ 
+       jafs-1.2.6-8.diff 
+ 
+   * OpenAFS 1.2.9 Source (openafs-1.2.9-src.tar.gz)
+ 
+       jafs-1.2.9.diff 
+ 
+   * OpenAFS 1.2.10a Source (openafs-1.2.10a-src.tar.gz)
+ 
+       jafs-1.2.10a.diff 
+ 
+   * Daily Snapshot / CVS (example: openafs-snap-2003-05-21.tar.gz)
+ 
+       jafs.diff
+ 
+ 
+  ** RUN CONFIGURE
+   From the same directory, run the configure script as you normally would 
+   to compile OpenAFS, but run it with a java-home argument so the script can
+   find your java distribution.  For example:
+ 
+   ./configure [other options] --java-home=/usr/java/jdk
+ 
+   NOTE: If the configure script is not within the root source directory,
+         then you will need to first run ./regen.sh to generate the 
+         configure script.  In this case you will need to manually
+         modify the JAFS Makefile by setting the JAVA_HOME variable
+         to your local system's JAVA_HOME. (i.e. /usr/java/jdk)
+ 
+   The configure script will ensure that this directory contains bin/ and lib/ 
+   subdirectories, and that there are /bin/javac and/bin/javah executables and 
+   an include/jni.h file.  If you don't supply a command line argument for the 
+   java home, the script will look for it in environment variables: first in
+   $JAVA_HOME and then in $JDK_HOME.  Also, note that if you have installed
+   (or are planning to install) OpenAFS by using the RPMs for Linux, you
+   should provide the --enable-transarc-paths configuration option.  If you
+   get a "** Can't determine local cell name" error message, the most likely
+   reason is that you didn't supply this option.
+ 
+  ** RUN MAKE
+   Finally, do a full build of OpenAFS by executing 'make' in the current
+   directory.  After it finishes, you are ready to compile JAFS.  Execute
+   'make jafs' from that same directory.  Afterward, there will be 
+   libjafsadm.so and libjafs.so in the lib/ directory, and a jafs.jar in the 
+   jlib/ directory. These can be used according to the instructions in the 
+   'USE' section of this document. 
+ 
+   For additional make options, please refer to the next section "MAKE OPTIONS"
+ 
+ 
+ ---------------------------------------------------------------------------
+ *
+ * MAKE OPTIONS
+ *
+ ---------------------------------------------------------------------------
+ 
+ Additional make options are available by running 'make' from the 
+ src/JAVA/libjafs directory; they are as follows:
+ 
+ make            - Perform a full make of all Java classes, jar archive, and JNI
+                   libraries
+ make acltest    - Builds the ACL test program.  Program usage is available by
+                   simply invoking './acltest'
+ make clean      - Delete all Java classes, Java API docs, test programs, and C
+                   object files
+ make cleanc     - Only delete test programs and C object files.
+ make clean_jar  - Delete the Java archive library (jlib/jafs.jar)
+ make clean_libs - Delete both JNI shared libraries (lib/libjafs.so and
+                   lib/libjafsadm.so)
+ make install    - Performs a full make of all components and then installs all
+                   necessary components to your local system.  This option 
+                   prepares the required '/usr/afswsp/' directory for use by 
+                   the native library.
+ make javadocs   - Generate Java API documents (in javadoc format).  Docs are
+                   saved to src/JAVA/javadocs
+ make jar        - Builds the Java archive library (containing all Java classes)
+ make libjafs    - Builds the user-space library (used for ACL and file access)
+ make libjafsadm - Builds the administrative library (used for all admin related 
+                   functions)
+ 
+ ---------------------------------------------------------------------------
+ *
+ * DIRECTORIES, FILES, AND TEST PROGRAMS
+ *
+ ---------------------------------------------------------------------------
+ 
+ src/JAVA/libjafs:
+ 
+   Within the src/JAVA/libjafs directory you will find a few items in addition
+   to the C source code and Makefiles.  In particular, you will find 'acltest.c',
+   'buildinfo.pl', and a subdirectory 'etc'.
+ 
+   acltest.c     - A test program that allows testing of the native libraries
+                   ACL calls without going through Java.  
+ 
+                   *Usage information for this program is available by simply 
+                   invoking './acltest' without any parameters.
+ 
+   buildinfo.pl  - A perl script that automatically updates the build information
+                   every time the native libraries are compiled.  Additionally,
+                   it automatically increments the build number associate with
+                   the native libraries (found in VersionInfo.h).  It may also
+                   be used to programatically query for build information.
+ 
+                   *Usage information for this program is available by simply 
+                   invoking 'perl buildinfo.pl' without any parameters.
+ 
+   etc/          - A directory containing user-space configuration files. These 
+                   files are used for user-space initialization and cache 
+                   configuration and are copied to '/usr/afswsp/etc' if a
+                   'make install' is issued.
+ 
+ src/JAVA/classes:
+ 
+   Within the src/JAVA/classes directory you will find the root of the Java 
+   package, the error message catalog file, and a test program:
+ 
+   *.java        - Java classes that comprise the test program.
+ 
+   adminTest     - A script that invokes the Java console-based test program.
+                   This program can be used to exercise all major API calls 
+                   from Java, thus testing JNI libraries as well as Java code.
+ 
+                   *Usage information for this program is available via its
+                   help menu: './adminTest help'
+ 
+   adminTest.properties
+                 - Configuration file for the Admin test program (only contains
+                   default cell name for administrator)
+ 
+   ErrorMessages.properties
+                 - Error message catalog file used by the ErrorTable class. Note
+                   that an additional message file can be generated that represents
+                   a language other than english (refer to the ErrorTable API docs
+                   for more information)
+ 
+   org/          - Root of the Java class package (package: org.openafs.jafs)
+ 
+ 
+ src/JAVA/javadocs:
+ 
+   This directory is dynamically generated when you issue a 'make javadocs' from
+   the src/JAVA/libjafs directory. It contains all Java API documentation
+   generated from the Java classes.
+ 
+ ---------------------------------------------------------------------------
+ *
+ * MISC
+ *
+ ---------------------------------------------------------------------------
+ 
+ If you'd like to edit the source code, you'll find the native C code in
+ the src/JAVA/libjafs directory, and the Java code in the 
+ src/JAVA/classes/org/openafs/jafs/ directory.  Please reference the 
+ src/TechNotes-JavaAPI document for more information.
+ 
Index: openafs/src/JAVA/libjafs/Server.c
diff -c openafs/src/JAVA/libjafs/Server.c:1.3 openafs/src/JAVA/libjafs/Server.c:1.3.2.1
*** openafs/src/JAVA/libjafs/Server.c:1.3	Tue Jul 15 19:11:26 2003
--- openafs/src/JAVA/libjafs/Server.c	Fri Oct 14 22:14:12 2005
***************
*** 66,89 ****
  
  ///// definition in jafs_Partition.c /////////////////
  
! extern void fillPartitionInfo(JNIEnv * env, jobject partition,
! 			      vos_partitionEntry_t partEntry);
  
  ///////////////////////////////////////////////////
  
  ///// definition in jafs_Key.c /////////////////
  
! extern void fillKeyInfo(JNIEnv * env, jobject key, bos_KeyInfo_t keyEntry);
  
  ///////////////////////////////////////////////////
  
  ///// definition in jafs_Process.c /////////////////
  
! extern void getProcessInfoChar(JNIEnv * env, void *serverHandle,
! 			       const char *processName, jobject process);
  
  ///////////////////////////////////////////////////
  
  /**
   * Extract the information from the given server entry and populate the
   * given object
--- 66,100 ----
  
  ///// definition in jafs_Partition.c /////////////////
  
! extern void fillPartitionInfo( JNIEnv *env, jobject partition, 
! 			       vos_partitionEntry_t partEntry );
  
  ///////////////////////////////////////////////////
  
  ///// definition in jafs_Key.c /////////////////
  
! extern void fillKeyInfo( JNIEnv *env, jobject key, bos_KeyInfo_t keyEntry );
  
  ///////////////////////////////////////////////////
  
  ///// definition in jafs_Process.c /////////////////
  
! extern void getProcessInfoChar( JNIEnv *env, void *serverHandle, 
! 				const char *processName, jobject process );
  
  ///////////////////////////////////////////////////
  
+ 
+ void IntIPAddressToString(int iIPAddress, char *strIPAddress)
+ {
+     sprintf(strIPAddress, "%d.%d.%d.%d",
+ 	    (int)((iIPAddress >> 24) & 0xFF),
+ 	    (int)((iIPAddress >> 16) & 0xFF),
+ 	    (int)((iIPAddress >>  8) & 0xFF),
+ 	    (int)((iIPAddress	  ) & 0xFF)
+     );
+ } //IntIPAddressToString
+ 
  /**
   * Extract the information from the given server entry and populate the
   * given object
***************
*** 93,190 ****
   * server      the Server object to populate with the info
   * servEntry     the container of the server's information
   */
! void
! fillServerInfo(JNIEnv * env, jint cellHandle, jobject server,
! 	       afs_serverEntry_t servEntry)
  {
!     jstring jip;
!     jobjectArray jaddresses;
!     jstring jserver;
!     int i = 0;
! 
!     // get the class fields if need be
!     if (serverCls == 0) {
! 	internal_getServerClass(env, server);
!     }
!     // in case it's blank
!     jserver = (*env)->NewStringUTF(env, servEntry.serverName);
!     (*env)->SetObjectField(env, server, server_nameField, jserver);
! 
!     // let's convert just the addresses in the address array into an IP
!     jaddresses =
! 	(jobjectArray) (*env)->GetObjectField(env, server,
! 					      server_IPAddressField);
!     for (i = 0; i < 16; i++) {
! 	if (servEntry.serverAddress[i] != 0) {
! 	    jip = (*env)->NewStringUTF(env, (char *)
! 				       inet_ntoa(htonl
! 						 (servEntry.
! 						  serverAddress[i])));
! 	    (*env)->SetObjectArrayElement(env, jaddresses, i, jip);
! 	} else {
! 	    break;
! 	}
!     }
  
!     // let's check if this is really a database server
!     (*env)->SetBooleanField(env, server, server_databaseField,
! 			    servEntry.serverType & DATABASE_SERVER);
!     if (servEntry.serverType & DATABASE_SERVER) {
! 	// for now, if it thinks it's a database server than it is
! 	// later, add checks for database configuration, and actual 
! 	// on-ness of the machine
! 	(*env)->SetBooleanField(env, server, server_badDatabaseField, FALSE);
!     } else {
! 	(*env)->SetBooleanField(env, server, server_badDatabaseField, FALSE);
!     }
! 
!     // we should check to see if this is truly a file server or not
!     // it could just be an old remnant, left over inside the vldb that 
!     // should be removed.
!     // if it is a file server, mark it as such.  If not, mark it as faulty.
!     (*env)->SetBooleanField(env, server, server_fileServerField,
! 			    servEntry.serverType & FILE_SERVER);
!     if (servEntry.serverType & FILE_SERVER) {
! 
! 	// to see if it's really a file server, make sure the 
! 	// "fs" process is running
! 	void *bosHandle;
! 	afs_status_t ast;
! 	bos_ProcessType_t processTypeT;
! 	bos_ProcessInfo_t processInfoT;
! 	char *fileServerProcessName = "fs";
! 
! 	// set the file server to true (it thinks it's a file server)
! 	(*env)->SetBooleanField(env, server, server_fileServerField, TRUE);
! 
! 	if (!bos_ServerOpen
! 	    ((void *)cellHandle, servEntry.serverName, &bosHandle, &ast)) {
! 	    throwAFSException(env, ast);
! 	    return;
! 	}
! 	if (!bos_ProcessInfoGet
! 	    (bosHandle, fileServerProcessName, &processTypeT, &processInfoT,
! 	     &ast)) {
! 	    // if the machine does not have a fs process or is not responding 
! 	    // or is part of another cell
! 	    if (ast == BZNOENT || ast == -1 || ast == RXKADBADTICKET) {
! 		(*env)->SetBooleanField(env, server,
! 					server_badFileServerField, TRUE);
! 		// otherwise
! 	    } else {
! 		throwAFSException(env, ast);
! 		return;
! 	    }
  	} else {
! 	    // it's good
! 	    (*env)->SetBooleanField(env, server, server_badFileServerField,
! 				    FALSE);
  	}
!     } else {
! 	(*env)->SetBooleanField(env, server, server_badFileServerField,
! 				FALSE);
!     }
  
  }
  
  /**
--- 104,203 ----
   * server      the Server object to populate with the info
   * servEntry     the container of the server's information
   */
! void fillServerInfo
!   ( JNIEnv *env, void *cellHandle, jobject server, afs_serverEntry_t servEntry )
  {
!   jstring jip;
!   jobjectArray jaddresses;
!   jstring jserver;
!   int i = 0;
!   char szServerAddr[AFS_MAX_SERVER_NAME_LEN];
! 
!   // get the class fields if need be
!   if( serverCls == 0 ) {
!     internal_getServerClass( env, server );
!   }
! 
!   // in case it's blank
!   jserver = (*env)->NewStringUTF(env, servEntry.serverName);
!   (*env)->SetObjectField(env, server, server_nameField, jserver);
! 
!   // let's convert just the addresses in the address array into an IP
!   jaddresses = (jobjectArray) (*env)->GetObjectField( env, server, 
! 						      server_IPAddressField );
  
!   for (i = 0; i < AFS_MAX_SERVER_ADDRESS; i++) {
! 	if (servEntry.serverAddress[i] != 0) {
! 	  IntIPAddressToString(servEntry.serverAddress[i], szServerAddr);
! 	  jip = (*env)->NewStringUTF(env, szServerAddr);
! 	  (*env)->SetObjectArrayElement(env, jaddresses, i, jip);
  	} else {
! 	  break;
  	}
!   }
  
+   // let's check if this is really a database server
+   (*env)->SetBooleanField(env, server, server_databaseField, 
+ 			  servEntry.serverType & DATABASE_SERVER);
+ 
+   if( servEntry.serverType & DATABASE_SERVER ) {
+     // for now, if it thinks it's a database server than it is
+     // later, add checks for database configuration, and actual 
+     // on-ness of the machine
+     (*env)->SetBooleanField(env, server, server_badDatabaseField, FALSE);
+   } else {
+     (*env)->SetBooleanField(env, server, server_badDatabaseField, FALSE);
+   }
+ 
+   // we should check to see if this is truly a file server or not
+   // it could just be an old remnant, left over inside the vldb that 
+   // should be removed.
+   // if it is a file server, mark it as such.  If not, mark it as faulty.
+   (*env)->SetBooleanField(env, server, server_fileServerField,  
+ 			  servEntry.serverType & FILE_SERVER);
+ 
+   if( servEntry.serverType & FILE_SERVER ) {
+     
+     // to see if it's really a file server, make sure the 
+     // "fs" process is running
+     void *bosHandle;
+     afs_status_t ast, ast2;
+     bos_ProcessType_t processTypeT;
+     bos_ProcessInfo_t processInfoT;
+     char *fileServerProcessName = "fs";
+ 
+     // set the file server to true (it thinks it's a file server)
+     (*env)->SetBooleanField(env, server, server_fileServerField, TRUE);
+ 
+     if( !bos_ServerOpen( cellHandle, servEntry.serverName, 
+ 			 &bosHandle, &ast ) ) {
+       throwAFSException( env, ast );
+       return;
+     }
+ 
+     if( !bos_ProcessInfoGet( bosHandle, fileServerProcessName, &processTypeT, 
+ 			     &processInfoT, &ast ) ) {
+       // if the machine does not have a fs process or is not responding 
+       // or is part of another cell
+       if( ast == BZNOENT || ast == -1 || ast == RXKADBADTICKET ) {
+         (*env)->SetBooleanField(env, server, server_badFileServerField, TRUE);
+       // otherwise
+       } else {
+         bos_ServerClose( bosHandle, &ast2 );
+         throwAFSException( env, ast );
+         return;
+       }
+     } else {
+       // it's good
+       (*env)->SetBooleanField(env, server, server_badFileServerField, FALSE);
+     }
+     if (!bos_ServerClose( bosHandle, &ast )) {
+       throwAFSException( env, ast );
+       return;
+     }
+   } else {
+     (*env)->SetBooleanField(env, server, server_badFileServerField, FALSE);
+   }
  }
  
  /**
***************
*** 197,230 ****
   * server     the Server object in which to fill in 
   *                   the information
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Server_getServerInfo(JNIEnv * env, jclass cls,
! 					   jint cellHandle, jstring jname,
! 					   jobject server)
! {
!     char *name;
!     afs_status_t ast;
!     afs_serverEntry_t servEntry;
! 
!     if (jname != NULL) {
! 	name = getNativeString(env, jname);
! 	if (name == NULL) {
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	throwAFSException(env, JAFSNULLSERVER);
! 	return;
!     }
  
-     // get the server entry
-     if (!afsclient_AFSServerGet((void *)cellHandle, name, &servEntry, &ast)) {
- 	throwAFSException(env, ast);
-     }
- 
-     fillServerInfo(env, cellHandle, server, servEntry);
- 
-     free(name);
  }
  
  /**
--- 210,250 ----
   * server     the Server object in which to fill in 
   *                   the information
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Server_getServerInfo (JNIEnv *env, jclass cls, 
! 					       jlong cellHandle, jstring jname, 
! 					       jobject server) {
! 
!   const char *name;
!   afs_status_t ast;
!   afs_serverEntry_t servEntry;
! 
!   if( jname != NULL ) {
!     name = (*env)->GetStringUTFChars(env, jname, 0);
!     if( !name ) {
! 	throwAFSException( env, JAFSADMNOMEM );
! 	return;    
!     }
!   } else {
!     name = NULL;
!   }
! 
!   // get the server entry
!   if ( !afsclient_AFSServerGet( (void *) cellHandle, name, 
! 				&servEntry, &ast ) ) {
!     if( name != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jname, name);
!     }
!     throwAFSException( env, ast );
!     return;
!   }
! 
!   fillServerInfo( env, cellHandle, server, servEntry );
! 
!   if( name != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, jname, name);
!   }
  
  }
  
  /**
***************
*** 238,269 ****
   *                      partitions belong
   * returns total number of partitions
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Server_getPartitionCount(JNIEnv * env, jclass cls,
! 					       jint cellHandle,
! 					       jint serverHandle)
! {
!     afs_status_t ast;
!     void *iterationId;
!     vos_partitionEntry_t partEntry;
!     int i = 0;
  
!     if (!vos_PartitionGetBegin
! 	((void *)cellHandle, (void *)serverHandle, NULL, &iterationId,
! 	 &ast)) {
! 	throwAFSException(env, ast);
! 	return -1;
!     }
! 
!     while (vos_PartitionGetNext((void *)iterationId, &partEntry, &ast))
! 	i++;
! 
!     if (ast != ADMITERATORDONE) {
! 	throwAFSException(env, ast);
! 	return -1;
!     }
! 
!     return i;
  }
  
  /**
--- 258,287 ----
   *                      partitions belong
   * returns total number of partitions
   */
! JNIEXPORT jint JNICALL 
! Java_org_openafs_jafs_Server_getPartitionCount (JNIEnv *env, jclass cls, 
! 						   jlong cellHandle, 
! 						   jlong serverHandle) {
! 
!   afs_status_t ast;
!   void *iterationId;
!   vos_partitionEntry_t partEntry;
!   int i = 0;
! 
!   if( !vos_PartitionGetBegin( (void *) cellHandle, (void *) serverHandle, 
! 			      NULL, &iterationId, &ast ) ) {
!     throwAFSException( env, ast );
!     return -1;
!   }
! 
!   while ( vos_PartitionGetNext( (void *) iterationId, &partEntry, &ast ) ) i++;
! 
!   if( ast != ADMITERATORDONE ) {
!     throwAFSException( env, ast );
!     return -1;
!   }
  
!   return i;
  }
  
  /**
***************
*** 278,299 ****
   *                      partitions belong
   * returns an iteration ID
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Server_getPartitionsBegin(JNIEnv * env, jclass cls,
! 						jint cellHandle,
! 						jint serverHandle)
! {
!     afs_status_t ast;
!     void *iterationId;
! 
!     if (!vos_PartitionGetBegin
! 	((void *)cellHandle, (void *)serverHandle, NULL, &iterationId,
! 	 &ast)) {
! 	throwAFSException(env, ast);
! 	return;
!     }
  
!     return (jint) iterationId;
  
  }
  
--- 296,316 ----
   *                      partitions belong
   * returns an iteration ID
   */
! JNIEXPORT jlong JNICALL 
! Java_org_openafs_jafs_Server_getPartitionsBegin (JNIEnv *env, jclass cls, 
! 						    jlong cellHandle, 
! 						    jlong serverHandle) {
! 
!   afs_status_t ast;
!   void *iterationId;
! 
!   if( !vos_PartitionGetBegin( (void *) cellHandle, (void *) serverHandle, 
! 			      NULL, &iterationId, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
!   return (jlong) iterationId;
  
  }
  
***************
*** 306,330 ****
   * iterationId   the iteration ID of this iteration
   * returns the name of the next partition of the server
   */
! JNIEXPORT jstring JNICALL
! Java_org_openafs_jafs_Server_getPartitionsNextString(JNIEnv * env, jclass cls,
! 						     jint iterationId)
! {
!     afs_status_t ast;
!     jstring jpartition;
!     vos_partitionEntry_t partEntry;
! 
!     if (!vos_PartitionGetNext((void *)iterationId, &partEntry, &ast)) {
! 	if (ast == ADMITERATORDONE) {
! 	    return NULL;
! 	} else {
! 	    throwAFSException(env, ast);
! 	    return;
! 	}
      }
  
!     jpartition = (*env)->NewStringUTF(env, partEntry.name);
!     return jpartition;
  
  }
  
--- 323,348 ----
   * iterationId   the iteration ID of this iteration
   * returns the name of the next partition of the server
   */
! JNIEXPORT jstring JNICALL 
! Java_org_openafs_jafs_Server_getPartitionsNextString (JNIEnv *env, 
! 							 jclass cls, 
! 							 jlong iterationId) {
! 
!   afs_status_t ast;
!   jstring jpartition;
!   vos_partitionEntry_t partEntry;
! 
!   if( !vos_PartitionGetNext( (void *) iterationId, &partEntry, &ast ) ) {
!     if( ast == ADMITERATORDONE ) {
!       return NULL;
!     } else {
!       throwAFSException( env, ast );
!       return;
      }
+   }
  
!   jpartition = (*env)->NewStringUTF(env, partEntry.name);
!   return jpartition;
  
  }
  
***************
*** 339,372 ****
   *                       values of the next partition
   * returns 0 if there are no more servers, != 0 otherwise
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Server_getPartitionsNext(JNIEnv * env, jclass cls,
! 					       jint iterationId,
! 					       jobject jpartitionObject)
! {
!     afs_status_t ast;
!     vos_partitionEntry_t partEntry;
! 
!     if (!vos_PartitionGetNext((void *)iterationId, &partEntry, &ast)) {
! 	if (ast == ADMITERATORDONE) {
! 	    return 0;
! 	} else {
! 	    throwAFSException(env, ast);
! 	    return 0;
! 	}
!     }
  
!     fillPartitionInfo(env, jpartitionObject, partEntry);
! 
!     // get the class fields if need be
!     if (partitionCls == 0) {
! 	internal_getPartitionClass(env, jpartitionObject);
!     }
!     (*env)->SetBooleanField(env, jpartitionObject, partition_cachedInfoField,
! 			    TRUE);
! 
! 
!     return 1;
  
  }
  
--- 357,390 ----
   *                       values of the next partition
   * returns 0 if there are no more servers, != 0 otherwise
   */
! JNIEXPORT jint JNICALL 
! Java_org_openafs_jafs_Server_getPartitionsNext (JNIEnv *env, jclass cls, 
! 						   jlong iterationId, 
! 						   jobject jpartitionObject) {
!     
!   afs_status_t ast;
!   vos_partitionEntry_t partEntry;
! 
!   if( !vos_PartitionGetNext( (void *) iterationId, &partEntry, &ast ) ) {
!     if( ast == ADMITERATORDONE ) {
!       return 0;
!     } else {
!       throwAFSException( env, ast );
!       return 0;
!     }
!   }
! 
!   fillPartitionInfo( env, jpartitionObject, partEntry );
! 
!   // get the class fields if need be
!   if( partitionCls == 0 ) {
!     internal_getPartitionClass( env, jpartitionObject );
!   }
!   (*env)->SetBooleanField( env, jpartitionObject, partition_cachedInfoField, 
! 			   TRUE );
  
!     
!   return 1;
  
  }
  
***************
*** 377,392 ****
   * cls      the current Java class
   * iterationId   the iteration ID of this iteration
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Server_getPartitionsDone(JNIEnv * env, jclass cls,
! 					       jint iterationId)
! {
!     afs_status_t ast;
! 
!     if (!vos_PartitionGetDone((void *)iterationId, &ast)) {
! 	throwAFSException(env, ast);
! 	return;
!     }
  
  }
  
--- 395,410 ----
   * cls      the current Java class
   * iterationId   the iteration ID of this iteration
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Server_getPartitionsDone (JNIEnv *env, jclass cls, 
! 						   jlong iterationId) {
! 
!   afs_status_t ast;
! 
!   if( !vos_PartitionGetDone( (void *) iterationId, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
  }
  
***************
*** 399,427 ****
   *                      partitions belong
   * jnewAdmin   the name of the admin to add to the list
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Server_addBosAdmin(JNIEnv * env, jclass cls,
! 					 jint serverHandle, jstring jnewAdmin)
! {
!     afs_status_t ast;
!     char *newAdmin;
! 
!     if (jnewAdmin != NULL) {
! 	newAdmin = getNativeString(env, jnewAdmin);
! 	if (newAdmin == NULL) {
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	throwAFSException(env, JAFSNULLUSER);
! 	return;
!     }
! 
!     if (!bos_AdminCreate((void *)serverHandle, newAdmin, &ast)) {
! 	throwAFSException(env, ast);
!     }
! 
!     free(newAdmin);
  
  }
  
--- 417,451 ----
   *                      partitions belong
   * jnewAdmin   the name of the admin to add to the list
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Server_addBosAdmin (JNIEnv *env, jclass cls, 
! 					     jlong serverHandle, 
! 					     jstring jnewAdmin) {
! 
!   afs_status_t ast;
!   const char *newAdmin;
! 
!   if( jnewAdmin != NULL ) {
!     newAdmin = (*env)->GetStringUTFChars(env, jnewAdmin, 0);
!     if( !newAdmin ) {
! 	throwAFSException( env, JAFSADMNOMEM );
! 	return;    
!     }
!   } else {
!     newAdmin = NULL;
!   }
! 
!   if( !bos_AdminCreate( (void *) serverHandle, newAdmin, &ast ) ) {
!     if( newAdmin != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jnewAdmin, newAdmin);
!     }
!     throwAFSException( env, ast );
!     return;
!   }
! 
!   if( newAdmin != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, jnewAdmin, newAdmin);
!   }
  
  }
  
***************
*** 435,464 ****
   *                      partitions belong
   * joldAdmin   the name of the admin to remove from the list
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Server_removeBosAdmin(JNIEnv * env, jclass cls,
! 					    jint serverHandle,
! 					    jstring joldAdmin)
! {
!     afs_status_t ast;
!     char *oldAdmin;
  
-     if (joldAdmin != NULL) {
- 	oldAdmin = getNativeString(env, joldAdmin);
- 	if (oldAdmin == NULL) {
- 	    throwAFSException(env, JAFSADMNOMEM);
- 	    return;
- 	}
-     } else {
- 	throwAFSException(env, JAFSNULLUSER);
- 	return;
-     }
- 
-     if (!bos_AdminDelete((void *)serverHandle, oldAdmin, &ast)) {
- 	throwAFSException(env, ast);
-     }
- 
-     free(oldAdmin);
  }
  
  /**
--- 459,494 ----
   *                      partitions belong
   * joldAdmin   the name of the admin to remove from the list
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Server_removeBosAdmin (JNIEnv *env, jclass cls, 
! 						jlong serverHandle, 
! 						jstring joldAdmin) {
! 
!   afs_status_t ast;
!   const char *oldAdmin;
! 
!   if( joldAdmin != NULL ) {
!     oldAdmin = (*env)->GetStringUTFChars(env, joldAdmin, 0);
!     if( !oldAdmin ) {
! 	throwAFSException( env, JAFSADMNOMEM );
! 	return;    
!     }
!   } else {
!     oldAdmin = NULL;
!   }
! 
!   if( !bos_AdminDelete( (void *) serverHandle, oldAdmin, &ast ) ) {
!     if( oldAdmin != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, joldAdmin, oldAdmin);
!     }
!     throwAFSException( env, ast );
!     return;
!   }
! 
!   if( oldAdmin != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, joldAdmin, oldAdmin);
!   }
  
  }
  
  /**
***************
*** 471,509 ****
   *                      BOS admins belong
   * returns total number of BOS administrators
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Server_getBosAdminCount(JNIEnv * env, jclass cls,
! 					      jint serverHandle)
! {
!     afs_status_t ast;
!     void *iterationId;
!     char *admin;
!     jstring jadmin;
!     int i = 0;
! 
!     if (!bos_AdminGetBegin((void *)serverHandle, &iterationId, &ast)) {
! 	throwAFSException(env, ast);
! 	return -1;
!     }
! 
!     admin = (char *)malloc(sizeof(char) * BOS_MAX_NAME_LEN);
! 
!     if (!admin) {
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return -1;
!     }
! 
!     while (bos_AdminGetNext((void *)iterationId, admin, &ast))
! 	i++;
! 
!     free(admin);
! 
!     if (ast != ADMITERATORDONE) {
! 	throwAFSException(env, ast);
! 	return -1;
!     }
  
!     return i;
  }
  
  /**
--- 501,538 ----
   *                      BOS admins belong
   * returns total number of BOS administrators
   */
! JNIEXPORT jint JNICALL 
! Java_org_openafs_jafs_Server_getBosAdminCount (JNIEnv *env, jclass cls, 
! 						  jlong serverHandle) {
! 
!   afs_status_t ast;
!   void *iterationId;
!   char *admin;
!   jstring jadmin;
!   int i = 0;
! 
!   if( !bos_AdminGetBegin( (void *) serverHandle, &iterationId, &ast ) ) {
!     throwAFSException( env, ast );
!     return -1;
!   }
! 
!   admin = (char *) malloc( sizeof(char)*BOS_MAX_NAME_LEN);
! 
!   if( !admin ) {
!     throwAFSException( env, JAFSADMNOMEM );
!     return -1;
!   }
! 
!   while ( bos_AdminGetNext( (void *) iterationId, admin, &ast ) ) i++;
! 
!   free(admin);
! 
!   if( ast != ADMITERATORDONE ) {
!     throwAFSException( env, ast );
!     return -1;
!   }
  
!   return i;
  }
  
  /**
***************
*** 517,535 ****
   *                      partitions belong
   * returns an iteration ID
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Server_getBosAdminsBegin(JNIEnv * env, jclass cls,
! 					       jint serverHandle)
! {
!     afs_status_t ast;
!     void *iterationId;
  
!     if (!bos_AdminGetBegin((void *)serverHandle, &iterationId, &ast)) {
! 	throwAFSException(env, ast);
! 	return;
!     }
  
-     return (jint) iterationId;
  }
  
  /**
--- 546,565 ----
   *                      partitions belong
   * returns an iteration ID
   */
! JNIEXPORT jlong JNICALL 
! Java_org_openafs_jafs_Server_getBosAdminsBegin (JNIEnv *env, jclass cls, 
! 						   jlong serverHandle) {
! 
!   afs_status_t ast;
!   void *iterationId;
! 
!   if( !bos_AdminGetBegin( (void *) serverHandle, &iterationId, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
!   return (jlong) iterationId;
  
  }
  
  /**
***************
*** 541,573 ****
   * iterationId   the iteration ID of this iteration
   * returns the name of the next admin of the server
   */
! JNIEXPORT jstring JNICALL
! Java_org_openafs_jafs_Server_getBosAdminsNextString(JNIEnv * env, jclass cls,
! 						    jint iterationId)
! {
! 
!     afs_status_t ast;
!     jstring jadmin;
!     char *admin = (char *)malloc(sizeof(char) * BOS_MAX_NAME_LEN);
! 
!     if (!admin) {
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return;
!     }
  
!     if (!bos_AdminGetNext((void *)iterationId, admin, &ast)) {
! 	free(admin);
! 	if (ast == ADMITERATORDONE) {
! 	    return NULL;
! 	} else {
! 	    throwAFSException(env, ast);
! 	    return;
! 	}
      }
  
!     jadmin = (*env)->NewStringUTF(env, admin);
!     free(admin);
!     return jadmin;
  
  }
  
--- 571,603 ----
   * iterationId   the iteration ID of this iteration
   * returns the name of the next admin of the server
   */
! JNIEXPORT jstring JNICALL 
! Java_org_openafs_jafs_Server_getBosAdminsNextString (JNIEnv *env, 
! 							jclass cls, 
! 							jlong iterationId) {
! 
!   afs_status_t ast;
!   jstring jadmin;
!   char *admin = (char *) malloc( sizeof(char)*BOS_MAX_NAME_LEN );
! 
!   if( !admin ) {
!     throwAFSException( env, JAFSADMNOMEM );
!     return;    
!   }
  
!   if( !bos_AdminGetNext( (void *) iterationId, admin, &ast ) ) {
!     free(admin);
!     if( ast == ADMITERATORDONE ) {
!       return NULL;
!     } else {
!       throwAFSException( env, ast );
!       return;
      }
+   }
  
!   jadmin = (*env)->NewStringUTF(env, admin);
!   free(admin);
!   return jadmin;
  
  }
  
***************
*** 582,627 ****
   * juserObject   the user object in which to fill the values of this admin
   * returns 0 if no more admins, != 0 otherwise
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Server_getBosAdminsNext(JNIEnv * env, jclass cls,
! 					      jint cellHandle,
! 					      jint iterationId,
! 					      jobject juserObject)
! {
!     afs_status_t ast;
!     char *admin;
!     jstring jadmin;
! 
!     admin = (char *)malloc(sizeof(char) * BOS_MAX_NAME_LEN);
! 
!     if (!admin) {
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return;
!     }
  
!     if (!bos_AdminGetNext((void *)iterationId, admin, &ast)) {
! 	free(admin);
! 	if (ast == ADMITERATORDONE) {
! 	    return 0;
! 	} else {
! 	    throwAFSException(env, ast);
! 	    return 0;
! 	}
!     }
! 
!     jadmin = (*env)->NewStringUTF(env, admin);
! 
!     if (userCls == 0) {
! 	internal_getUserClass(env, juserObject);
!     }
  
!     (*env)->SetObjectField(env, juserObject, user_nameField, jadmin);
  
!     getUserInfoChar(env, cellHandle, admin, juserObject);
!     (*env)->SetBooleanField(env, juserObject, user_cachedInfoField, TRUE);
! 
!     free(admin);
!     return 1;
  
  }
  
--- 612,657 ----
   * juserObject   the user object in which to fill the values of this admin
   * returns 0 if no more admins, != 0 otherwise
   */
! JNIEXPORT jint JNICALL 
! Java_org_openafs_jafs_Server_getBosAdminsNext (JNIEnv *env, jclass cls, 
! 						  jlong cellHandle, 
! 						  jlong iterationId, 
! 						  jobject juserObject ) {
!     
!   afs_status_t ast;
!   char *admin;
!   jstring jadmin;
! 
!   admin = (char *) malloc( sizeof(char)*BOS_MAX_NAME_LEN);
! 
!   if( !admin ) {
!     throwAFSException( env, JAFSADMNOMEM );
!     return;    
!   }
! 
!   if( !bos_AdminGetNext( (void *) iterationId, admin, &ast ) ) {
!     free( admin );
!     if( ast == ADMITERATORDONE ) {
!       return 0;
!     } else {
!       throwAFSException( env, ast );
!       return 0;
!     }
!   }
! 
!   jadmin = (*env)->NewStringUTF(env, admin);
! 
!   if( userCls == 0 ) {
!     internal_getUserClass( env, juserObject );
!   }
  
!   (*env)->SetObjectField(env, juserObject, user_nameField, jadmin);
  
!   getUserInfoChar( env, cellHandle, admin, juserObject );
!   (*env)->SetBooleanField( env, juserObject, user_cachedInfoField, TRUE );
  
!   free( admin );
!   return 1;
  
  }
  
***************
*** 632,647 ****
   * cls      the current Java class
   * iterationId   the iteration ID of this iteration
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Server_getBosAdminsDone(JNIEnv * env, jclass cls,
! 					      jint iterationId)
! {
!     afs_status_t ast;
  
-     if (!bos_AdminGetDone((void *)iterationId, &ast)) {
- 	throwAFSException(env, ast);
- 	return;
-     }
  }
  
  /**
--- 662,678 ----
   * cls      the current Java class
   * iterationId   the iteration ID of this iteration
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Server_getBosAdminsDone (JNIEnv *env, jclass cls, 
! 						  jlong iterationId) {
! 
!   afs_status_t ast;
! 
!   if( !bos_AdminGetDone( (void *) iterationId, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
  }
  
  /**
***************
*** 654,682 ****
   *                      keys belong
   * returns total number of keys
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Server_getKeyCount(JNIEnv * env, jclass cls,
! 					 jint serverHandle)
! {
!     afs_status_t ast;
!     void *iterationId;
!     bos_KeyInfo_t keyEntry;
!     int i = 0;
! 
!     if (!bos_KeyGetBegin((void *)serverHandle, &iterationId, &ast)) {
! 	throwAFSException(env, ast);
! 	return -1;
!     }
  
!     while (bos_KeyGetNext((void *)iterationId, &keyEntry, &ast))
! 	i++;
! 
!     if (ast != ADMITERATORDONE) {
! 	throwAFSException(env, ast);
! 	return -1;
!     }
! 
!     return i;
  }
  
  /**
--- 685,712 ----
   *                      keys belong
   * returns total number of keys
   */
! JNIEXPORT jint JNICALL 
! Java_org_openafs_jafs_Server_getKeyCount (JNIEnv *env, jclass cls, 
! 					     jlong serverHandle) {
! 
!   afs_status_t ast;
!   void *iterationId;
!   bos_KeyInfo_t keyEntry;
!   int i = 0;
! 
!   if( !bos_KeyGetBegin( (void *) serverHandle, &iterationId, &ast ) ) {
!     throwAFSException( env, ast );
!     return -1;
!   }
! 
!   while ( bos_KeyGetNext( (void *) iterationId, &keyEntry, &ast ) ) i++;
! 
!   if( ast != ADMITERATORDONE ) {
!     throwAFSException( env, ast );
!     return -1;
!   }
  
!   return i;
  }
  
  /**
***************
*** 689,707 ****
   * serverHandle  the bos handle of the server to which the keys belong
   * returns an iteration ID
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Server_getKeysBegin(JNIEnv * env, jclass cls,
! 					  jint serverHandle)
! {
!     afs_status_t ast;
!     void *iterationId;
  
!     if (!bos_KeyGetBegin((void *)serverHandle, &iterationId, &ast)) {
! 	throwAFSException(env, ast);
! 	return;
!     }
  
-     return (jint) iterationId;
  }
  
  /**
--- 719,738 ----
   * serverHandle  the bos handle of the server to which the keys belong
   * returns an iteration ID
   */
! JNIEXPORT jlong JNICALL 
! Java_org_openafs_jafs_Server_getKeysBegin (JNIEnv *env, jclass cls, 
! 					      jlong serverHandle) {
! 
!   afs_status_t ast;
!   void *iterationId;
! 
!   if( !bos_KeyGetBegin( (void *) serverHandle, &iterationId, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
!   return (jlong) iterationId;
  
  }
  
  /**
***************
*** 715,747 ****
   *                 properties of the next key.
   * returns 0 if there are no more keys, != 0 otherwise
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Server_getKeysNext(JNIEnv * env, jclass cls,
! 					 jint iterationId, jobject jkeyObject)
! {
! 
!     afs_status_t ast;
!     bos_KeyInfo_t keyEntry;
  
!     if (!bos_KeyGetNext((void *)iterationId, &keyEntry, &ast)) {
! 	if (ast == ADMITERATORDONE) {
! 	    return 0;
! 	} else {
! 	    throwAFSException(env, ast);
! 	    return 0;
! 	}
      }
  
!     fillKeyInfo(env, jkeyObject, keyEntry);
  
!     // get the class fields if need be
!     if (keyCls == 0) {
! 	internal_getKeyClass(env, jkeyObject);
!     }
  
!     (*env)->SetBooleanField(env, jkeyObject, key_cachedInfoField, TRUE);
  
-     return 1;
  }
  
  /**
--- 746,779 ----
   *                 properties of the next key.
   * returns 0 if there are no more keys, != 0 otherwise
   */
! JNIEXPORT jint JNICALL 
! Java_org_openafs_jafs_Server_getKeysNext (JNIEnv *env, jclass cls, 
! 					     jlong iterationId, 
! 					     jobject jkeyObject) {
!     
!   afs_status_t ast;
!   bos_KeyInfo_t keyEntry;
  
!   if( !bos_KeyGetNext( (void *) iterationId, &keyEntry, &ast ) ) {
!     if( ast == ADMITERATORDONE ) {
!       return 0;
!     } else {
!       throwAFSException( env, ast );
!       return 0;
      }
+   }
  
!   fillKeyInfo( env, jkeyObject, keyEntry );
  
!   // get the class fields if need be
!   if( keyCls == 0 ) {
!     internal_getKeyClass( env, jkeyObject );
!   }
! 
!   (*env)->SetBooleanField( env, jkeyObject, key_cachedInfoField, TRUE );
  
!   return 1;
  
  }
  
  /**
***************
*** 751,766 ****
   * cls      the current Java class
   * iterationId   the iteration ID of this iteration
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Server_getKeysDone(JNIEnv * env, jclass cls,
! 					 jint iterationId)
! {
!     afs_status_t ast;
  
-     if (!bos_KeyGetDone((void *)iterationId, &ast)) {
- 	throwAFSException(env, ast);
- 	return;
-     }
  }
  
  /**
--- 783,799 ----
   * cls      the current Java class
   * iterationId   the iteration ID of this iteration
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Server_getKeysDone (JNIEnv *env, jclass cls, 
! 					     jlong iterationId) {
! 
!   afs_status_t ast;
! 
!   if( !bos_KeyGetDone( (void *) iterationId, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
  }
  
  /**
***************
*** 773,811 ****
   *                      processes belong
   * returns total number of processes
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Server_getProcessCount(JNIEnv * env, jclass cls,
! 					     jint serverHandle)
! {
!     afs_status_t ast;
!     void *iterationId;
!     char *process;
!     jstring jprocess;
!     int i = 0;
! 
!     if (!bos_ProcessNameGetBegin((void *)serverHandle, &iterationId, &ast)) {
! 	throwAFSException(env, ast);
! 	return -1;
!     }
! 
!     process = (char *)malloc(sizeof(char) * BOS_MAX_NAME_LEN);
! 
!     if (!process) {
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return -1;
!     }
! 
!     while (bos_ProcessNameGetNext((void *)iterationId, process, &ast))
! 	i++;
  
!     free(process);
! 
!     if (ast != ADMITERATORDONE) {
! 	throwAFSException(env, ast);
! 	return -1;
!     }
! 
!     return i;
  }
  
  /**
--- 806,843 ----
   *                      processes belong
   * returns total number of processes
   */
! JNIEXPORT jint JNICALL 
! Java_org_openafs_jafs_Server_getProcessCount (JNIEnv *env, jclass cls, 
! 						 jlong serverHandle) {
! 
!   afs_status_t ast;
!   void *iterationId;
!   char *process;
!   jstring jprocess;
!   int i = 0;
! 
!   if( !bos_ProcessNameGetBegin( (void *) serverHandle, &iterationId, &ast ) ) {
!     throwAFSException( env, ast );
!     return -1;
!   }
! 
!   process = (char *) malloc( sizeof(char)*BOS_MAX_NAME_LEN );
! 
!   if( !process ) {
!     throwAFSException( env, JAFSADMNOMEM );
!     return -1;
!   }
! 
!   while ( bos_ProcessNameGetNext( (void *) iterationId, process, &ast ) ) i++;
! 
!   free( process );
! 
!   if( ast != ADMITERATORDONE ) {
!     throwAFSException( env, ast );
!     return -1;
!   }
  
!   return i;
  }
  
  /**
***************
*** 819,837 ****
   *                      processes belong
   * returns an iteration ID
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Server_getProcessesBegin(JNIEnv * env, jclass cls,
! 					       jint serverHandle)
! {
!     afs_status_t ast;
!     void *iterationId;
  
!     if (!bos_ProcessNameGetBegin((void *)serverHandle, &iterationId, &ast)) {
! 	throwAFSException(env, ast);
! 	return;
!     }
  
-     return (jint) iterationId;
  }
  
  /**
--- 851,870 ----
   *                      processes belong
   * returns an iteration ID
   */
! JNIEXPORT jlong JNICALL 
! Java_org_openafs_jafs_Server_getProcessesBegin (JNIEnv *env, jclass cls, 
! 						   jlong serverHandle) {
! 
!   afs_status_t ast;
!   void *iterationId;
! 
!   if( !bos_ProcessNameGetBegin( (void *) serverHandle, &iterationId, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
!   return (jlong) iterationId;
  
  }
  
  /**
***************
*** 843,874 ****
   * iterationId   the iteration ID of this iteration
   * returns the name of the next process of the cell
   */
! JNIEXPORT jstring JNICALL
! Java_org_openafs_jafs_Server_getProcessesNextString(JNIEnv * env, jclass cls,
! 						    jint iterationId)
! {
!     afs_status_t ast;
!     jstring jprocess;
!     char *process = (char *)malloc(sizeof(char) * BOS_MAX_NAME_LEN);
  
-     if (!process) {
- 	throwAFSException(env, JAFSADMNOMEM);
- 	return;
-     }
- 
-     if (!bos_ProcessNameGetNext((void *)iterationId, process, &ast)) {
- 	free(process);
- 	if (ast == ADMITERATORDONE) {
- 	    return NULL;
- 	} else {
- 	    throwAFSException(env, ast);
- 	    return;
- 	}
-     }
- 
-     jprocess = (*env)->NewStringUTF(env, process);
-     free(process);
-     return jprocess;
  }
  
  /**
--- 876,909 ----
   * iterationId   the iteration ID of this iteration
   * returns the name of the next process of the cell
   */
! JNIEXPORT jstring JNICALL 
! Java_org_openafs_jafs_Server_getProcessesNextString (JNIEnv *env, 
! 							jclass cls, 
! 							jlong iterationId) {
! 
!   afs_status_t ast;
!   jstring jprocess;
!   char *process = (char *) malloc( sizeof(char)*BOS_MAX_NAME_LEN );
! 
!   if( !process ) {
!     throwAFSException( env, JAFSADMNOMEM );
!     return;    
!   }
! 
!   if( !bos_ProcessNameGetNext( (void *) iterationId, process, &ast ) ) {
!     free( process );
!     if( ast == ADMITERATORDONE ) {
!       return NULL;
!     } else {
!       throwAFSException( env, ast );
!       return;
!     }
!   }
! 
!   jprocess = (*env)->NewStringUTF(env, process);
!   free( process );
!   return jprocess;
  
  }
  
  /**
***************
*** 883,927 ****
   *                          values of the next process
   * returns 0 if there are no more processes, != otherwise
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Server_getProcessesNext(JNIEnv * env, jclass cls,
! 					      jint serverHandle,
! 					      jint iterationId,
! 					      jobject jprocessObject)
! {
!     afs_status_t ast;
!     char *process = (char *)malloc(sizeof(char) * BOS_MAX_NAME_LEN);
!     jstring jprocess;
  
!     if (!process) {
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return;
!     }
  
!     if (!bos_ProcessNameGetNext((void *)iterationId, process, &ast)) {
! 	free(process);
! 	if (ast == ADMITERATORDONE) {
! 	    return 0;
! 	} else {
! 	    throwAFSException(env, ast);
! 	    return 0;
! 	}
!     }
!     // get the class fields if need be
!     if (processCls == 0) {
! 	internal_getProcessClass(env, jprocessObject);
!     }
  
!     jprocess = (*env)->NewStringUTF(env, process);
!     (*env)->SetObjectField(env, jprocessObject, process_nameField, jprocess);
  
-     getProcessInfoChar(env, (void *)serverHandle, process, jprocessObject);
- 
-     (*env)->SetBooleanField(env, jprocessObject, process_cachedInfoField,
- 			    TRUE);
- 
-     free(process);
-     return 1;
  }
  
  /**
--- 918,964 ----
   *                          values of the next process
   * returns 0 if there are no more processes, != otherwise
   */
! JNIEXPORT jint JNICALL 
! Java_org_openafs_jafs_Server_getProcessesNext (JNIEnv *env, jclass cls, 
! 						  jlong serverHandle, 
! 						  jlong iterationId, 
! 						  jobject jprocessObject) {
!     
!   afs_status_t ast;
!   char *process = (char *) malloc( sizeof(char)*BOS_MAX_NAME_LEN );
!   jstring jprocess;
! 
!   if( !process ) {
!     throwAFSException( env, JAFSADMNOMEM );
!     return;    
!   }
! 
!   if( !bos_ProcessNameGetNext( (void *) iterationId, process, &ast ) ) {
!     if( ast == ADMITERATORDONE ) {
!       return 0;
!     } else {
!       free( process );
!       throwAFSException( env, ast );
!       return 0;
!     }
!   }
! 
!   // get the class fields if need be
!   if( processCls == 0 ) {
!     internal_getProcessClass( env, jprocessObject );
!   }
! 
!   jprocess = (*env)->NewStringUTF(env, process);
!   (*env)->SetObjectField(env, jprocessObject, process_nameField, jprocess);
  
!   getProcessInfoChar( env, (void *) serverHandle, process, jprocessObject );
  
!   (*env)->SetBooleanField( env, jprocessObject, 
! 			   process_cachedInfoField, TRUE );
  
!   free( process );
!   return 1;
  
  }
  
  /**
***************
*** 931,946 ****
   * cls      the current Java class
   * iterationId   the iteration ID of this iteration
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Server_getProcessesDone(JNIEnv * env, jclass cls,
! 					      jint iterationId)
! {
!     afs_status_t ast;
  
-     if (!bos_ProcessNameGetDone((void *)iterationId, &ast)) {
- 	throwAFSException(env, ast);
- 	return;
-     }
  }
  
  /**
--- 968,984 ----
   * cls      the current Java class
   * iterationId   the iteration ID of this iteration
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Server_getProcessesDone (JNIEnv *env, jclass cls, 
! 						  jlong iterationId) {
! 
!   afs_status_t ast;
! 
!   if( !bos_ProcessNameGetDone( (void *) iterationId, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
  }
  
  /**
***************
*** 975,1106 ****
   *                          one block at a time and skip badly damaged 
   *                          blocks.  Use if partition has disk errors
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Server_salvage(JNIEnv * env, jclass cls,
! 				     jint cellHandle, jint serverHandle,
! 				     jstring jpartName, jstring jvolName,
! 				     jint numSalvagers, jstring jtempDir,
! 				     jstring jlogFile,
! 				     jboolean inspectAllVolumes,
! 				     jboolean removeBadlyDamaged,
! 				     jboolean writeInodes,
! 				     jboolean writeRootInodes,
! 				     jboolean forceDirectory,
! 				     jboolean forceBlockReads)
! {
!     afs_status_t ast;
!     char *partName;
!     char *volName;
!     char *tempDir;
!     char *logFile;
!     vos_force_t force;
!     bos_SalvageDamagedVolumes_t sdv;
!     bos_WriteInodes_t wi;
!     bos_WriteRootInodes_t wri;
!     bos_ForceDirectory_t forceD;
!     bos_ForceBlockRead_t forceBR;
! 
!     // convert strings
!     if (jpartName != NULL) {
! 	partName = getNativeString(env, jpartName);
! 	if (!partName) {
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	partName = NULL;
!     }
! 
!     if (jvolName != NULL) {
! 	volName = getNativeString(env, jvolName);
! 	if (!volName) {
! 	    if (partName != NULL)
! 		free(partName);
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	volName = NULL;
!     }
! 
!     if (jtempDir != NULL) {
! 	tempDir = getNativeString(env, jtempDir);
! 	if (!tempDir) {
! 	    if (partName != NULL)
! 		free(partName);
! 	    if (volName != NULL)
! 		free(volName);
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	tempDir = NULL;
!     }
! 
!     if (jlogFile != NULL) {
! 	logFile = getNativeString(env, jlogFile);
! 	if (!logFile) {
! 	    if (partName != NULL)
! 		free(partName);
! 	    if (volName != NULL)
! 		free(volName);
! 	    if (tempDir != NULL)
! 		free(tempDir);
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	logFile = NULL;
!     }
! 
!     // deal with booleans
!     if (inspectAllVolumes) {
! 	force = VOS_FORCE;
!     } else {
! 	force = VOS_NORMAL;
!     }
!     if (removeBadlyDamaged) {
! 	sdv = BOS_DONT_SALVAGE_DAMAGED_VOLUMES;
!     } else {
! 	sdv = BOS_SALVAGE_DAMAGED_VOLUMES;
!     }
!     if (writeInodes) {
! 	wi = BOS_SALVAGE_WRITE_INODES;
!     } else {
! 	wi = BOS_SALVAGE_DONT_WRITE_INODES;
!     }
!     if (writeRootInodes) {
! 	wri = BOS_SALVAGE_WRITE_ROOT_INODES;
!     } else {
! 	wri = BOS_SALVAGE_DONT_WRITE_ROOT_INODES;
!     }
!     if (forceDirectory) {
! 	forceD = BOS_SALVAGE_FORCE_DIRECTORIES;
!     } else {
! 	forceD = BOS_SALVAGE_DONT_FORCE_DIRECTORIES;
!     }
!     if (forceBlockReads) {
! 	forceBR = BOS_SALVAGE_FORCE_BLOCK_READS;
!     } else {
! 	forceBR = BOS_SALVAGE_DONT_FORCE_BLOCK_READS;
!     }
! 
!     //salvage!
!     if (!bos_Salvage
! 	((void *)cellHandle, (void *)serverHandle, partName, volName,
! 	 (int)numSalvagers, tempDir, logFile, force, sdv, wi, wri, forceD,
! 	 forceBR, &ast)) {
! 	throwAFSException(env, ast);
!     }
!     // release strings
!     if (partName != NULL)
! 	free(partName);
!     if (volName != NULL)
! 	free(volName);
!     if (tempDir != NULL)
! 	free(tempDir);
!     if (logFile != NULL)
! 	free(logFile);
  
  }
  
--- 1013,1164 ----
   *                          one block at a time and skip badly damaged 
   *                          blocks.  Use if partition has disk errors
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Server_salvage (JNIEnv *env, jclass cls, 
! 					 jlong cellHandle, jlong serverHandle, 
! 					 jstring jpartName, jstring jvolName, 
! 					 jint numSalvagers, jstring jtempDir, 
! 					 jstring jlogFile, 
! 					 jboolean inspectAllVolumes, 
! 					 jboolean removeBadlyDamaged, 
! 					 jboolean writeInodes, 
! 					 jboolean writeRootInodes, 
! 					 jboolean forceDirectory, 
! 					 jboolean forceBlockReads) {
! 
!   afs_status_t ast;
!   const char *partName;
!   const char *volName;
!   const char *tempDir;
!   const char *logFile;
!   vos_force_t force;
!   bos_SalvageDamagedVolumes_t sdv;
!   bos_WriteInodes_t wi;
!   bos_WriteRootInodes_t wri;
!   bos_ForceDirectory_t forceD;
!   bos_ForceBlockRead_t forceBR;
!   
!   // convert strings
!   if( jpartName != NULL ) {
!     partName = (*env)->GetStringUTFChars(env, jpartName, 0);    
!     if( !partName ) {
! 	throwAFSException( env, JAFSADMNOMEM );
! 	return;    
!     }
!   } else {
!     partName = NULL;
!   }
!   if( jvolName != NULL ) {
!     volName = (*env)->GetStringUTFChars(env, jvolName, 0);    
!     if( !volName ) {
!       if( partName != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, jpartName, partName);    
!       }
!       throwAFSException( env, JAFSADMNOMEM );
!       return;    
!     }
!   } else {
!     volName = NULL;
!   }
!   if( jtempDir != NULL ) {
!     tempDir = (*env)->GetStringUTFChars(env, jtempDir, 0);    
!     if( !tempDir ) {
!       if( partName != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, jpartName, partName);    
!       }
!       if( volName != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, jvolName, volName);    
!       }
!       throwAFSException( env, JAFSADMNOMEM );
!       return;    
!     }
!   } else {
!     tempDir = NULL;
!   }
!   if( jlogFile != NULL ) {
!     logFile = (*env)->GetStringUTFChars(env, jlogFile, 0);    
!     if( !logFile ) {
!       if( partName != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, jpartName, partName);    
!       }
!       if( volName != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, jvolName, volName);    
!       }
!       if( tempDir != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, jtempDir, tempDir);    
!       }
!       throwAFSException( env, JAFSADMNOMEM );
!       return;    
!     }
!   } else {
!     logFile = NULL;
!   }
! 
!   // deal with booleans
!   if( inspectAllVolumes ) {
!     force = VOS_FORCE;
!   } else {
!     force = VOS_NORMAL;
!   }
!   if( removeBadlyDamaged ) {
!     sdv = BOS_DONT_SALVAGE_DAMAGED_VOLUMES;
!   } else {
!     sdv = BOS_SALVAGE_DAMAGED_VOLUMES;
!   }
!   if( writeInodes ) {
!     wi = BOS_SALVAGE_WRITE_INODES;
!   } else {
!     wi = BOS_SALVAGE_DONT_WRITE_INODES;
!   }
!   if( writeRootInodes ) {
!     wri = BOS_SALVAGE_WRITE_ROOT_INODES;
!   } else {
!     wri = BOS_SALVAGE_DONT_WRITE_ROOT_INODES;
!   }
!   if( forceDirectory ) {
!     forceD = BOS_SALVAGE_FORCE_DIRECTORIES;
!   } else {
!     forceD = BOS_SALVAGE_DONT_FORCE_DIRECTORIES;
!   }
!   if( forceBlockReads ) {
!     forceBR = BOS_SALVAGE_FORCE_BLOCK_READS;
!   } else {
!     forceBR = BOS_SALVAGE_DONT_FORCE_BLOCK_READS;
!   }
! 
!   //salvage!
!   if( !bos_Salvage( (void *) cellHandle, (void *) serverHandle, partName, 
! 		    volName, (int) numSalvagers, tempDir, logFile, force, sdv, 
! 		    wi, wri, forceD, forceBR, &ast ) ) {
!     if( partName != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jpartName, partName);    
!     }
!     if( volName != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jvolName, volName);    
!     }
!     if( tempDir != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jtempDir, tempDir);    
!     }
!     if( logFile != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jlogFile, logFile);    
!     }
!     throwAFSException( env, ast );
!     return;
!   }
! 
!   // release strings
!   if( partName != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, jpartName, partName);    
!   }
!   if( volName != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, jvolName, volName);    
!   }
!   if( tempDir != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, jtempDir, tempDir);    
!   }
!   if( logFile != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, jlogFile, logFile);    
!   }
  
  }
  
***************
*** 1118,1184 ****
   * execTime   the ExecutableTime object, in which 
   *                   to fill the restart time fields
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Server_getRestartTime(JNIEnv * env, jclass cls,
! 					    jint serverHandle, jint jtype,
! 					    jobject exectime)
! {
!     afs_status_t ast;
!     bos_Restart_t type;
!     bos_RestartTime_t time;
!     jfieldID hourField;
!     jfieldID minField;
!     jfieldID secField;
!     jfieldID dayField;
!     jfieldID neverField;
!     jfieldID nowField;
! 
!     // get the class fields if need be
!     if (exectimeCls == 0) {
! 	internal_getExecTimeClass(env, exectime);
!     }
! 
!     if (jtype == org_openafs_jafs_Server_RESTART_BINARY) {
! 	type = BOS_RESTART_DAILY;
!     } else {
! 	type = BOS_RESTART_WEEKLY;
!     }
! 
!     hourField = exectime_HourField;
!     minField = exectime_MinField;
!     secField = exectime_SecField;
!     dayField = exectime_DayField;
!     neverField = exectime_NeverField;
!     nowField = exectime_NowField;
! 
!     if (!bos_ExecutableRestartTimeGet
! 	((void *)serverHandle, type, &time, &ast)) {
! 	throwAFSException(env, ast);
! 	return;
!     }
!     // set now
!     (*env)->SetBooleanField(env, exectime, nowField,
! 			    (time.mask & BOS_RESTART_TIME_NOW));
! 
!     // set never
!     (*env)->SetBooleanField(env, exectime, neverField,
! 			    (time.mask & BOS_RESTART_TIME_NEVER));
! 
!     // set hour
!     (*env)->SetShortField(env, exectime, hourField, time.hour);
! 
!     // set minute
!     (*env)->SetShortField(env, exectime, minField, time.min);
! 
!     // set second
!     (*env)->SetShortField(env, exectime, secField, time.sec);
! 
!     // set day
!     if (time.mask & BOS_RESTART_TIME_DAY) {
! 	(*env)->SetShortField(env, exectime, dayField, time.day);
!     } else {
! 	(*env)->SetShortField(env, exectime, dayField, (jshort) - 1);
!     }
  
  }
  
--- 1176,1242 ----
   * execTime   the ExecutableTime object, in which 
   *                   to fill the restart time fields
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Server_getRestartTime
!   (JNIEnv *env, jclass cls, jlong serverHandle, jint jtype, jobject exectime)
! {
!   afs_status_t ast;
!   bos_Restart_t type;
!   bos_RestartTime_t time;
!   jfieldID hourField;
!   jfieldID minField;
!   jfieldID secField;
!   jfieldID dayField;
!   jfieldID neverField;
!   jfieldID nowField;
! 
!   // get the class fields if need be
!   if( exectimeCls == 0 ) {
!     internal_getExecTimeClass( env, exectime );
!   }
! 
!   if( jtype == org_openafs_jafs_Server_RESTART_BINARY ) {
!     type = BOS_RESTART_DAILY;
!   } else {
!     type = BOS_RESTART_WEEKLY;
!   }
! 
!   hourField  = exectime_HourField;
!   minField   = exectime_MinField;
!   secField   = exectime_SecField;
!   dayField   = exectime_DayField;
!   neverField = exectime_NeverField;
!   nowField   = exectime_NowField;
! 
!   if( !bos_ExecutableRestartTimeGet( (void *) serverHandle, type, 
! 				     &time, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
!   
!   // set now
!   (*env)->SetBooleanField(env, exectime, nowField, 
! 			  (time.mask & BOS_RESTART_TIME_NOW) );
!   
!   // set never
!   (*env)->SetBooleanField(env, exectime, neverField, 
! 			  (time.mask & BOS_RESTART_TIME_NEVER) );
! 
!   // set hour
!   (*env)->SetShortField(env, exectime, hourField, time.hour );
! 
!   // set minute
!   (*env)->SetShortField(env, exectime, minField, time.min );
! 
!   // set second
!   (*env)->SetShortField(env, exectime, secField, time.sec );
! 
!   // set day
!   if( time.mask & BOS_RESTART_TIME_DAY ) {
!     (*env)->SetShortField(env, exectime, dayField, time.day );
!   } else {
!     (*env)->SetShortField(env, exectime, dayField, (jshort) -1 );
!   }
  
  }
  
***************
*** 1195,1305 ****
   * executableTime   the ExecutableTime object containing the 
   *                         desired information
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Server_setRestartTime(JNIEnv * env, jclass cls,
! 					    jint serverHandle, jint jtype,
! 					    jobject exectime)
! {
!     afs_status_t ast;
!     bos_Restart_t type;
!     bos_RestartTime_t time;
!     jboolean doHour;
!     jboolean doMinute;
!     jboolean doSecond;
!     jboolean doDay;
!     jboolean doNever;
!     jboolean doNow;
!     jshort hour;
!     jshort minute;
!     jshort second;
!     jshort day;
!     jfieldID hourField;
!     jfieldID minField;
!     jfieldID secField;
!     jfieldID dayField;
!     jfieldID neverField;
!     jfieldID nowField;
! 
!     // get the class fields if need be
!     if (exectimeCls == 0) {
! 	internal_getExecTimeClass(env, exectime);
!     }
! 
!     if (jtype == org_openafs_jafs_Server_RESTART_BINARY) {
! 	type = BOS_RESTART_DAILY;
!     } else {
! 	type = BOS_RESTART_WEEKLY;
!     }
! 
!     hourField = exectime_HourField;
!     minField = exectime_MinField;
!     secField = exectime_SecField;
!     dayField = exectime_DayField;
!     neverField = exectime_NeverField;
!     nowField = exectime_NowField;
! 
!     hour = (*env)->GetShortField(env, exectime, hourField);
!     if (hour != 0) {
! 	doHour = TRUE;
!     } else {
! 	doHour = FALSE;
!     }
!     minute = (*env)->GetShortField(env, exectime, minField);
!     if (minute != 0) {
! 	doMinute = TRUE;
!     } else {
! 	doMinute = FALSE;
!     }
!     second = (*env)->GetShortField(env, exectime, secField);
!     if (second != 0) {
! 	doSecond = TRUE;
!     } else {
! 	doSecond = FALSE;
!     }
!     day = (*env)->GetShortField(env, exectime, dayField);
!     if (day != -1) {
! 	doDay = TRUE;
!     } else {
! 	doDay = FALSE;
!     }
!     doNever = (*env)->GetBooleanField(env, exectime, neverField);
!     doNow = (*env)->GetBooleanField(env, exectime, nowField);
! 
!     bzero(&time, sizeof(time));
  
-     if (jtype == org_openafs_jafs_Server_RESTART_BINARY) {
- 	type = BOS_RESTART_DAILY;
-     } else {
- 	type = BOS_RESTART_WEEKLY;
-     }
- 
-     if (doHour) {
- 	time.mask |= BOS_RESTART_TIME_HOUR;
-     }
-     if (doMinute) {
- 	time.mask |= BOS_RESTART_TIME_MINUTE;
-     }
-     if (doSecond) {
- 	time.mask |= BOS_RESTART_TIME_SECOND;
-     }
-     if (doDay) {
- 	time.mask |= BOS_RESTART_TIME_DAY;
-     }
-     if (doNever) {
- 	time.mask |= BOS_RESTART_TIME_NEVER;
-     }
-     if (doNow) {
- 	time.mask |= BOS_RESTART_TIME_NOW;
-     }
- 
-     time.hour = hour;
-     time.min = minute;
-     time.sec = second;
-     time.day = day;
- 
-     if (!bos_ExecutableRestartTimeSet((void *)serverHandle, type, time, &ast)) {
- 	throwAFSException(env, ast);
-     }
  }
  
  /**
--- 1253,1366 ----
   * executableTime   the ExecutableTime object containing the 
   *                         desired information
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Server_setRestartTime (JNIEnv *env, jclass cls, 
! 						jlong serverHandle, jint jtype, 
! 						jobject exectime ) {
! 
!   afs_status_t ast;
!   bos_Restart_t type;
!   bos_RestartTime_t time;
!   jboolean doHour;
!   jboolean doMinute;
!   jboolean doSecond;
!   jboolean doDay;
!   jboolean doNever;
!   jboolean doNow;  
!   jshort hour;
!   jshort minute;
!   jshort second;
!   jshort day;
!   jfieldID hourField;
!   jfieldID minField;
!   jfieldID secField;
!   jfieldID dayField;
!   jfieldID neverField;
!   jfieldID nowField;
! 
!   // get the class fields if need be
!   if( exectimeCls == 0 ) {
!     internal_getExecTimeClass( env, exectime );
!   }
! 
!   if( jtype == org_openafs_jafs_Server_RESTART_BINARY ) {
!     type = BOS_RESTART_DAILY;
!   } else {
!     type = BOS_RESTART_WEEKLY;
!   }
! 
!   hourField  = exectime_HourField;
!   minField   = exectime_MinField;
!   secField   = exectime_SecField;
!   dayField   = exectime_DayField;
!   neverField = exectime_NeverField;
!   nowField   = exectime_NowField;
! 
!   hour = (*env)->GetShortField(env, exectime, hourField );
!   if( hour != 0 ) {
!     doHour = TRUE;
!   } else {
!     doHour = FALSE;
!   }
!   minute = (*env)->GetShortField(env, exectime, minField );
!   if( minute != 0 ) {
!     doMinute = TRUE;
!   } else {
!     doMinute = FALSE;
!   }
!   second = (*env)->GetShortField(env, exectime, secField );
!   if( second != 0 ) {
!     doSecond = TRUE;
!   } else {
!     doSecond = FALSE;
!   }
!   day = (*env)->GetShortField(env, exectime, dayField );
!   if( day != -1 ) {
!     doDay = TRUE;
!   } else {
!     doDay = FALSE;
!   }
!   doNever = (*env)->GetBooleanField(env, exectime, neverField );
!   doNow = (*env)->GetBooleanField(env, exectime, nowField );
! 
!   bzero(&time, sizeof(time));
! 
!   if( jtype == org_openafs_jafs_Server_RESTART_BINARY ) {
!     type = BOS_RESTART_DAILY;
!   } else {
!     type = BOS_RESTART_WEEKLY;
!   }  
! 
!   if( doHour ) {
!     time.mask |= BOS_RESTART_TIME_HOUR;
!   }
!   if( doMinute ) {
!     time.mask |= BOS_RESTART_TIME_MINUTE;
!   }
!   if( doSecond ) {
!     time.mask |= BOS_RESTART_TIME_SECOND;
!   }
!   if( doDay ) {
!     time.mask |= BOS_RESTART_TIME_DAY;
!   }
!   if( doNever ) {
!     time.mask |= BOS_RESTART_TIME_NEVER;
!   }
!   if( doNow ) {
!     time.mask |= BOS_RESTART_TIME_NOW;
!   }
! 
!   time.hour = hour;
!   time.min = minute;
!   time.sec = second;
!   time.day = day;
! 
!   if( !bos_ExecutableRestartTimeSet( (void *) serverHandle, type, 
! 				     time, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
  }
  
  /**
***************
*** 1311,1335 ****
   * serverHandle  the vos handle of the server     
   * partition   the id of the partition to sync, can be -1 to ignore
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Server_syncServerWithVLDB(JNIEnv * env, jclass cls,
! 						jint cellHandle,
! 						jint serverHandle,
! 						jint partition)
! {
!     afs_status_t ast;
!     int *part;
! 
!     if (partition == -1) {
! 	part = NULL;
!     } else {
! 	part = (int *)&partition;
!     }
  
-     if (!vos_ServerSync
- 	((void *)cellHandle, (void *)serverHandle, NULL, part, &ast)) {
- 	throwAFSException(env, ast);
-     }
  }
  
  /**
--- 1372,1398 ----
   * serverHandle  the vos handle of the server     
   * partition   the id of the partition to sync, can be -1 to ignore
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Server_syncServerWithVLDB (JNIEnv *env, jclass cls, 
! 						    jlong cellHandle, 
! 						    jlong serverHandle, 
! 						    jint partition) {
! 
!   afs_status_t ast;
!   int *part;
! 
!   if( partition == -1 ) {
!     part = NULL;
!   } else {
!     part = (int *) &partition;
!   }
! 
!   if( !vos_ServerSync( (void *) cellHandle, (void *) serverHandle, 
! 		       NULL, part, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
  }
  
  /**
***************
*** 1342,1374 ****
   * partition   the id of the partition to sync, can be -1 to ignore
   * forceDeletion   whether or not to force the deletion of bad volumes
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Server_syncVLDBWithServer(JNIEnv * env, jclass cls,
! 						jint cellHandle,
! 						jint serverHandle,
! 						jint partition,
! 						jboolean forceDeletion)
! {
!     afs_status_t ast;
!     int *part;
!     vos_force_t force;
  
-     if (partition == -1) {
- 	part = NULL;
-     } else {
- 	part = (int *)&partition;
-     }
- 
-     if (forceDeletion) {
- 	force = VOS_FORCE;
-     } else {
- 	force = VOS_NORMAL;
-     }
- 
-     if (!vos_VLDBSync
- 	((void *)cellHandle, (void *)serverHandle, NULL, part, force, &ast)) {
- 	throwAFSException(env, ast);
-     }
  }
  
  /**
--- 1405,1439 ----
   * partition   the id of the partition to sync, can be -1 to ignore
   * forceDeletion   whether or not to force the deletion of bad volumes
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Server_syncVLDBWithServer (JNIEnv *env, jclass cls, 
! 						    jlong cellHandle, 
! 						    jlong serverHandle, 
! 						    jint partition, 
! 						    jboolean forceDeletion) {
! 
!   afs_status_t ast;
!   int *part;
!   vos_force_t force;
! 
!   if( partition == -1 ) {
!     part = NULL;
!   } else {
!     part = (int *) &partition;
!   }
!   
!   if( forceDeletion ) {
!     force = VOS_FORCE;
!   } else {
!     force = VOS_NORMAL;
!   }
! 
!   if( !vos_VLDBSync( (void *) cellHandle, (void *) serverHandle, NULL, part, 
! 		     force, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
  }
  
  /**
***************
*** 1379,1394 ****
   * serverHandle  the bos handle of the server to which the 
   *                      processes belong
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Server_startAllProcesses(JNIEnv * env, jclass cls,
! 					       jint serverHandle)
! {
!     afs_status_t ast;
  
-     if (!bos_ProcessAllStart((void *)serverHandle, &ast)) {
- 	throwAFSException(env, ast);
- 	return;
-     }
  }
  
  /**
--- 1444,1460 ----
   * serverHandle  the bos handle of the server to which the 
   *                      processes belong
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Server_startAllProcesses (JNIEnv *env, jclass cls, 
! 						   jlong serverHandle) {
! 
!   afs_status_t ast;
! 
!   if( !bos_ProcessAllStart( (void *) serverHandle, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
  }
  
  /**
***************
*** 1399,1414 ****
   * serverHandle  the bos handle of the server to which the 
   *                      processes belong
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Server_stopAllProcesses(JNIEnv * env, jclass cls,
! 					      jint serverHandle)
! {
!     afs_status_t ast;
  
-     if (!bos_ProcessAllStop((void *)serverHandle, &ast)) {
- 	throwAFSException(env, ast);
- 	return;
-     }
  }
  
  /**
--- 1465,1481 ----
   * serverHandle  the bos handle of the server to which the 
   *                      processes belong
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Server_stopAllProcesses (JNIEnv *env, jclass cls, 
! 						  jlong serverHandle) {
! 
!   afs_status_t ast;
! 
!   if( !bos_ProcessAllStop( (void *) serverHandle, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
  }
  
  /**
***************
*** 1420,1443 ****
   *                      processes belong
   * restartBosServer   whether or not to restart the bos server as well
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Server_restartAllProcesses(JNIEnv * env, jclass cls,
! 						 jint serverHandle,
! 						 jboolean restartBosServer)
! {
!     afs_status_t ast;
!     bos_RestartBosServer_t rbs;
  
-     if (restartBosServer) {
- 	rbs = BOS_RESTART_BOS_SERVER;
-     } else {
- 	rbs = BOS_DONT_RESTART_BOS_SERVER;
-     }
- 
-     if (!bos_ProcessAllStopAndRestart((void *)serverHandle, rbs, &ast)) {
- 	throwAFSException(env, ast);
- 	return;
-     }
  }
  
  /**
--- 1487,1511 ----
   *                      processes belong
   * restartBosServer   whether or not to restart the bos server as well
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Server_restartAllProcesses (JNIEnv *env, jclass cls, 
! 						     jlong serverHandle, 
! 						   jboolean restartBosServer) {
! 
!   afs_status_t ast;
!   bos_RestartBosServer_t rbs;
!   
!   if( restartBosServer ) {
!     rbs = BOS_RESTART_BOS_SERVER;
!   } else {
!     rbs = BOS_DONT_RESTART_BOS_SERVER;
!   }
! 
!   if( !bos_ProcessAllStopAndRestart( (void *) serverHandle, rbs, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
  }
  
  /**
***************
*** 1450,1526 ****
   * serverHandle  the bos handle of the server to which the key belongs
   * jlogFile   the full path and name of the desired bos log
   */
! JNIEXPORT jstring JNICALL
! Java_org_openafs_jafs_Server_getLog(JNIEnv * env, jclass cls,
! 				    jint serverHandle, jstring jlogFile)
! {
      afs_status_t ast;
!     char *logFile;
      char *logData;
      unsigned long currInLogSize = 1;
      unsigned long currOutLogSize = 0;
      jstring logOut;
  
!     logData = (char *)malloc(sizeof(char) * currInLogSize);
!     if (logData == NULL) {
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return NULL;
      }
  
!     if (jlogFile != NULL) {
! 	logFile = getNativeString(env, jlogFile);
! 	if (logFile == NULL) {
! 	    free(logData);
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return NULL;
! 	}
!     } else {
! 	free(logData);
! 	throwAFSException(env, JAFSNULLARG);
! 	return NULL;
      }
  
      // check how big the log is . . .
!     if (!bos_LogGet
! 	((void *)serverHandle, logFile, &currOutLogSize, logData, &ast)) {
! 	// anything but not enough room in buffer
! 	if (ast != ADMMOREDATA) {
! 	    free(logData);
! 	    free(logFile);
! 	    throwAFSException(env, ast);
! 	    return NULL;
  	}
      }
!     // free previous allocation
!     free(logData);
  
      // increase log size (plus one for terminator)
      currInLogSize = currOutLogSize + 1;
- 
      // allocate buffer
!     logData = (char *)malloc(sizeof(char) * currInLogSize);
!     if (logData == NULL) {
! 	free(logFile);
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return NULL;
      }
      // get the log for real
!     if (!bos_LogGet
! 	((void *)serverHandle, logFile, &currOutLogSize, logData, &ast)) {
! 	free(logData);
! 	free(logFile);
! 	throwAFSException(env, ast);
  	return NULL;
      }
!     // NULL-terminate
      logData[currOutLogSize] == '\0';
  
      logOut = (*env)->NewStringUTF(env, logData);
! 
!     free(logData);
!     free(logFile);
! 
      return logOut;
  }
  
  
--- 1518,1606 ----
   * serverHandle  the bos handle of the server to which the key belongs
   * jlogFile   the full path and name of the desired bos log
   */
! JNIEXPORT jstring JNICALL 
! Java_org_openafs_jafs_Server_getLog(JNIEnv *env, jclass cls, 
! 				       jlong serverHandle, jstring jlogFile) {
! 
      afs_status_t ast;
!     const char *logFile;
      char *logData;
      unsigned long currInLogSize = 1;
      unsigned long currOutLogSize = 0;
      jstring logOut;
  
!     if( jlogFile != NULL ) {
!       logFile = (*env)->GetStringUTFChars(env, jlogFile, 0);
!       if( !logFile ) {
! 	  throwAFSException( env, JAFSADMNOMEM );
! 	  return;    
!       }
!     } else {
!       logFile = NULL;
      }
  
!     logData = (char *) malloc( sizeof(char)*currInLogSize );
!     if( !logData ) {
!       throwAFSException( env, JAFSADMNOMEM );
!       return;    
      }
  
      // check how big the log is . . .
!     if( !bos_LogGet( (void *) serverHandle, logFile, 
! 		     &currOutLogSize, logData, &ast ) ) {
!       // anything but not enough room in buffer
!       if( ast != ADMMOREDATA ) {
! 	free( logData );
! 	if( logFile != NULL ) { 
! 	  (*env)->ReleaseStringUTFChars(env, jlogFile, logFile);
  	}
+ 	throwAFSException( env, ast );
+ 	return NULL;
+       }
      }
! 
!     free( logData );
  
      // increase log size (plus one for terminator)
      currInLogSize = currOutLogSize + 1;
      // allocate buffer
!     logData = (char *) malloc( sizeof(char)*currInLogSize );
!     if( !logData ) {
!       throwAFSException( env, JAFSADMNOMEM );
!       return;    
      }
+ 
+     if( !logData ) {
+       // memory exception
+       if( logFile != NULL ) { 
+ 	  (*env)->ReleaseStringUTFChars(env, jlogFile, logFile);
+       }
+       throwAFSException( env, ast );
+       return NULL;
+     }
+ 
      // get the log for real
!     if( !bos_LogGet( (void *) serverHandle, logFile, &currOutLogSize, 
! 		     logData, &ast ) ) {
! 	free( logData );
! 	if( logFile != NULL ) { 
! 	  (*env)->ReleaseStringUTFChars(env, jlogFile, logFile);
! 	}
! 	(*env)->ReleaseStringUTFChars(env, jlogFile, logFile);
! 	throwAFSException( env, ast );
  	return NULL;
      }
!     
      logData[currOutLogSize] == '\0';
  
      logOut = (*env)->NewStringUTF(env, logData);
!     
!     free( logData );
!     if( logFile != NULL ) { 
!       (*env)->ReleaseStringUTFChars(env, jlogFile, logFile);
!     }
      return logOut;
+ 
  }
  
  
***************
*** 1532,1569 ****
   * serverHandle  the bos handle of the server to which the key belongs
   * jcommand     the text of the commmand to execute
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Server_executeCommand(JNIEnv * env, jclass cls,
! 					    jint serverHandle,
! 					    jstring jcommand)
! {
!     afs_status_t ast;
!     char *command;
  
-     if (jcommand != NULL) {
- 	command = getNativeString(env, jcommand);
- 	if (command == NULL) {
- 	    throwAFSException(env, JAFSADMNOMEM);
- 	    return;
- 	}
-     } else {
- 	throwAFSException(env, JAFSNULLARG);
- 	return;
-     }
- 
-     if (!bos_CommandExecute((void *)serverHandle, command, &ast)) {
- 	throwAFSException(env, ast);
-     }
- 
-     free(command);
  }
  
  // reclaim global memory being used by this portion
  JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Server_reclaimServerMemory(JNIEnv * env, jclass cls)
! {
!     if (serverCls) {
! 	(*env)->DeleteGlobalRef(env, serverCls);
! 	serverCls = 0;
!     }
  }
--- 1612,1676 ----
   * serverHandle  the bos handle of the server to which the key belongs
   * jcommand     the text of the commmand to execute
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Server_executeCommand (JNIEnv *env, jclass cls, 
! 						jlong serverHandle, 
! 						jstring jcommand) {
! 
!   afs_status_t ast;
!   const char *command;
! 
!   if( jcommand != NULL ) {
!     command = (*env)->GetStringUTFChars(env, jcommand, 0);
!     if( !command ) {
! 	throwAFSException( env, JAFSADMNOMEM );
! 	return;    
!     }
!   } else {
!     command = NULL;
!   }
! 
!   if( !bos_CommandExecute( (void *) serverHandle, command, &ast ) ) {
!     if( command != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jcommand, command);
!     }
!     throwAFSException( env, ast );
!     return;
!   }
! 
!   if( command != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, jcommand, command);
!   }
  
  }
  
  // reclaim global memory being used by this portion
  JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Server_reclaimServerMemory (JNIEnv *env, jclass cls) {
! 
!   if( serverCls ) {
!       (*env)->DeleteGlobalRef(env, serverCls);
!       serverCls = 0;
!   }
! 
  }
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
Index: openafs/src/JAVA/libjafs/User.c
diff -c openafs/src/JAVA/libjafs/User.c:1.3 openafs/src/JAVA/libjafs/User.c:1.3.2.1
*** openafs/src/JAVA/libjafs/User.c:1.3	Tue Jul 15 19:11:26 2003
--- openafs/src/JAVA/libjafs/User.c	Fri Oct 14 22:14:12 2005
***************
*** 68,73 ****
--- 68,74 ----
  extern jfieldID user_lockedUntilField;
  
  extern jclass groupCls;
+ //extern jfieldID group_cellHandleField;
  extern jfieldID group_nameField;
  extern jfieldID group_cachedInfoField;
  
***************
*** 80,186 ****
   * env      the Java environment
   * cls      the current Java class
   * cellHandle    the handle of the cell to which the user belongs
!  * jusername      the name of the user to create
   * jpassword      the password for the new user
   * uid     the user id to assign to the user (0 to have one 
   *                automatically assigned)
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_User_create(JNIEnv * env, jclass cls, jint cellHandle,
! 				  jstring jusername, jstring jpassword,
! 				  jint uid)
  {
!     afs_status_t ast;
!     char *username;
!     char *password;
!     kas_identity_p who = (kas_identity_p) malloc(sizeof(kas_identity_t));
! 
!     if (!who) {
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return;
!     }
!     // convert java strings
!     if (jusername != NULL) {
! 	username = getNativeString(env, jusername);
! 	if (username == NULL) {
! 	    free(who);
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	free(who);
! 	throwAFSException(env, JAFSNULLUSER);
! 	return;
!     }
! 
!     if (jpassword != NULL) {
! 	password = getNativeString(env, jpassword);
! 	if (password == NULL) {
! 	    free(who);
! 	    free(username);
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	free(who);
! 	free(username);
! 	throwAFSException(env, JAFSNULLPASS);
! 	return;
!     }
! 
!     // make sure the name is within the allowed bounds
!     if (strlen(username) > KAS_MAX_NAME_LEN) {
! 	free(who);
! 	free(username);
! 	free(password);
! 	throwAFSException(env, ADMPTSUSERNAMETOOLONG);
! 	return;
!     }
!     // make sure name doesn't have ":" in it
!     if (strchr(username, ':') != (int)NULL) {
! 	free(who);
! 	free(username);
! 	free(password);
! 	throwAFSException(env, PRBADNAM);
! 	return;
!     }
!     // make sure the id isn't negative
!     if (uid < 0) {
! 	free(who);
! 	free(username);
! 	free(password);
! 	// use the "bad arg" error code even though it's an ID exception.  
! 	// There isn't a bad user ID error code
! 	throwAFSException(env, PRBADARG);
! 	return;
!     }
! 
!     if (username != NULL) {
! 	internal_makeKasIdentity(username, who);
!     }
!     // create the kas entry
!     if (!kas_PrincipalCreate((void *)cellHandle, NULL, who, password, &ast)) {
! 	free(who);
! 	free(username);
! 	free(password);
! 	throwAFSException(env, ast);
! 	return;
!     }
!     // create the pts entry - if there's an error, make sure to delete 
!     // the kas entry 
!     if (!pts_UserCreate((void *)cellHandle, username, (int *)&uid, &ast)) {
! 	afs_status_t ast_kd;
! 	kas_PrincipalDelete((void *)cellHandle, NULL, who, &ast_kd);
! 	free(who);
! 	free(username);
! 	free(password);
! 	throwAFSException(env, ast);
! 	return;
!     }
! 
      free(who);
!     free(username);
!     free(password);
  }
  
  /**
--- 81,220 ----
   * env      the Java environment
   * cls      the current Java class
   * cellHandle    the handle of the cell to which the user belongs
!  * juserName      the name of the user to create
   * jpassword      the password for the new user
   * uid     the user id to assign to the user (0 to have one 
   *                automatically assigned)
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_User_create
!   (JNIEnv *env, jclass cls, jlong cellHandle, jstring juserName, 
!    jstring jpassword, jint uid )
  {
!   afs_status_t ast;
!   const char *userName;
!   const char *password;
!   kas_identity_p who = (kas_identity_p) malloc( sizeof(kas_identity_t) );
!   
!   if( !who ) {
!     throwAFSException( env, JAFSADMNOMEM );
!     return;    
!   }
! 
!   // convert java strings
!   if( juserName != NULL ) {
!     userName = (*env)->GetStringUTFChars(env, juserName, 0);
!     if( !userName ) {
!       free( who );
!       throwAFSException( env, JAFSADMNOMEM );
!       return;    
!     }
!   } else {
!     userName = NULL;
!   }
!   if( jpassword != NULL ) {
!     password = (*env)->GetStringUTFChars(env, jpassword, 0);
!     if( !password ) {
!       free( who );
!       if( userName != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, juserName, userName);
!       }
!       throwAFSException( env, JAFSADMNOMEM );
!       return;    
!     }
!   } else {
!     password = NULL;
!   }
! 
!   // make sure the name is within the allowed bounds
!   if( userName != NULL && strlen( userName ) > KAS_MAX_NAME_LEN ) {
!     free( who );
!     // release converted java strings
!     if( userName != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, juserName, userName);
!     }
!     if( password != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jpassword, password);
!     }
!     throwAFSException( env, ADMPTSUSERNAMETOOLONG  );
!     return;
!   }
! 
!   // make sure name doesn't have ":" in it
!   if( userName != NULL && strchr( userName, ':' ) != (int) NULL ) {
!       free(who);
!       // release converted java strings
!       if( userName != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, juserName, userName);
!       }
!       if( password != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, jpassword, password);
!       }
!       throwAFSException( env, PRBADNAM );
!       return;
!   }
! 
!   // make sure the id isn't negative
!   if( uid < 0 ) {
!       free(who);
!       // release converted java strings
!       if( userName != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, juserName, userName);
!       }
!       if( password != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, jpassword, password);
!       }
!       // use the "bad arg" error code even though it's an ID exception.  
!       // There isn't a bad user ID error code
!       throwAFSException( env, PRBADARG );
!       return;
!   }
! 
!   if( userName != NULL ) {
!     internal_makeKasIdentity( userName, who );
!   }
! 
!   // create the kas entry
!   if (!kas_PrincipalCreate( (void *) cellHandle, NULL, who, 
! 			    password, &ast ) ) {
      free(who);
!     // release converted java strings
!     if( userName != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, juserName, userName);
!     }
!     if( password != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jpassword, password);
!     }
!     throwAFSException( env, ast );
!     return;
!   } 
! 
!   // create the pts entry - if there's an error, make sure to delete 
!   // the kas entry 
!   if( !pts_UserCreate( (void *) cellHandle, userName, (int *) &uid, &ast ) ) {
!     afs_status_t ast_kd;
!     kas_PrincipalDelete( (void *) cellHandle, NULL, who, &ast_kd );
!     free( who );
!     // release converted java strings
!     if( userName != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, juserName, userName);
!     }
!     if( password != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jpassword, password);
!     }
!     throwAFSException( env, ast );
!     return;
!   }
! 
!   free( who );
!   // release converted java strings
!   if( userName != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, juserName, userName);
!   }
!   if( password != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, jpassword, password);
!   }
! 
  }
  
  /**
***************
*** 191,261 ****
   * env      the Java environment
   * cls      the current Java class
   * cellHandle    the handle of the cell to which the user belongs
!  * jusername      the name of the user to delete
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_User_delete(JNIEnv * env, jclass cls, jint cellHandle,
! 				  jstring jusername)
  {
!     afs_status_t ast;
!     char *username;
!     kas_identity_p who = (kas_identity_p) malloc(sizeof(kas_identity_t));
!     int kas;
! 
!     if (!who) {
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return;
!     }
! 
!     if (jusername != NULL) {
! 	username = getNativeString(env, jusername);
! 	if (username == NULL) {
! 	    free(who);
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	free(who);
! 	throwAFSException(env, JAFSNULLUSER);
! 	return;
!     }
! 
!     // make sure the name is within the allowed bounds
!     if (strlen(username) > KAS_MAX_NAME_LEN) {
! 	free(who);
! 	free(username);
! 	throwAFSException(env, ADMPTSUSERNAMETOOLONG);
! 	return;
!     }
! 
!     internal_makeKasIdentity(username, who);
! 
!     // delete the kas entry
!     if (!kas_PrincipalDelete((void *)cellHandle, NULL, who, &ast)) {
! 	if (ast != KANOENT) {
! 	    free(who);
! 	    free(username);
! 	    throwAFSException(env, ast);
! 	    return;
! 	} else {
! 	    kas = FALSE;
! 	}
!     }
!     //delete the pts entry
!     if (!pts_UserDelete((void *)cellHandle, username, &ast)) {
! 	// throw exception if there was no such pts user only if there was 
! 	// also no such kas user
! 	if ((ast == ADMPTSFAILEDNAMETRANSLATE && !kas)
! 	    || ast != ADMPTSFAILEDNAMETRANSLATE) {
! 	    free(who);
! 	    free(username);
! 	    throwAFSException(env, ast);
! 	    return;
! 	}
!     }
! 
!     free(who);
!     free(username);
  }
  
  /**
--- 225,305 ----
   * env      the Java environment
   * cls      the current Java class
   * cellHandle    the handle of the cell to which the user belongs
!  * juserName      the name of the user to delete
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_User_delete
!   (JNIEnv *env, jclass cls, jlong cellHandle, jstring juserName )
  {
!   afs_status_t ast;
!   const char *userName;
!   kas_identity_p who = (kas_identity_p) malloc( sizeof(kas_identity_t) );  
!   int kas;
!   
!   if( !who ) {
!     throwAFSException( env, JAFSADMNOMEM );
!     return;    
!   }
! 
!   if( juserName != NULL ) {
!       userName = (*env)->GetStringUTFChars(env, juserName, 0);
!       if( !userName ) {
! 	free( who );
! 	throwAFSException( env, JAFSADMNOMEM );
! 	return;    
!       }
!   } else {
!       userName = NULL;
!   }
! 
!   // make sure the name is within the allowed bounds
!   if( userName != NULL && strlen( userName ) > KAS_MAX_NAME_LEN ) {
!     free( who );
!     if( userName != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, juserName, userName);
!     }
!     throwAFSException( env, ADMPTSUSERNAMETOOLONG  );
!     return;
!   }
! 
!   if( userName != NULL ) {
!       internal_makeKasIdentity( userName, who );
!   }
! 
!   // delete the kas entry
!   if( !kas_PrincipalDelete( (void *) cellHandle, NULL, who, &ast ) ) {
!       if( ast != KANOENT ) {
! 	  free(who);
! 	  if( userName != NULL ) {
! 	      (*env)->ReleaseStringUTFChars(env, juserName, userName);
! 	  }
! 	  throwAFSException( env, ast );
! 	  return;
!       } else {
! 	  kas = FALSE;
!       }
!   }
! 
!   //delete the pts entry
!   if( !pts_UserDelete( (void *) cellHandle, userName, &ast ) ) {
!       // throw exception if there was no such pts user only if there was 
!       // also no such kas user
!       if( (ast == ADMPTSFAILEDNAMETRANSLATE && !kas ) || 
! 	  ast != ADMPTSFAILEDNAMETRANSLATE ) {
! 	  free( who );
! 	  if( userName != NULL ) {
! 	      (*env)->ReleaseStringUTFChars(env, juserName, userName);
! 	  }
! 	  throwAFSException( env, ast );
! 	  return;
!       }
!   }
! 
!   free( who );
!   // release converted java strings
!   if( userName != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, juserName, userName);
!   }
  }
  
  /**
***************
*** 264,316 ****
   * env      the Java environment
   * cls      the current Java class
   * cellHandle    the handle of the cell to which the user belongs
!  * jusername      the name of the user to unlock
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_User_unlock(JNIEnv * env, jclass cls, jint cellHandle,
! 				  jstring jusername)
  {
!     afs_status_t ast;
!     char *username;
!     kas_identity_p who = (kas_identity_p) malloc(sizeof(kas_identity_t));
! 
!     if (!who) {
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return;
!     }
!     // convert java strings
!     if (jusername != NULL) {
! 	username = getNativeString(env, jusername);
! 	if (username == NULL) {
! 	    free(who);
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	free(who);
! 	throwAFSException(env, JAFSNULLUSER);
! 	return;
!     }
! 
!     // make sure the name is within the allowed bounds
!     if (strlen(username) > KAS_MAX_NAME_LEN) {
! 	free(who);
! 	free(username);
! 	throwAFSException(env, ADMPTSUSERNAMETOOLONG);
! 	return;
!     }
! 
!     internal_makeKasIdentity(username, who);
! 
!     if (!kas_PrincipalUnlock((void *)cellHandle, NULL, who, &ast)) {
! 	free(who);
! 	free(username);
! 	throwAFSException(env, ast);
! 	return;
!     }
! 
!     free(who);
!     free(username);
  }
  
  /**
--- 308,367 ----
   * env      the Java environment
   * cls      the current Java class
   * cellHandle    the handle of the cell to which the user belongs
!  * juserName      the name of the user to unlock
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_User_unlock
!   (JNIEnv *env, jclass cls, jlong cellHandle, jstring juserName )
  {
!   afs_status_t ast;
!   const char *userName;
!   kas_identity_p who = (kas_identity_p) malloc( sizeof(kas_identity_t) );  
!   
!   if( !who ) {
!     throwAFSException( env, JAFSADMNOMEM );
!     return;    
!   }
! 
!   // convert java strings
!   if( juserName != NULL ) {
!       userName = (*env)->GetStringUTFChars(env, juserName, 0);
!     if( !userName ) {
! 	throwAFSException( env, JAFSADMNOMEM );
! 	return;    
!     }
!   } else {
!       userName = NULL;
!   }
! 
!   // make sure the name is within the allowed bounds
!   if( userName != NULL && strlen( userName ) > KAS_MAX_NAME_LEN ) {
!     free( who );
!     if( userName != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, juserName, userName);
!     }
!     throwAFSException( env, ADMPTSUSERNAMETOOLONG  );
!     return;
!   }  
! 
!   if( userName != NULL ) {
!     internal_makeKasIdentity( userName, who );
!   }
! 
!   if( !kas_PrincipalUnlock( (void *) cellHandle, NULL, who, &ast ) ) {
!     free( who );
!     if( userName != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, juserName, userName);
!     }
!     throwAFSException( env, ast );
!     return;
!   }
! 
!   free( who );
!   // release converted java strings
!   if( userName != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, juserName, userName);
!   }
  }
  
  /**
***************
*** 322,528 ****
   * name      the name of the user for which to get the info
   * user      the User object to populate with the info
   */
! void
! getUserInfoChar(JNIEnv * env, int cellHandle, const char *name, jobject user)
  {
!     jstring jowner;
!     jstring jcreator;
!     jstring jlastModName;
!     jstring jencryptionKey;
!     jboolean pts;
!     jboolean kas;
!     pts_UserEntry_t ptsEntry;
!     afs_status_t ast;
!     kas_identity_p who = (kas_identity_p) malloc(sizeof(kas_identity_t));
!     kas_principalEntry_t kasEntry;
!     unsigned int lockedUntil;
! 
!     if (!who) {
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return;
!     }
!     // make sure the name is within the allowed bounds
!     if (name != NULL && strlen(name) > KAS_MAX_NAME_LEN) {
! 	free(who);
! 	throwAFSException(env, ADMPTSUSERNAMETOOLONG);
  	return;
      }
! 
!     if (name != NULL) {
! 	internal_makeKasIdentity(name, who);
!     }
!     // get all the field ids, if you haven't done so already
!     if (userCls == 0) {
! 	internal_getUserClass(env, user);
!     }
!     // get the pts entry
!     if (!pts_UserGet((void *)cellHandle, name, &ptsEntry, &ast)) {
! 	// if the user has no pts ptsEntry
! 	if (ast == ADMPTSFAILEDNAMETRANSLATE) {
! 	    pts = FALSE;
! 	} else {
! 	    free(who);
! 	    throwAFSException(env, ast);
  	    return;
- 	}
-     } else {
- 	pts = TRUE;
-     }
- 
- 
-     // get the kas entry
-     if (!kas_PrincipalGet((void *)cellHandle, NULL, who, &kasEntry, &ast)) {
- 	// no kas entry
- 	if (ast == KANOENT) {
- 	    if (!pts) {
- 		free(who);
- 		throwAFSException(env, ast);
- 		return;
- 	    } else {
- 		kas = FALSE;
- 	    }
- 	    // other
  	} else {
! 	    free(who);
! 	    throwAFSException(env, ast);
! 	    return;
  	}
      } else {
! 	kas = TRUE;
!     }
! 
!     // get the lock status
!     if (kas
! 	&& !kas_PrincipalLockStatusGet((void *)cellHandle, NULL, who,
! 				       &lockedUntil, &ast)) {
! 	free(who);
! 	throwAFSException(env, ast);
  	return;
      }
! 
!     (*env)->SetBooleanField(env, user, user_ptsField, pts);
!     (*env)->SetBooleanField(env, user, user_kasField, kas);
! 
!     // set the pts fields
!     if (pts) {
! 	(*env)->SetIntField(env, user, user_nameUidField, ptsEntry.nameUid);
! 	(*env)->SetIntField(env, user, user_ownerUidField, ptsEntry.ownerUid);
! 	(*env)->SetIntField(env, user, user_creatorUidField,
! 			    ptsEntry.creatorUid);
! 	(*env)->SetIntField(env, user, user_groupCreationQuotaField,
! 			    ptsEntry.groupCreationQuota);
! 	(*env)->SetIntField(env, user, user_groupMembershipCountField,
! 			    ptsEntry.groupMembershipCount);
! 
! 	if (ptsEntry.listStatus == PTS_USER_OWNER_ACCESS) {
! 	    (*env)->SetIntField(env, user, user_listStatusField,
! 				org_openafs_jafs_User_USER_OWNER_ACCESS);
! 	} else {
! 	    (*env)->SetIntField(env, user, user_listStatusField,
! 				org_openafs_jafs_User_USER_ANYUSER_ACCESS);
! 	}
! 	if (ptsEntry.listGroupsOwned == PTS_USER_OWNER_ACCESS) {
! 	    (*env)->SetIntField(env, user, user_listGroupsOwnedField,
! 				org_openafs_jafs_User_USER_OWNER_ACCESS);
! 	} else {
! 	    (*env)->SetIntField(env, user, user_listGroupsOwnedField,
! 				org_openafs_jafs_User_USER_ANYUSER_ACCESS);
! 	}
! 	if (ptsEntry.listMembership == PTS_USER_OWNER_ACCESS) {
! 	    (*env)->SetIntField(env, user, user_listMembershipField,
! 				org_openafs_jafs_User_USER_OWNER_ACCESS);
! 	} else {
! 	    (*env)->SetIntField(env, user, user_listMembershipField,
! 				org_openafs_jafs_User_USER_ANYUSER_ACCESS);
! 	}
! 
! 	jowner = (*env)->NewStringUTF(env, ptsEntry.owner);
! 	jcreator = (*env)->NewStringUTF(env, ptsEntry.creator);
! 
! 	(*env)->SetObjectField(env, user, user_ownerField, jowner);
! 	(*env)->SetObjectField(env, user, user_creatorField, jcreator);
! 
!     }
!     // set the kas fields
!     if (kas) {
! 	char *convertedKey;
! 	int i;
! 	if (kasEntry.adminSetting == KAS_ADMIN) {
! 	    (*env)->SetIntField(env, user, user_adminSettingField,
! 				org_openafs_jafs_User_ADMIN);
! 	} else {
! 	    (*env)->SetIntField(env, user, user_adminSettingField,
! 				org_openafs_jafs_User_NO_ADMIN);
! 	}
! 	if (kasEntry.tgsSetting == TGS) {
! 	    (*env)->SetIntField(env, user, user_tgsSettingField,
! 				org_openafs_jafs_User_GRANT_TICKETS);
! 	} else {
! 	    (*env)->SetIntField(env, user, user_tgsSettingField,
! 				org_openafs_jafs_User_NO_GRANT_TICKETS);
! 	}
! 	if (kasEntry.encSetting != NO_ENCRYPT) {
! 	    (*env)->SetIntField(env, user, user_encSettingField,
! 				org_openafs_jafs_User_ENCRYPT);
! 	} else {
! 	    (*env)->SetIntField(env, user, user_encSettingField,
! 				org_openafs_jafs_User_NO_ENCRYPT);
! 	}
! 	if (kasEntry.cpwSetting == CHANGE_PASSWORD) {
! 	    (*env)->SetIntField(env, user, user_cpwSettingField,
! 				org_openafs_jafs_User_CHANGE_PASSWORD);
! 	} else {
! 	    (*env)->SetIntField(env, user, user_cpwSettingField,
! 				org_openafs_jafs_User_NO_CHANGE_PASSWORD);
! 	}
! 	if (kasEntry.rpwSetting == REUSE_PASSWORD) {
! 	    (*env)->SetIntField(env, user, user_rpwSettingField,
! 				org_openafs_jafs_User_REUSE_PASSWORD);
! 	} else {
! 	    (*env)->SetIntField(env, user, user_rpwSettingField,
! 				org_openafs_jafs_User_NO_REUSE_PASSWORD);
! 	}
! 	(*env)->SetIntField(env, user, user_userExpirationField,
! 			    kasEntry.userExpiration);
! 	(*env)->SetIntField(env, user, user_lastModTimeField,
! 			    kasEntry.lastModTime);
! 	(*env)->SetIntField(env, user, user_lastChangePasswordTimeField,
! 			    kasEntry.lastChangePasswordTime);
! 	(*env)->SetIntField(env, user, user_maxTicketLifetimeField,
! 			    kasEntry.maxTicketLifetime);
! 	(*env)->SetIntField(env, user, user_keyVersionField,
! 			    kasEntry.keyVersion);
! 	(*env)->SetLongField(env, user, user_keyCheckSumField,
! 			     (unsigned int)kasEntry.keyCheckSum);
! 	(*env)->SetIntField(env, user, user_daysToPasswordExpireField,
! 			    kasEntry.daysToPasswordExpire);
! 	(*env)->SetIntField(env, user, user_failLoginCountField,
! 			    kasEntry.failLoginCount);
! 	(*env)->SetIntField(env, user, user_lockTimeField, kasEntry.lockTime);
! 	(*env)->SetIntField(env, user, user_lockedUntilField, lockedUntil);
! 
! 	jlastModName =
! 	    (*env)->NewStringUTF(env, kasEntry.lastModPrincipal.principal);
! 	(*env)->SetObjectField(env, user, user_lastModNameField,
! 			       jlastModName);
! 
! 	convertedKey =
! 	    (char *)malloc(sizeof(char *) *
! 			   (sizeof(kasEntry.key.key) * 4 + 1));
! 	if (!convertedKey) {
! 	    free(who);
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
! 	for (i = 0; i < sizeof(kasEntry.key.key); i++) {
! 	    sprintf(&(convertedKey[i * 4]), "\\%0.3o", kasEntry.key.key[i]);
! 	}
! 	jencryptionKey = (*env)->NewStringUTF(env, convertedKey);
! 	(*env)->SetObjectField(env, user, user_encryptionKeyField,
! 			       jencryptionKey);
! 	free(convertedKey);
!     }
!     free(who);
  }
  
  /**
--- 373,579 ----
   * name      the name of the user for which to get the info
   * user      the User object to populate with the info
   */
! void getUserInfoChar
!   (JNIEnv *env, void *cellHandle, const char *name, jobject user)
  {
!   jstring jowner;
!   jstring jcreator;
!   jstring jlastModName;
!   jstring jencryptionKey;
!   jboolean pts;
!   jboolean kas;
!   pts_UserEntry_t ptsEntry;
!   afs_status_t ast;
!   kas_identity_p who = (kas_identity_p) malloc( sizeof(kas_identity_t) );
!   kas_principalEntry_t kasEntry;
!   unsigned int lockedUntil;
! 
!   if( !who ) {
!     throwAFSException( env, JAFSADMNOMEM );
!     return;    
!   }
! 
!   // make sure the name is within the allowed bounds
!   if( name != NULL && strlen( name ) > KAS_MAX_NAME_LEN ) {
!     free( who );
!     throwAFSException( env, ADMPTSUSERNAMETOOLONG );
!     return;
!   }
!   
!   if( name != NULL ) {
!       internal_makeKasIdentity( name, who );
!   }
! 
!   // get all the field ids, if you haven't done so already
!   if( userCls == 0 ) {
!     internal_getUserClass( env, user );
!   }
! 
!   // get the pts entry
!   if ( !pts_UserGet( cellHandle, name, &ptsEntry, &ast ) ) {
!     // if the user has no pts ptsEntry
!     if( ast == ADMPTSFAILEDNAMETRANSLATE ) {
! 	pts = FALSE;	
!     } else {
! 	free( who );
! 	throwAFSException( env, ast );
  	return;
      }
!   } else {
!       pts = TRUE;
!   }
!   
! 
!   // get the kas entry
!   if( !kas_PrincipalGet( cellHandle, NULL, who, &kasEntry, &ast ) ) {
!     // no kas entry
!     if( ast == KANOENT ) { 
! 	if( !pts ) {
! 	    free( who );
! 	    throwAFSException( env, ast );
  	    return;
  	} else {
! 	    kas = FALSE;
  	}
+     // other
      } else {
! 	free( who );
! 	throwAFSException( env, ast );
  	return;
      }
!   } else {
!       kas = TRUE;
!   }
! 
!   // get the lock status
!   if( kas && !kas_PrincipalLockStatusGet( cellHandle, NULL, who, 
! 					  &lockedUntil, &ast ) ) {
!     free( who );
!     throwAFSException( env, ast );
!     return;
!   }
! 
!   (*env)->SetBooleanField(env, user, user_ptsField, pts);
!   (*env)->SetBooleanField(env, user, user_kasField, kas);
! 
!   // set the pts fields
!   if( pts ) {
!       (*env)->SetIntField(env, user, user_nameUidField, ptsEntry.nameUid);
!       (*env)->SetIntField(env, user, user_ownerUidField, ptsEntry.ownerUid);
!       (*env)->SetIntField(env, user, user_creatorUidField, 
! 			  ptsEntry.creatorUid);
!       (*env)->SetIntField(env, user, user_groupCreationQuotaField, 
! 			  ptsEntry.groupCreationQuota);
!       (*env)->SetIntField(env, user, user_groupMembershipCountField, 
! 			  ptsEntry.groupMembershipCount);
!       
!       if( ptsEntry.listStatus == PTS_USER_OWNER_ACCESS ) {
! 	  (*env)->SetIntField(env, user, user_listStatusField, 
! 			      org_openafs_jafs_User_USER_OWNER_ACCESS);
!       } else {
! 	  (*env)->SetIntField(env, user, user_listStatusField, 
! 			      org_openafs_jafs_User_USER_ANYUSER_ACCESS);
!       }
!       if( ptsEntry.listGroupsOwned == PTS_USER_OWNER_ACCESS ) {
! 	  (*env)->SetIntField(env, user, user_listGroupsOwnedField, 
! 			      org_openafs_jafs_User_USER_OWNER_ACCESS);
!       } else {
! 	  (*env)->SetIntField(env, user, user_listGroupsOwnedField, 
! 			      org_openafs_jafs_User_USER_ANYUSER_ACCESS);
!       }
!       if( ptsEntry.listMembership == PTS_USER_OWNER_ACCESS ) {
! 	  (*env)->SetIntField(env, user, user_listMembershipField, 
! 			      org_openafs_jafs_User_USER_OWNER_ACCESS);
!       } else {
! 	  (*env)->SetIntField(env, user, user_listMembershipField, 
! 			      org_openafs_jafs_User_USER_ANYUSER_ACCESS);
!       }
!       
!       jowner = (*env)->NewStringUTF(env, ptsEntry.owner);
!       jcreator =  (*env)->NewStringUTF(env, ptsEntry.creator);
!       
!       (*env)->SetObjectField(env, user, user_ownerField, jowner);
!       (*env)->SetObjectField(env, user, user_creatorField, jcreator);
! 
!   }
! 
!   // set the kas fields
!   if( kas ) {
!       char *convertedKey;
!       int i;
!       if( kasEntry.adminSetting == KAS_ADMIN ) {
! 	  (*env)->SetIntField(env, user, user_adminSettingField, 
! 			      org_openafs_jafs_User_ADMIN);
!       } else {
! 	  (*env)->SetIntField(env, user, user_adminSettingField, 
! 			      org_openafs_jafs_User_NO_ADMIN);
!       }
!       if( kasEntry.tgsSetting == TGS ) {
! 	  (*env)->SetIntField(env, user, user_tgsSettingField, 
! 			      org_openafs_jafs_User_GRANT_TICKETS);
!       } else {
! 	  (*env)->SetIntField(env, user, user_tgsSettingField, 
! 			      org_openafs_jafs_User_NO_GRANT_TICKETS);
!       }
!       if( kasEntry.encSetting != NO_ENCRYPT ) {
! 	  (*env)->SetIntField(env, user, user_encSettingField, 
! 			      org_openafs_jafs_User_ENCRYPT);
!       } else {
! 	  (*env)->SetIntField(env, user, user_encSettingField, 
! 			      org_openafs_jafs_User_NO_ENCRYPT);
!       }
!       if( kasEntry.cpwSetting == CHANGE_PASSWORD ) {
! 	  (*env)->SetIntField(env, user, user_cpwSettingField, 
! 			      org_openafs_jafs_User_CHANGE_PASSWORD);
!       } else {
! 	  (*env)->SetIntField(env, user, user_cpwSettingField, 
! 			      org_openafs_jafs_User_NO_CHANGE_PASSWORD);
!       }
!       if( kasEntry.rpwSetting == REUSE_PASSWORD ) {
! 	  (*env)->SetIntField(env, user, user_rpwSettingField, 
! 			      org_openafs_jafs_User_REUSE_PASSWORD);
!       } else {
! 	  (*env)->SetIntField(env, user, user_rpwSettingField, 
! 			      org_openafs_jafs_User_NO_REUSE_PASSWORD);
!       }
!       (*env)->SetIntField(env, user, user_userExpirationField, 
! 			  kasEntry.userExpiration);
!       (*env)->SetIntField(env, user, user_lastModTimeField, 
! 			  kasEntry.lastModTime);
!       (*env)->SetIntField(env, user, user_lastChangePasswordTimeField, 
! 			  kasEntry.lastChangePasswordTime);
!       (*env)->SetIntField(env, user, user_maxTicketLifetimeField, 
! 			  kasEntry.maxTicketLifetime);
!       (*env)->SetIntField(env, user, user_keyVersionField, 
! 			  kasEntry.keyVersion);
!       (*env)->SetLongField(env, user, user_keyCheckSumField, 
! 			   (unsigned int) kasEntry.keyCheckSum);
!       (*env)->SetIntField(env, user, user_daysToPasswordExpireField, 
! 			  kasEntry.daysToPasswordExpire);
!       (*env)->SetIntField(env, user, user_failLoginCountField, 
! 			  kasEntry.failLoginCount);
!       (*env)->SetIntField(env, user, user_lockTimeField, kasEntry.lockTime);
!       (*env)->SetIntField(env, user, user_lockedUntilField, lockedUntil);
!       
!       jlastModName = (*env)->NewStringUTF(env, 
! 					  kasEntry.lastModPrincipal.principal);
!       (*env)->SetObjectField(env, user, user_lastModNameField, jlastModName);
! 
!       convertedKey = (char *) malloc( sizeof(char *)*
! 				      (sizeof(kasEntry.key.key)*4+1) );
!       if( !convertedKey ) {
! 	throwAFSException( env, JAFSADMNOMEM );
! 	return;    
!       }
!       for( i = 0; i < sizeof(kasEntry.key.key); i++ ) {
! 	sprintf( &(convertedKey[i*4]), "\\%0.3o", kasEntry.key.key[i] );
!       }
!       jencryptionKey =  (*env)->NewStringUTF(env, convertedKey);
!       (*env)->SetObjectField(env, user, user_encryptionKeyField, 
! 			     jencryptionKey);
!       free( convertedKey );
!   }
!   free(who);
  }
  
  /**
***************
*** 536,569 ****
   * user     the User object in which to fill in the 
   *                 information
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_User_getUserInfo(JNIEnv * env, jclass cls,
! 				       jint cellHandle, jstring jname,
! 				       jobject user)
  {
!     char *name;
! 
!     if (jname != NULL) {
! 	name = getNativeString(env, jname);
! 	if (!name) {
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	throwAFSException(env, JAFSNULLUSER);
! 	return;
!     }
! 
!     getUserInfoChar(env, cellHandle, name, user);
! 
!     // get class fields if need be
!     if (userCls == 0) {
! 	internal_getUserClass(env, user);
!     }
!     // set name in case blank object
!     (*env)->SetObjectField(env, user, user_nameField, jname);
  
!     free(name);
  }
  
  /**
--- 587,621 ----
   * user     the User object in which to fill in the 
   *                 information
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_User_getUserInfo
!   (JNIEnv *env, jclass cls, jlong cellHandle, jstring jname, jobject user)
  {
!   const char *name;
  
!   if( jname != NULL ) {
!       name = (*env)->GetStringUTFChars(env, jname, 0);
!     if( !name ) {
! 	throwAFSException( env, JAFSADMNOMEM );
! 	return;    
!     }
!   } else {
!       name = NULL;
!   }
! 
!   getUserInfoChar( env, cellHandle, name, user );
!  
!   // get class fields if need be
!   if( userCls == 0 ) {
!     internal_getUserClass( env, user );
!   }
!   
!   // set name in case blank object
!   (*env)->SetObjectField(env, user, user_nameField, jname);
!   
!   if( name != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jname, name);
!   }      
  }
  
  /**
***************
*** 577,727 ****
   * user  the User object containing the desired 
   *                 information
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_User_setUserInfo(JNIEnv * env, jclass cls,
! 				       jint cellHandle, jstring jname,
! 				       jobject user)
  {
!     char *name;
!     kas_identity_p who = (kas_identity_p) malloc(sizeof(kas_identity_t));
!     pts_UserUpdateEntry_t ptsEntry;
!     afs_status_t ast;
!     kas_admin_t isAdmin;
!     kas_tgs_t grantTickets;
!     kas_enc_t canEncrypt;
!     kas_cpw_t canChangePassword;
!     kas_rpw_t passwordReuse;
!     unsigned int expirationDate;
!     unsigned int maxTicketLifetime;
!     unsigned int passwordExpires;
!     unsigned int failedPasswordAttempts;
!     unsigned int failedPasswordLockTime;
!     int kas;
!     int pts;
! 
!     if (!who) {
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return;
!     }
! 
!     if (jname != NULL) {
! 	name = getNativeString(env, jname);
! 	if (name == NULL) {
! 	    free(who);
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	free(who);
! 	throwAFSException(env, JAFSNULLUSER);
! 	return;
!     }
! 
!     // make sure the name is within the allowed bounds
!     if (strlen(name) > KAS_MAX_NAME_LEN) {
! 	free(who);
! 	free(name);
! 	throwAFSException(env, ADMPTSUSERNAMETOOLONG);
! 	return;
!     }
! 
!     internal_makeKasIdentity(name, who);
! 
!     // get class fields if need be
!     if (userCls == 0) {
! 	internal_getUserClass(env, user);
!     }
! 
!     kas = (*env)->GetBooleanField(env, user, user_kasField);
!     pts = (*env)->GetBooleanField(env, user, user_ptsField);
! 
!     if (pts) {
! 	// set the pts fields: 
! 	ptsEntry.flag =
! 	    PTS_USER_UPDATE_GROUP_CREATE_QUOTA | PTS_USER_UPDATE_PERMISSIONS;
! 	ptsEntry.groupCreationQuota =
! 	    (*env)->GetIntField(env, user, user_groupCreationQuotaField);
! 	if ((*env)->GetIntField(env, user, user_listStatusField) ==
! 	    org_openafs_jafs_User_USER_OWNER_ACCESS) {
! 	    ptsEntry.listStatus = PTS_USER_OWNER_ACCESS;
! 	} else {
! 	    ptsEntry.listStatus = PTS_USER_ANYUSER_ACCESS;
! 	}
! 	if ((*env)->GetIntField(env, user, user_listGroupsOwnedField) ==
! 	    org_openafs_jafs_User_USER_OWNER_ACCESS) {
! 	    ptsEntry.listGroupsOwned = PTS_USER_OWNER_ACCESS;
! 	} else {
! 	    ptsEntry.listGroupsOwned = PTS_USER_ANYUSER_ACCESS;
! 	}
! 	if ((*env)->GetIntField(env, user, user_listMembershipField) ==
! 	    org_openafs_jafs_User_USER_OWNER_ACCESS) {
! 	    ptsEntry.listMembership = PTS_USER_OWNER_ACCESS;
! 	} else {
! 	    ptsEntry.listMembership = PTS_USER_ANYUSER_ACCESS;
! 	}
! 	if (!pts_UserModify((void *)cellHandle, name, &ptsEntry, &ast)) {
! 	    free(who);
! 	    free(name);
! 	    throwAFSException(env, ast);
! 	    return;
! 	}
!     }
! 
!     if (kas) {
! 	// set the kas fields:
! 	if ((*env)->GetIntField(env, user, user_adminSettingField) ==
! 	    org_openafs_jafs_User_ADMIN) {
! 	    isAdmin = KAS_ADMIN;
! 	} else {
! 	    isAdmin = NO_KAS_ADMIN;
! 	}
! 	if ((*env)->GetIntField(env, user, user_tgsSettingField) ==
! 	    org_openafs_jafs_User_GRANT_TICKETS) {
! 	    grantTickets = TGS;
! 	} else {
! 	    grantTickets = NO_TGS;
! 	}
! 	if ((*env)->GetIntField(env, user, user_encSettingField) ==
! 	    org_openafs_jafs_User_ENCRYPT) {
! 	    canEncrypt = 0;
! 	} else {
! 	    canEncrypt = NO_ENCRYPT;
! 	}
! 	if ((*env)->GetIntField(env, user, user_cpwSettingField) ==
! 	    org_openafs_jafs_User_CHANGE_PASSWORD) {
! 	    canChangePassword = CHANGE_PASSWORD;
! 	} else {
! 	    canChangePassword = NO_CHANGE_PASSWORD;
! 	}
! 	if ((*env)->GetIntField(env, user, user_rpwSettingField) ==
! 	    org_openafs_jafs_User_REUSE_PASSWORD) {
! 	    passwordReuse = REUSE_PASSWORD;
! 	} else {
! 	    passwordReuse = NO_REUSE_PASSWORD;
! 	}
! 	expirationDate =
! 	    (*env)->GetIntField(env, user, user_userExpirationField);
! 	maxTicketLifetime =
! 	    (*env)->GetIntField(env, user, user_maxTicketLifetimeField);
! 	passwordExpires =
! 	    (*env)->GetIntField(env, user, user_daysToPasswordExpireField);
! 	failedPasswordAttempts =
! 	    (*env)->GetIntField(env, user, user_failLoginCountField);
! 	failedPasswordLockTime =
! 	    (*env)->GetIntField(env, user, user_lockTimeField);
! 
! 
! 	if (!kas_PrincipalFieldsSet
! 	    ((void *)cellHandle, NULL, who, &isAdmin, &grantTickets,
! 	     &canEncrypt, &canChangePassword, &expirationDate,
! 	     &maxTicketLifetime, &passwordExpires, &passwordReuse,
! 	     &failedPasswordAttempts, &failedPasswordLockTime, &ast)) {
! 	    throwAFSException(env, ast);
! 	}
!     }
! 
!     free(who);
!     free(name);
  }
  
  /**
--- 629,786 ----
   * user  the User object containing the desired 
   *                 information
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_User_setUserInfo
!   (JNIEnv *env, jclass cls, jlong cellHandle, jstring jname, jobject user )
  {
!   const char *name;
!   kas_identity_p who = (kas_identity_p) malloc( sizeof(kas_identity_t) );
!   pts_UserUpdateEntry_t ptsEntry;
!   afs_status_t ast;
!   kas_admin_t isAdmin;
!   kas_tgs_t grantTickets;
!   kas_enc_t canEncrypt;
!   kas_cpw_t canChangePassword;
!   kas_rpw_t passwordReuse;
!   unsigned int expirationDate;
!   unsigned int maxTicketLifetime;
!   unsigned int passwordExpires;
!   unsigned int failedPasswordAttempts;
!   unsigned int failedPasswordLockTime;
!   int kas;
!   int pts;
! 
!   if( !who ) {
!     throwAFSException( env, JAFSADMNOMEM );
!     return;    
!   }
! 
!   if( jname != NULL ) {
!       name = (*env)->GetStringUTFChars(env, jname, 0);
!     if( !name ) {
! 	throwAFSException( env, JAFSADMNOMEM );
! 	return;    
!     }
!   } else {
!       name = NULL;
!   }
! 
!   // make sure the name is within the allowed bounds
!   if( name != NULL && strlen( name ) > KAS_MAX_NAME_LEN ) {
!     free( who );
!     (*env)->ReleaseStringUTFChars(env, jname, name);
!     throwAFSException( env, ADMPTSUSERNAMETOOLONG );
!     return;
!   }
! 
!   if( name != NULL ) {
!       internal_makeKasIdentity( name, who );
!   }
! 
!   // get class fields if need be
!   if( userCls == 0 ) {
!     internal_getUserClass( env, user );
!   }
! 
!   kas = (*env)->GetBooleanField(env, user, user_kasField);
!   pts = (*env)->GetBooleanField(env, user, user_ptsField);
! 
!   if( pts ) {
!       // set the pts fields: 
!       ptsEntry.flag = PTS_USER_UPDATE_GROUP_CREATE_QUOTA | 
! 	PTS_USER_UPDATE_PERMISSIONS;
!       ptsEntry.groupCreationQuota = 
! 	(*env)->GetIntField(env, user, user_groupCreationQuotaField);
!       if( (*env)->GetIntField(env, user, user_listStatusField) == 
! 	  org_openafs_jafs_User_USER_OWNER_ACCESS ) {
! 	  ptsEntry.listStatus = PTS_USER_OWNER_ACCESS;
!       } else {
! 	  ptsEntry.listStatus = PTS_USER_ANYUSER_ACCESS;
!       }
!       if( (*env)->GetIntField(env, user, user_listGroupsOwnedField) == 
! 	  org_openafs_jafs_User_USER_OWNER_ACCESS ) {
! 	  ptsEntry.listGroupsOwned = PTS_USER_OWNER_ACCESS;
!       } else {
! 	  ptsEntry.listGroupsOwned = PTS_USER_ANYUSER_ACCESS;
!       }
!       if( (*env)->GetIntField(env, user, user_listMembershipField) == 
! 	  org_openafs_jafs_User_USER_OWNER_ACCESS ) {
! 	  ptsEntry.listMembership = PTS_USER_OWNER_ACCESS;
!       } else {
! 	  ptsEntry.listMembership = PTS_USER_ANYUSER_ACCESS;
!       }
!       if( !pts_UserModify( (void *) cellHandle, name, &ptsEntry, &ast ) ) {
! 	  free( who );
! 	  if( name != NULL ) {
! 	      (*env)->ReleaseStringUTFChars(env, jname, name);
! 	  }
! 	  throwAFSException( env, ast );
! 	  return;    
!       }
!   }
! 
!   if( kas ) {
!       // set the kas fields:
!       if( (*env)->GetIntField(env, user, user_adminSettingField) == 
! 	  org_openafs_jafs_User_ADMIN ) {
! 	  isAdmin = KAS_ADMIN;
!       } else {
! 	  isAdmin = NO_KAS_ADMIN;
!       }
!       if( (*env)->GetIntField(env, user, user_tgsSettingField) == 
! 	  org_openafs_jafs_User_GRANT_TICKETS ) {
! 	  grantTickets = TGS;
!       } else {
! 	  grantTickets = NO_TGS;
!       }
!       if( (*env)->GetIntField(env, user, user_encSettingField) == 
! 	  org_openafs_jafs_User_ENCRYPT ) {
! 	  canEncrypt = 0;
!       } else {
! 	  canEncrypt = NO_ENCRYPT;
!       }
!       if( (*env)->GetIntField(env, user, user_cpwSettingField) == 
! 	  org_openafs_jafs_User_CHANGE_PASSWORD ) {
! 	  canChangePassword = CHANGE_PASSWORD;
!       } else {
! 	  canChangePassword = NO_CHANGE_PASSWORD;
!       }
!       if( (*env)->GetIntField(env, user, user_rpwSettingField) == 
! 	  org_openafs_jafs_User_REUSE_PASSWORD ) {
! 	  passwordReuse = REUSE_PASSWORD;
!       } else {
! 	  passwordReuse = NO_REUSE_PASSWORD;
!       }
!       expirationDate = (*env)->GetIntField(env, user, 
! 					   user_userExpirationField);
!       maxTicketLifetime = (*env)->GetIntField(env, user, 
! 					      user_maxTicketLifetimeField);
!       passwordExpires = (*env)->GetIntField(env, user, 
! 					    user_daysToPasswordExpireField);
!       failedPasswordAttempts = (*env)->GetIntField(env, user, 
! 						   user_failLoginCountField);
!       failedPasswordLockTime =  (*env)->GetIntField(env, user, 
! 						    user_lockTimeField);
!       
!       if( !kas_PrincipalFieldsSet( (void *) cellHandle, NULL, who, &isAdmin, 
! 				   &grantTickets, &canEncrypt, 
! 				   &canChangePassword, &expirationDate, 
! 				   &maxTicketLifetime, &passwordExpires, 
! 				   &passwordReuse, &failedPasswordAttempts, 
! 				   &failedPasswordLockTime, &ast ) ) {
! 	  free( who );
! 	  if( name != NULL ) {
! 	      (*env)->ReleaseStringUTFChars(env, jname, name);
! 	  }
! 	  throwAFSException( env, ast );
! 	  return;    
!       }
!   }      
! 
!   free( who );
!   if( name != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jname, name);
!   }
  }
  
  /**
***************
*** 734,902 ****
   * joldName     the name of the user to rename
   * jnewName     the new name for the user
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_User_rename(JNIEnv * env, jclass cls, jint cellHandle,
! 				  jstring joldName, jstring jnewName)
  {
!     char *oldName;
!     char *newName;
!     kas_identity_p whoOld = (kas_identity_p) malloc(sizeof(kas_identity_t));
!     kas_identity_p whoNew = (kas_identity_p) malloc(sizeof(kas_identity_t));
      kas_principalEntry_t kasEntry;
      pts_UserEntry_t ptsEntry;
      afs_status_t ast;
      int kas;
  
!     if (!whoOld || !whoNew) {
! 	if (whoOld) {
! 	    free(whoOld);
! 	}
! 	if (whoNew) {
! 	    free(whoNew);
! 	}
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return;
!     }
! 
!     if (joldName != NULL) {
! 	oldName = getNativeString(env, joldName);
! 	if (oldName == NULL) {
! 	    free(whoOld);
! 	    free(whoNew);
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
  	}
      } else {
  	oldName = NULL;
      }
!     if (jnewName != NULL) {
! 	newName = getNativeString(env, jnewName);
! 	if (newName == NULL) {
! 	    free(whoOld);
! 	    free(whoNew);
! 	    if (oldName != NULL)
! 		free(oldName);
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
  	}
      } else {
  	newName = NULL;
      }
  
      // make sure the names are within the allowed bounds
!     if ((oldName != NULL && strlen(oldName) > KAS_MAX_NAME_LEN)
! 	|| (newName != NULL && strlen(newName) > KAS_MAX_NAME_LEN)) {
! 	free(whoOld);
! 	free(whoNew);
! 	if (oldName != NULL)
! 	    free(oldName);
! 	if (newName != NULL)
! 	    free(newName);
! 	throwAFSException(env, ADMPTSUSERNAMETOOLONG);
  	return;
      }
! 
!     if (oldName != NULL) {
! 	internal_makeKasIdentity(oldName, whoOld);
      }
!     if (newName != NULL) {
! 	internal_makeKasIdentity(newName, whoNew);
      }
      // retrieve the old kas info
!     if (!kas_PrincipalGet((void *)cellHandle, NULL, whoOld, &kasEntry, &ast)) {
! 	if (ast != KANOENT) {
! 	    free(whoOld);
! 	    free(whoNew);
! 	    if (oldName != NULL)
! 		free(oldName);
! 	    if (newName != NULL)
! 		free(newName);
! 	    throwAFSException(env, ast);
  	    return;
  	} else {
  	    kas = FALSE;
  	}
      } else {
  	kas = TRUE;
!     }
! 
!     if (kas) {
  	// create a new kas entry
  	// temporarily set the password equal to the new name
! 	if (!kas_PrincipalCreate
! 	    ((void *)cellHandle, NULL, whoNew, newName, &ast)) {
! 	    free(whoOld);
! 	    free(whoNew);
! 	    if (oldName != NULL)
! 		free(oldName);
! 	    if (newName != NULL)
! 		free(newName);
! 	    throwAFSException(env, ast);
  	    return;
! 	}
  	// set the password 
  	ast = 0;
  	// For some reason kas_PrincipalKeySet doesn't set the return code 
  	// correctly.  It always returns 0.
  	// So instead of checking the return code, we see if there's an 
  	// error in the status variable.
! 	kas_PrincipalKeySet((void *)cellHandle, NULL, whoNew, 0,
! 			    &(kasEntry.key), &ast);
! 	if (ast) {
  	    afs_status_t ast_kd;
! 	    kas_PrincipalDelete((void *)cellHandle, NULL, whoNew, &ast_kd);
! 	    free(whoOld);
! 	    free(whoNew);
! 	    if (oldName != NULL)
! 		free(oldName);
! 	    if (newName != NULL)
! 		free(newName);
! 	    throwAFSException(env, ast);
  	    return;
  	}
      }
      // rename the pts entry
!     if (!pts_UserRename((void *)cellHandle, oldName, newName, &ast)) {
  	// throw exception if there was no such pts user only if 
! 	// there was also no such kas user
! 	if ((ast == ADMPTSFAILEDNAMETRANSLATE && !kas)
! 	    || ast != ADMPTSFAILEDNAMETRANSLATE) {
  	    afs_status_t ast_kd;
! 	    if (kas) {
! 		kas_PrincipalDelete((void *)cellHandle, NULL, whoNew,
! 				    &ast_kd);
  	    }
! 	    free(whoOld);
! 	    free(whoNew);
! 	    if (oldName != NULL)
! 		free(oldName);
! 	    if (newName != NULL)
! 		free(newName);
! 	    throwAFSException(env, ast);
  	    return;
  	}
      }
  
!     if (kas) {
  	// delete the old kas entry
! 	if (!kas_PrincipalDelete((void *)cellHandle, NULL, whoOld, &ast)) {
! 	    free(whoOld);
! 	    free(whoNew);
! 	    if (oldName != NULL)
! 		free(oldName);
! 	    if (newName != NULL)
! 		free(newName);
! 	    throwAFSException(env, ast);
  	    return;
  	}
!     }
  
!     free(whoOld);
!     free(whoNew);
!     if (oldName != NULL)
! 	free(oldName);
!     if (newName != NULL)
! 	free(newName);
  }
  
  /**
--- 793,988 ----
   * joldName     the name of the user to rename
   * jnewName     the new name for the user
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_User_rename
!   (JNIEnv *env, jclass cls, jlong cellHandle, jstring joldName, jstring jnewName)
  {
! 
!     const char *oldName;
!     const char *newName;
!     kas_identity_p whoOld = (kas_identity_p) malloc( sizeof(kas_identity_t) );
!     kas_identity_p whoNew = (kas_identity_p) malloc( sizeof(kas_identity_t) );
      kas_principalEntry_t kasEntry;
      pts_UserEntry_t ptsEntry;
      afs_status_t ast;
      int kas;
  
!     if( !whoOld || !whoNew ) {
!       if( whoOld ) {
! 	free( whoOld );
!       }
!       if( whoNew ) {
! 	free( whoNew );
!       } 
!       throwAFSException( env, JAFSADMNOMEM );
!       return;    
!     }
! 
!     if( joldName != NULL ) {
! 	oldName = (*env)->GetStringUTFChars(env, joldName, 0);
! 	if( !oldName ) {
! 	    throwAFSException( env, JAFSADMNOMEM );
! 	    return;    
  	}
      } else {
  	oldName = NULL;
      }
!     if( jnewName != NULL ) {
! 	newName = (*env)->GetStringUTFChars(env, jnewName, 0);
! 	if( !newName ) {
! 	  if( oldName != NULL ) {
! 	    (*env)->ReleaseStringUTFChars(env, joldName, oldName);
! 	  }
! 	  throwAFSException( env, JAFSADMNOMEM );
! 	  return;    
  	}
      } else {
  	newName = NULL;
      }
  
      // make sure the names are within the allowed bounds
!     if( oldName != NULL && strlen( oldName ) > KAS_MAX_NAME_LEN ) {
! 	free( whoOld );
! 	free( whoNew );
! 	if( oldName != NULL ) {
! 	    (*env)->ReleaseStringUTFChars(env, joldName, oldName);
! 	}
! 	if( newName != NULL ) {
! 	    (*env)->ReleaseStringUTFChars(env, jnewName, newName);
! 	}
! 	throwAFSException( env, ADMPTSUSERNAMETOOLONG );
  	return;
      }
!     if( newName != NULL && strlen( newName ) > KAS_MAX_NAME_LEN ) {
! 	free( whoOld );
! 	free( whoNew );
! 	if( oldName != NULL ) {
! 	    (*env)->ReleaseStringUTFChars(env, joldName, oldName);
! 	}
! 	if( newName != NULL ) {
! 	    (*env)->ReleaseStringUTFChars(env, jnewName, newName);
! 	}
! 	throwAFSException( env, ADMPTSUSERNAMETOOLONG );
! 	return;
!     }
!     
!     if( oldName != NULL ) {
! 	internal_makeKasIdentity( oldName, whoOld );
      }
!     if( newName != NULL ) {
! 	internal_makeKasIdentity( newName, whoNew );
      }
+ 
      // retrieve the old kas info
!     if( !kas_PrincipalGet( (void *) cellHandle, NULL, whoOld, 
! 			   &kasEntry, &ast ) ) {
! 	if( ast != KANOENT ) {
! 	    free( whoOld );
! 	    free( whoNew );
! 	    if( oldName != NULL ) {
! 		(*env)->ReleaseStringUTFChars(env, joldName, oldName);
! 	    }
! 	    if( newName != NULL ) {
! 		(*env)->ReleaseStringUTFChars(env, jnewName, newName);
! 	    }
! 	    throwAFSException( env, ast );
  	    return;
  	} else {
  	    kas = FALSE;
  	}
      } else {
  	kas = TRUE;
!     }   
! 	
!     if( kas ) {
  	// create a new kas entry
  	// temporarily set the password equal to the new name
! 	if (!kas_PrincipalCreate( (void *) cellHandle, NULL, whoNew, 
! 				  newName, &ast ) ) {	    
! 	    free( whoOld );
! 	    free( whoNew );
! 	    if( oldName != NULL ) {
! 		(*env)->ReleaseStringUTFChars(env, joldName, oldName);
! 	    }
! 	    if( newName != NULL ) {
! 		(*env)->ReleaseStringUTFChars(env, jnewName, newName);
! 	    }
! 	    throwAFSException( env, ast );
  	    return;
! 	} 
! 
  	// set the password 
  	ast = 0;
  	// For some reason kas_PrincipalKeySet doesn't set the return code 
  	// correctly.  It always returns 0.
  	// So instead of checking the return code, we see if there's an 
  	// error in the status variable.
! 	kas_PrincipalKeySet( (void *) cellHandle, NULL, whoNew, 0, 
! 			     &(kasEntry.key), &ast );
! 	if( ast ) {
  	    afs_status_t ast_kd;
! 	    kas_PrincipalDelete( (void *) cellHandle, NULL, whoNew, &ast_kd );
! 	    free( whoOld );
! 	    free( whoNew );
! 	    if( oldName != NULL ) {
! 		(*env)->ReleaseStringUTFChars(env, joldName, oldName);
! 	    }
! 	    if( newName != NULL ) {
! 		(*env)->ReleaseStringUTFChars(env, jnewName, newName);
! 	    }
! 	    throwAFSException( env, ast );
  	    return;
  	}
      }
+ 
      // rename the pts entry
!     if( !pts_UserRename( (void *) cellHandle, oldName, newName, &ast ) ) {
  	// throw exception if there was no such pts user only if 
!         // there was also no such kas user
! 	if( (ast == ADMPTSFAILEDNAMETRANSLATE && !kas ) || 
! 	    ast != ADMPTSFAILEDNAMETRANSLATE ) {
  	    afs_status_t ast_kd;
! 	    if( kas ) {
! 		kas_PrincipalDelete( (void *) cellHandle, NULL, whoNew, 
! 				     &ast_kd );
  	    }
! 	    free( whoOld );
! 	    free( whoNew );
! 	    if( oldName != NULL ) {
! 		(*env)->ReleaseStringUTFChars(env, joldName, oldName);
! 	    }
! 	    if( newName != NULL ) {
! 		(*env)->ReleaseStringUTFChars(env, jnewName, newName);
! 	    }
! 	    throwAFSException( env, ast );
  	    return;
  	}
      }
  
!     if( kas ) {
  	// delete the old kas entry
! 	if( !kas_PrincipalDelete( (void *) cellHandle, NULL, whoOld, &ast ) ) {
! 	    free( whoOld );
! 	    free( whoNew );
! 	    if( oldName != NULL ) {
! 		(*env)->ReleaseStringUTFChars(env, joldName, oldName);
! 	    }
! 	    if( newName != NULL ) {
! 		(*env)->ReleaseStringUTFChars(env, jnewName, newName);
! 	    }
! 	    throwAFSException( env, ast );
  	    return;
  	}
!     }    
  
!     free( whoOld );
!     free( whoNew );
!     if( oldName != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, joldName, oldName);
!     }
!     if( newName != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, jnewName, newName);
!     }
  }
  
  /**
***************
*** 905,1013 ****
   * env      the Java environment
   * cls      the current Java class
   * cellHandle    the handle of the cell to which the user belongs
!  * jusername     the name of the user for which to set the password
   * jnewPassword     the new password for the user
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_User_setPassword(JNIEnv * env, jclass cls,
! 				       jint cellHandle, jstring jusername,
! 				       jstring jnewPassword)
  {
!     afs_status_t ast;
!     char *cellName;
!     char *username;
!     char *newPassword;
!     kas_encryptionKey_p newKey =
! 	(kas_encryptionKey_p) malloc(sizeof(kas_encryptionKey_t));
!     kas_identity_p who = (kas_identity_p) malloc(sizeof(kas_identity_t));
! 
!     if (!who || !newKey) {
! 	if (who) {
! 	    free(who);
! 	}
! 	if (newKey) {
! 	    free(newKey);
! 	}
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return;
!     }
! 
!     if (jusername != NULL) {
! 	username = getNativeString(env, jusername);
! 	if (username == NULL) {
! 	    free(who);
! 	    free(newKey);
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	free(who);
! 	free(newKey);
! 	throwAFSException(env, JAFSNULLUSER);
! 	return;
!     }
! 
!     if (jnewPassword != NULL) {
! 	newPassword = getNativeString(env, jnewPassword);
! 	if (newPassword == NULL) {
! 	    free(who);
! 	    free(newKey);
! 	    free(username);
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	free(who);
! 	free(newKey);
! 	free(username);
! 	throwAFSException(env, JAFSNULLPASS);
! 	return;
!     }
! 
!     // make sure the name is within the allowed bounds
!     if (strlen(username) > KAS_MAX_NAME_LEN) {
! 	free(who);
! 	free(newKey);
! 	free(username);
! 	free(newPassword);
! 	throwAFSException(env, ADMPTSUSERNAMETOOLONG);
! 	return;
!     }
! 
!     if (!afsclient_CellNameGet((void *)cellHandle, &cellName, &ast)) {
! 	free(who);
! 	free(newKey);
! 	free(username);
! 	free(newPassword);
! 	throwAFSException(env, ast);
! 	return;
!     }
! 
!     if (!kas_StringToKey(cellName, newPassword, newKey, &ast)) {
! 	free(who);
! 	free(newKey);
! 	free(username);
! 	free(newPassword);
! 	throwAFSException(env, ast);
! 	return;
!     }
! 
!     internal_makeKasIdentity(username, who);
! 
!     ast = 0;
!     // For some reason kas_PrincipalKeySet doesn't set the return code correctly.
!     //  It always returns 0.
!     // So instead of checking the return code, we see if there's an error 
!     // in the status variable.
!     kas_PrincipalKeySet((void *)cellHandle, NULL, who, 0, newKey, &ast);
!     if (ast) {
! 	throwAFSException(env, ast);
!     }
  
      free(who);
!     free(newKey);
!     free(username);
!     free(newPassword);
  }
  
  /**
--- 991,1114 ----
   * env      the Java environment
   * cls      the current Java class
   * cellHandle    the handle of the cell to which the user belongs
!  * juserName     the name of the user for which to set the password
   * jnewPassword     the new password for the user
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_User_setPassword
!   (JNIEnv *env, jclass cls, jlong cellHandle, jstring juserName,
!    jstring jnewPassword)
  {
!   afs_status_t ast;
!   char *cellName;
!   const char *userName;
!   const char *newPassword;
!   kas_encryptionKey_p newKey = 
!     (kas_encryptionKey_p) malloc( sizeof(kas_encryptionKey_t) );
!   kas_identity_p who = (kas_identity_p) malloc( sizeof(kas_identity_t) );
! 
!   if( !who || !newKey ) {
!     if( who ) {
!       free( who );
!     }
!     if( newKey ) {
!       free( newKey );
!     }
!     throwAFSException( env, JAFSADMNOMEM );
!     return;    
!   }
! 
!   if( juserName != NULL ) {
!       userName = (*env)->GetStringUTFChars(env, juserName, 0);
!       if( !userName ) {
! 	  throwAFSException( env, JAFSADMNOMEM );
! 	  return;    
!       }
!   } else {
!       userName = NULL;
!   }
!   if( jnewPassword != NULL ) {
!       newPassword = (*env)->GetStringUTFChars(env, jnewPassword, 0);
!       if( !newPassword ) {
! 	  throwAFSException( env, JAFSADMNOMEM );
! 	  return;    
!       }
!   } else {
!       newPassword = NULL;
!   }
  
+   // make sure the name is within the allowed bounds
+   if( userName != NULL && strlen( userName ) > KAS_MAX_NAME_LEN ) {
      free(who);
!     free( newKey );
!     if( userName != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, juserName, userName);
!     }
!     if( newPassword != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, jnewPassword, newPassword);
!     }
!     throwAFSException( env, ADMPTSUSERNAMETOOLONG );
!     return;
!   }
! 
!   if( !afsclient_CellNameGet( (void *) cellHandle, &cellName, &ast ) ) {
!       free(who);
!       free( newKey );
!       if( userName != NULL ) {
! 	  (*env)->ReleaseStringUTFChars(env, juserName, userName);
!       }
!       if( newPassword != NULL ) {
! 	  (*env)->ReleaseStringUTFChars(env, jnewPassword, newPassword);
!       }
!       throwAFSException( env, ast );
!       return;
!   }
!   
!   if( !kas_StringToKey( cellName, newPassword, newKey, &ast ) ) {
!       free(who);
!       free( newKey );
!       if( userName != NULL ) {
! 	  (*env)->ReleaseStringUTFChars(env, juserName, userName);
!       }
!       if( newPassword != NULL ) {
! 	  (*env)->ReleaseStringUTFChars(env, jnewPassword, newPassword);
!       }
!       throwAFSException( env, ast );
!       return;
!   }
! 
!   if( userName != NULL ) {
!       internal_makeKasIdentity( userName, who );
!   }
! 
!   ast = 0;
!   // For some reason kas_PrincipalKeySet doesn't set the return code correctly.
!   //  It always returns 0.
!   // So instead of checking the return code, we see if there's an error 
!   // in the status variable.
!   kas_PrincipalKeySet( (void *) cellHandle, NULL, who, 0, newKey, &ast );
!   if( ast ) {
!     free( who );
!     free( newKey );
!     if( userName != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, juserName, userName);
!     }
!     if( newPassword != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, jnewPassword, newPassword);
!     }
!     throwAFSException( env, ast );
!     return;
!   }
! 
!   free( who );
!   free( newKey );
!   if( userName != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, juserName, userName);
!   }
!   if( newPassword != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jnewPassword, newPassword);
!   }
! 
  }
  
  /**
***************
*** 1021,1053 ****
   * jname          the name of the user for which to get the groups
   * returns an iteration ID
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_User_getUserGroupsBegin(JNIEnv * env, jclass cls,
! 					      jint cellHandle, jstring jname)
  {
!     char *name;
!     afs_status_t ast;
!     void *iterationId;
! 
!     if (jname != NULL) {
! 	name = getNativeString(env, jname);
! 	if (name == NULL) {
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	throwAFSException(env, JAFSNULLUSER);
! 	return;
!     }
  
!     if (!pts_UserMemberListBegin
! 	((void *)cellHandle, name, &iterationId, &ast)) {
! 	throwAFSException(env, ast);
!     }
! 
!     free(name);
  
-     return (jint) iterationId;
  }
  
  /**
--- 1122,1160 ----
   * jname          the name of the user for which to get the groups
   * returns an iteration ID
   */
! JNIEXPORT jlong JNICALL 
! Java_org_openafs_jafs_User_getUserGroupsBegin
!   (JNIEnv *env, jclass cls, jlong cellHandle, jstring jname)
  {
!   const char *name;
!   afs_status_t ast;
!   void *iterationId;
! 
!   if( jname != NULL ) {
!       name = (*env)->GetStringUTFChars(env, jname, 0);
!       if( !name ) {
! 	  throwAFSException( env, JAFSADMNOMEM );
! 	  return;    
!       }
!   } else {
!       name = NULL;
!   }
! 
!   if( !pts_UserMemberListBegin( (void *) cellHandle, name, &iterationId, 
! 				&ast ) ) {
!       if( name != NULL ) {
! 	  (*env)->ReleaseStringUTFChars(env, jname, name);
!       }
!       throwAFSException( env, ast );
!       return;
!   }
! 
!   if( name != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jname, name);
!   }
  
!   return (jlong) iterationId;
  
  }
  
  /**
***************
*** 1059,1090 ****
   * iterationId   the iteration ID of this iteration
   * returns the name of the next group
   */
! JNIEXPORT jstring JNICALL
! Java_org_openafs_jafs_User_getUserGroupsNextString(JNIEnv * env, jclass cls,
! 						   jint iterationId)
  {
!     afs_status_t ast;
!     char *groupName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN);
!     jstring jgroup;
! 
!     if (!groupName) {
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return;
!     }
! 
!     if (!pts_UserMemberListNext((void *)iterationId, groupName, &ast)) {
! 	free(groupName);
! 	if (ast == ADMITERATORDONE) {
! 	    return NULL;
! 	} else {
! 	    throwAFSException(env, ast);
! 	    return;
! 	}
      }
! 
!     jgroup = (*env)->NewStringUTF(env, groupName);
!     free(groupName);
!     return jgroup;
  }
  
  /**
--- 1166,1197 ----
   * iterationId   the iteration ID of this iteration
   * returns the name of the next group
   */
! JNIEXPORT jstring JNICALL 
! Java_org_openafs_jafs_User_getUserGroupsNextString
!   (JNIEnv *env, jclass cls, jlong iterationId)
  {
!   afs_status_t ast;
!   char *groupName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN);
!   jstring jgroup;
! 
!   if( !groupName ) {
!     throwAFSException( env, JAFSADMNOMEM );
!     return;    
!   }
! 
!   if( !pts_UserMemberListNext( (void *) iterationId, groupName, &ast ) ) {
!     free( groupName );
!     if( ast == ADMITERATORDONE ) {
!       return NULL;
!     } else {
!       throwAFSException( env, ast );
!       return;
      }
!   }
!   
!   jgroup = (*env)->NewStringUTF(env, groupName);
!   free( groupName );
!   return jgroup;
  }
  
  /**
***************
*** 1099,1144 ****
   *                   next group
   * returns 0 if there are no more users, != 0 otherwise
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_User_getUserGroupsNext(JNIEnv * env, jclass cls,
! 					     jint cellHandle,
! 					     jint iterationId,
! 					     jobject jgroupObject)
  {
!     afs_status_t ast;
!     char *groupName;
!     jstring jgroup;
! 
!     groupName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN);
! 
!     if (!groupName) {
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return;
!     }
! 
!     if (!pts_UserMemberListNext((void *)iterationId, groupName, &ast)) {
! 	free(groupName);
! 	if (ast == ADMITERATORDONE) {
! 	    return 0;
! 	} else {
! 	    throwAFSException(env, ast);
! 	    return 0;
! 	}
      }
  
!     jgroup = (*env)->NewStringUTF(env, groupName);
  
!     if (groupCls == 0) {
! 	internal_getGroupClass(env, jgroupObject);
!     }
  
!     (*env)->SetObjectField(env, jgroupObject, group_nameField, jgroup);
  
!     getGroupInfoChar(env, (void *)cellHandle, groupName, jgroupObject);
!     (*env)->SetBooleanField(env, jgroupObject, group_cachedInfoField, TRUE);
  
!     free(groupName);
!     return 1;
  
  }
  
--- 1206,1250 ----
   *                   next group
   * returns 0 if there are no more users, != 0 otherwise
   */
! JNIEXPORT jint JNICALL 
! Java_org_openafs_jafs_User_getUserGroupsNext
!   (JNIEnv *env, jclass cls, jlong cellHandle, jlong iterationId,
!    jobject jgroupObject)
  {
!   afs_status_t ast;
!   char *groupName;
!   jstring jgroup;
! 
!   groupName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN);
! 
!   if( !groupName ) {
!     throwAFSException( env, JAFSADMNOMEM );
!     return;    
!   }
! 
!   if( !pts_UserMemberListNext( (void *) iterationId, groupName, &ast ) ) {
!     free( groupName );
!     if( ast == ADMITERATORDONE ) {
!       return 0;
!     } else {
!       throwAFSException( env, ast );
!       return 0;
      }
+   }
  
!   jgroup = (*env)->NewStringUTF(env, groupName);
  
!   if( groupCls == 0 ) {
!     internal_getGroupClass( env, jgroupObject );
!   }
  
!   (*env)->SetObjectField(env, jgroupObject, group_nameField, jgroup);
  
!   getGroupInfoChar( env, (void *) cellHandle, groupName, jgroupObject );
!   (*env)->SetBooleanField( env, jgroupObject, group_cachedInfoField, TRUE );
  
!   free( groupName );
!   return 1;
  
  }
  
***************
*** 1149,1164 ****
   * cls      the current Java class
   * iterationId   the iteration ID of this iteration
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_User_getUserGroupsDone(JNIEnv * env, jclass cls,
! 					     jint iterationId)
  {
!     afs_status_t ast;
  
!     if (!pts_UserMemberListDone((void *)iterationId, &ast)) {
! 	throwAFSException(env, ast);
! 	return;
!     }
  }
  
  /**
--- 1255,1270 ----
   * cls      the current Java class
   * iterationId   the iteration ID of this iteration
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_User_getUserGroupsDone
!   (JNIEnv *env, jclass cls, jlong iterationId)
  {
!   afs_status_t ast;
  
!   if( !pts_UserMemberListDone( (void *) iterationId, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  }
  
  /**
***************
*** 1170,1207 ****
   * jname          the name of the user for which to get the groups
   * returns total number of groups owned by the user
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_User_getGroupsOwnedCount(JNIEnv * env, jclass cls,
! 					       jint cellHandle, jstring jname)
  {
!     afs_status_t ast;
!     void *iterationId;
!     char *groupName;
!     int i = 0;
! 
!     iterationId =
! 	(void *)Java_org_openafs_jafs_User_getGroupsOwnedBegin(env, cls,
! 							       cellHandle,
! 							       jname);
  
!     groupName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN);
! 
!     if (!groupName) {
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return -1;
!     }
! 
!     while (pts_OwnedGroupListNext((void *)iterationId, groupName, &ast))
! 	i++;
! 
!     free(groupName);
! 
!     if (ast != ADMITERATORDONE) {
! 	throwAFSException(env, ast);
! 	return -1;
!     }
! 
!     return i;
  }
  
  /**
--- 1276,1313 ----
   * jname          the name of the user for which to get the groups
   * returns total number of groups owned by the user
   */
! JNIEXPORT jint JNICALL 
! Java_org_openafs_jafs_User_getGroupsOwnedCount
!   (JNIEnv *env, jclass cls, jlong cellHandle, jstring jname)
  {
!   afs_status_t ast;
!   void *iterationId;
!   char *groupName;
!   int i = 0;
! 
!   iterationId = 
!     (void *) Java_org_openafs_jafs_User_getGroupsOwnedBegin( env, cls, 
! 								cellHandle, 
! 								jname );
! 
!   groupName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN);
! 
!   if( !groupName ) {
!     throwAFSException( env, JAFSADMNOMEM );
!     return -1;    
!   }
! 
!   while ( pts_OwnedGroupListNext( (void *) iterationId, groupName, &ast ) ) 
!     i++;
! 
!   free( groupName );  
! 
!   if( ast != ADMITERATORDONE ) {
!     throwAFSException( env, ast );
!     return -1;
!   }
  
!   return i;
  }
  
  /**
***************
*** 1215,1247 ****
   * jname  the name of the user or group for which to get the groups
   * returns an iteration ID
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_User_getGroupsOwnedBegin(JNIEnv * env, jclass cls,
! 					       jint cellHandle, jstring jname)
  {
!     char *name;
!     afs_status_t ast;
!     void *iterationId;
! 
!     if (jname != NULL) {
! 	name = getNativeString(env, jname);
! 	if (name == NULL) {
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return -1;
! 	}
!     } else {
! 	throwAFSException(env, JAFSNULLUSER);
! 	return -1;
!     }
  
!     if (!pts_OwnedGroupListBegin
! 	((void *)cellHandle, name, &iterationId, &ast)) {
! 	throwAFSException(env, ast);
!     }
! 
!     free(name);
  
-     return (jint) iterationId;
  }
  
  /**
--- 1321,1359 ----
   * jname  the name of the user or group for which to get the groups
   * returns an iteration ID
   */
! JNIEXPORT jlong JNICALL 
! Java_org_openafs_jafs_User_getGroupsOwnedBegin
!   (JNIEnv *env, jclass cls, jlong cellHandle, jstring jname)
  {
!   const char *name;
!   afs_status_t ast;
!   void *iterationId;
! 
!   if( jname != NULL ) {
!       name = (*env)->GetStringUTFChars(env, jname, 0);
!       if( !name ) {
! 	  throwAFSException( env, JAFSADMNOMEM );
! 	  return;    
!       }
!   } else {
!       name = NULL;
!   }
! 
!   if( !pts_OwnedGroupListBegin( (void *) cellHandle, name, 
! 				&iterationId, &ast ) ) {
!       if( jname != NULL ) {
! 	  (*env)->ReleaseStringUTFChars(env, jname, name);
!       }
!       throwAFSException( env, ast );
!       return;
!   }
! 
!   if( jname != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jname, name);
!   }
  
!   return (jlong) iterationId;
  
  }
  
  /**
***************
*** 1253,1284 ****
   * iterationId   the iteration ID of this iteration
   * returns the name of the next group
   */
! JNIEXPORT jstring JNICALL
! Java_org_openafs_jafs_User_getGroupsOwnedNextString(JNIEnv * env, jclass cls,
! 						    jint iterationId)
  {
!     afs_status_t ast;
!     char *groupName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN);
!     jstring jgroup;
! 
!     if (!groupName) {
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return;
!     }
! 
!     if (!pts_OwnedGroupListNext((void *)iterationId, groupName, &ast)) {
! 	free(groupName);
! 	if (ast == ADMITERATORDONE) {
! 	    return NULL;
! 	} else {
! 	    throwAFSException(env, ast);
! 	    return NULL;
! 	}
      }
! 
!     jgroup = (*env)->NewStringUTF(env, groupName);
!     free(groupName);
!     return jgroup;
  
  }
  
--- 1365,1396 ----
   * iterationId   the iteration ID of this iteration
   * returns the name of the next group
   */
! JNIEXPORT jstring JNICALL 
! Java_org_openafs_jafs_User_getGroupsOwnedNextString
!   (JNIEnv *env, jclass cls, jlong iterationId)
  {
!   afs_status_t ast;
!   char *groupName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN);
!   jstring jgroup;
! 
!   if( !groupName ) {
!     throwAFSException( env, JAFSADMNOMEM );
!     return;    
!   }
! 
!   if( !pts_OwnedGroupListNext( (void *) iterationId, groupName, &ast ) ) {
!     free( groupName );
!     if( ast == ADMITERATORDONE ) {
!       return NULL;
!     } else {
!       throwAFSException( env, ast );
!       return;
      }
!   }
!   
!   jgroup = (*env)->NewStringUTF(env, groupName);
!   free( groupName );
!   return jgroup;
  
  }
  
***************
*** 1294,1339 ****
   *                   next group
   * returns 0 if there are no more users, != 0 otherwise
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_User_getGroupsOwnedNext(JNIEnv * env, jclass cls,
! 					      jint cellHandle,
! 					      jint iterationId,
! 					      jobject jgroupObject)
  {
!     afs_status_t ast;
!     char *groupName;
!     jstring jgroup;
! 
!     groupName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN);
! 
!     if (!groupName) {
! 	throwAFSException(env, JAFSADMNOMEM);
! 	return 0;
!     }
! 
!     if (!pts_OwnedGroupListNext((void *)iterationId, groupName, &ast)) {
! 	free(groupName);
! 	if (ast == ADMITERATORDONE) {
! 	    return 0;
! 	} else {
! 	    throwAFSException(env, ast);
! 	    return 0;
! 	}
      }
  
!     jgroup = (*env)->NewStringUTF(env, groupName);
  
!     if (groupCls == 0) {
! 	internal_getGroupClass(env, jgroupObject);
!     }
  
!     (*env)->SetObjectField(env, jgroupObject, group_nameField, jgroup);
  
!     getGroupInfoChar(env, (void *)cellHandle, groupName, jgroupObject);
!     (*env)->SetBooleanField(env, jgroupObject, group_cachedInfoField, TRUE);
  
!     free(groupName);
!     return 1;
  
  }
  
--- 1406,1450 ----
   *                   next group
   * returns 0 if there are no more users, != 0 otherwise
   */
! JNIEXPORT jint JNICALL 
! Java_org_openafs_jafs_User_getGroupsOwnedNext
!   (JNIEnv *env, jclass cls, jlong cellHandle, jlong iterationId, 
!    jobject jgroupObject)
  {
!   afs_status_t ast;
!   char *groupName;
!   jstring jgroup;
! 
!   groupName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN);
! 
!   if( !groupName ) {
!     throwAFSException( env, JAFSADMNOMEM );
!     return;    
!   }
! 
!   if( !pts_OwnedGroupListNext( (void *) iterationId, groupName, &ast ) ) {
!     free( groupName );
!     if( ast == ADMITERATORDONE ) {
!       return 0;
!     } else {
!       throwAFSException( env, ast );
!       return 0;
      }
+   }
  
!   jgroup = (*env)->NewStringUTF(env, groupName);
  
!   if( groupCls == 0 ) {
!     internal_getGroupClass( env, jgroupObject );
!   }
  
!   (*env)->SetObjectField(env, jgroupObject, group_nameField, jgroup);
  
!   getGroupInfoChar( env, (void *) cellHandle, groupName, jgroupObject );
!   (*env)->SetBooleanField( env, jgroupObject, group_cachedInfoField, TRUE );
  
!   free( groupName );
!   return 1;
  
  }
  
***************
*** 1344,1367 ****
   * cls      the current Java class
   * iterationId   the iteration ID of this iteration
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_User_getGroupsOwnedDone(JNIEnv * env, jclass cls,
! 					      jint iterationId)
  {
!     afs_status_t ast;
  
!     if (!pts_OwnedGroupListDone((void *)iterationId, &ast)) {
! 	throwAFSException(env, ast);
! 	return;
!     }
  }
  
  // reclaim global memory being used by this portion
  JNIEXPORT void JNICALL
! Java_org_openafs_jafs_User_reclaimUserMemory(JNIEnv * env, jclass cls)
  {
!     if (userCls) {
! 	(*env)->DeleteGlobalRef(env, userCls);
! 	userCls = 0;
!     }
  }
--- 1455,1484 ----
   * cls      the current Java class
   * iterationId   the iteration ID of this iteration
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_User_getGroupsOwnedDone
!   (JNIEnv *env, jclass cls, jlong iterationId)
  {
!   afs_status_t ast;
  
!   if( !pts_OwnedGroupListDone( (void *) iterationId, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
!   
  }
  
  // reclaim global memory being used by this portion
  JNIEXPORT void JNICALL
! Java_org_openafs_jafs_User_reclaimUserMemory
!   (JNIEnv *env, jclass cls)
  {
!   if( userCls ) {
!       (*env)->DeleteGlobalRef(env, userCls);
!       userCls = 0;
!   }
! 
  }
+ 
+ 
+ 
Index: openafs/src/JAVA/libjafs/UserToken.c
diff -c openafs/src/JAVA/libjafs/UserToken.c:1.3 openafs/src/JAVA/libjafs/UserToken.c:1.3.2.1
*** openafs/src/JAVA/libjafs/UserToken.c:1.3	Tue Jul 15 19:11:26 2003
--- openafs/src/JAVA/libjafs/UserToken.c	Fri Oct 14 22:14:12 2005
***************
*** 27,32 ****
--- 27,33 ----
  #include <sys/stat.h>
  #include <sys/ioctl.h>
  #include <afs/vice.h>
+ #include <netinet/in.h>
  #include <afs/venus.h>
  #include <afs/afs_args.h>
  /*#include <afs/afs_osi.h>
***************
*** 38,74 ****
  #endif
  
  pthread_mutex_t jafs_init_lock;
- 
  extern pthread_mutex_t jafs_login_lock;
- 
  extern int readCacheParms(char *afsMountPoint, char *afsConfDir,
! 			  char *afsCacheDir, int *cacheBlocks,
! 			  int *cacheFiles, int *cacheStatEntries,
! 			  int *dCacheSize, int *vCacheSize, int *chunkSize,
! 			  int *closeSynch, int *debug, int *nDaemons,
! 			  int *cacheFlags, char *logFile);
  
  /**
   * Be carefull with the memory management:
   *
!  * - For every getNativeString call the corresponding free().
   * - For every Get<type>ArrayElements call the corresponding
   *   Release<type>ArrayElements
   * - For every malloc call the corresponding free.
   */
  
! int
! osi_audit(void)
  {
!     return 0;
  }
  
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Token_callDebugger(JNIEnv * env, jobject obj)
  {
      fprintf(stderr, "callDebugger called\n");
      __asm__("int $0x3");
! }
  
  /**
   * Initialize the user space library.
--- 39,72 ----
  #endif
  
  pthread_mutex_t jafs_init_lock;
  extern pthread_mutex_t jafs_login_lock;
  extern int readCacheParms(char *afsMountPoint, char *afsConfDir,
!                           char *afsCacheDir,  int *cacheBlocks, 
!                           int *cacheFiles, int *cacheStatEntries,
!                           int *dCacheSize, int *vCacheSize, int *chunkSize,
!                           int *closeSynch, int *debug, int *nDaemons, 
!                           int *cacheFlags, char *logFile);
  
  /**
   * Be carefull with the memory management:
   *
!  * - For every GetStringUTFChars call the corresponding ReleaseStringUTFChars.
   * - For every Get<type>ArrayElements call the corresponding
   *   Release<type>ArrayElements
   * - For every malloc call the corresponding free.
   */
  
! int osi_audit(void)
  {
!    return 0;
  }
  
! /*JNIEXPORT void JNICALL Java_org_openafs_jafs_Token_callDebugger
!   (JNIEnv *env, jobject obj)
  {
      fprintf(stderr, "callDebugger called\n");
      __asm__("int $0x3");
! }*/
  
  /**
   * Initialize the user space library.
***************
*** 82,148 ****
   *
   * throws AFSException
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Token_initUserSpace(JNIEnv * env, jclass cls)
  {
!     char afsMountPoint[100], afsConfDir[100], afsCacheDir[100], logFile[100];
!     jfieldID fid;
!     int pagval;
! 
!     /* Initialize each init parameter with its associated default value */
!     int cacheBlocks = 100000;
!     int cacheFiles = 12500;
!     int cacheStatEntries = 8192;
!     int dCacheSize = 11398;
!     int vCacheSize = 128;
!     int chunkSize = 0;
!     int closeSynch = 0;
!     int debug = 0;
!     int nDaemons = 3;
!     int cacheFlags = -1;
! 
!     /* Initialize each init parameter with its associated default value */
!     strcpy(afsMountPoint, "/afs");
!     strcpy(afsConfDir, "/usr/afswsp/etc");
!     strcpy(afsCacheDir, "/usr/afswsp/cache");
!     strcpy(logFile, "/usr/afswsp/log/libjafs.log");
! 
!     pthread_mutex_init(&jafs_init_lock, NULL);
!     pthread_mutex_lock(&jafs_init_lock);
! 
!     readCacheParms(afsMountPoint, afsConfDir, afsCacheDir, &cacheBlocks,
! 		   &cacheFiles, &cacheStatEntries, &dCacheSize, &vCacheSize,
! 		   &chunkSize, &closeSynch, &debug, &nDaemons, &cacheFlags,
! 		   logFile);
! 
!     /* See cache.tune for configuration details */
!     if (debug) {
! 	fprintf(stderr, "uafs_Init(\"init_native\", \"%s\", \"%s\", \"%s\",
!                       %d, %d, %d,
!                       %d, %d, %d,
!                       %d, %d, %d, %d, \"%s\");\n", afsMountPoint, afsConfDir, afsCacheDir, cacheBlocks, cacheFiles, cacheStatEntries, dCacheSize, vCacheSize, chunkSize, closeSynch, debug, nDaemons, cacheFlags, logFile);
!     }
!     uafs_Init("init_native", afsMountPoint, afsConfDir, afsCacheDir,
! 	      cacheBlocks, cacheFiles, cacheStatEntries, dCacheSize,
! 	      vCacheSize, chunkSize, closeSynch, debug, nDaemons, cacheFlags,
! 	      logFile);
! 
! 
!     /* make the initial pag the unauthenticated pag */
!     afs_setpag();
!     uafs_unlog();
!     pagval = afs_getpag_val();
! 
!     fid = (*env)->GetStaticFieldID(env, cls, "ANYUSER_PAG_ID", "I");
!     if (fid == 0) {
! 	fprintf(stderr,
! 		"UserToken::init(): GetFieldID (ANYUSER_PAG_ID) failed\n");
! 	return;
!     }
  
!     (*env)->SetStaticIntField(env, cls, fid, pagval);
! 
!     pthread_mutex_unlock(&jafs_init_lock);
  }
  
  /**
--- 80,151 ----
   *
   * throws AFSException
   */
! JNIEXPORT void JNICALL Java_org_openafs_jafs_Token_initUserSpace
!   (JNIEnv *env, jclass cls)
  {
!   char afsMountPoint[100], afsConfDir[100], afsCacheDir[100], logFile[100];
!   jfieldID fid;
!   int pagval;
! 
!   /* Initialize each init parameter with its associated default value */
!   int cacheBlocks = 100000;
!   int cacheFiles  = 12500;
!   int cacheStatEntries = 8192;
!   int dCacheSize  = 11398;
!   int vCacheSize  = 128;
!   int chunkSize   = 0;
!   int closeSynch  = 0;
!   int debug       = 0;
!   int nDaemons    = 3; 
!   int cacheFlags  = -1;
! 
!   /* Initialize each init parameter with its associated default value */
!   strcpy(afsMountPoint, "/afs");
!   strcpy(afsConfDir,  "/usr/afswsp/etc");
!   strcpy(afsCacheDir, "/usr/afswsp/cache");
!   strcpy(logFile,     "/usr/afswsp/log/libjafs.log");
! 
!   pthread_mutex_init(&jafs_init_lock, NULL);
!   pthread_mutex_lock(&jafs_init_lock);
! 
!   readCacheParms(afsMountPoint, afsConfDir, afsCacheDir,
!                  &cacheBlocks, &cacheFiles, &cacheStatEntries,
!                  &dCacheSize, &vCacheSize, &chunkSize,
!                  &closeSynch, &debug, &nDaemons, &cacheFlags,
!                  logFile);
! 
!   /* See cache.tune for configuration details */
!   if (debug) {
!     fprintf(stderr, "uafs_Init(\"init_native\", \"%s\", \"%s\", \"%s\"",
!                       "%d, %d, %d,"
!                       "%d, %d, %d,"
!                       "%d, %d, %d, %d, \"%s\");\n",
!               afsMountPoint, afsConfDir, afsCacheDir,
!               cacheBlocks, cacheFiles, cacheStatEntries,
!               dCacheSize, vCacheSize, chunkSize,
!               closeSynch, debug, nDaemons, cacheFlags, logFile);
!   }
!   uafs_Init("init_native", afsMountPoint, afsConfDir, afsCacheDir,
!              cacheBlocks, cacheFiles, cacheStatEntries,
!              dCacheSize, vCacheSize, chunkSize,
!              closeSynch, debug, nDaemons, cacheFlags, logFile);
! 
! 
!   /* make the initial pag the unauthenticated pag */
!   afs_setpag();
!   uafs_unlog();
!   pagval = afs_getpag_val();
! 
!   fid = (*env)->GetStaticFieldID(env, cls, "ANYUSER_PAG_ID", "I");
!   if (fid == 0) {
!     fprintf(stderr,
!     "UserToken::init(): GetFieldID (ANYUSER_PAG_ID) failed\n");
!     return;
!   }
!     
!   (*env)->SetStaticIntField(env, cls, fid, pagval);
  
!   pthread_mutex_unlock(&jafs_init_lock);
  }
  
  /**
***************
*** 160,262 ****
   * throws AFSException
   */
  JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Token_klog(JNIEnv * env, jobject obj, jstring jusername,
! 				 jstring jpassword, jstring jcell, jint id)
  {
!     char *username;
!     char *password;
!     char *cell;
!     char *reason;
!     int code;
!     jint rc = -1;
! 
!     if (jcell != NULL) {
! 	cell = getNativeString(env, jcell);
! 	if (!cell) {
! 	    fprintf(stderr, "UserToken::klog(): failed to get cell name\n");
! 	    throwMessageException(env,
! 				  "Internal error, failed to translate cell name.");
! 	    return -1;
! 	}
!     } else {
! 	cell = NULL;
      }
! 
!     if (jusername != NULL) {
! 	username = getNativeString(env, jusername);
! 	if (!username) {
! 	    if (cell != NULL)
! 		free(cell);
! 	    fprintf(stderr, "UserToken::klog(): failed to get username\n");
! 	    throwMessageException(env,
! 				  "Internal error, failed to translate username.");
! 	    return -1;
! 	}
!     } else {
! 	if (cell != NULL)
! 	    free(cell);
! 	throwAFSException(env, JAFSNULLUSER);
! 	return -1;
      }
! 
!     if (jpassword != NULL) {
! 	password = getNativeString(env, jpassword);
! 	if (!password) {
! 	    if (cell != NULL)
! 		free(cell);
! 	    free(username);
! 	    fprintf(stderr, "UserToken::klog(): failed to get password\n");
! 	    throwMessageException(env,
! 				  "Internal error, failed to translate password.");
! 	    return -1;
! 	}
!     } else {
! 	if (cell != NULL)
! 	    free(cell);
! 	free(username);
! 	throwAFSException(env, JAFSNULLPASS);
! 	return -1;
      }
! 
!     if (id == 0) {
! 	code = uafs_klog(username, cell, password, &reason);
!     } else {
! 	/* Use existing PAG for this thread */
! 	code = afs_setpag_val(id);
! 	if (code != 0)
! 	    code = 180492L;	/* KABADARGUMENT */
! 	if (!code)
! 	    code = uafs_klog_nopag(username, cell, password, &reason);
      }
! 
!     if (code != 0) {
! 	if (cell != NULL)
! 	    free(cell);
! 	if (username != NULL)
! 	    free(username);
! 	if (password != NULL)
! 	    free(password);
! 	fprintf(stderr,
! 		"UserToken::klog(): uafs_klog failed to cell %s: %s\n", cell,
! 		reason);
! 	fprintf(stderr, "code = %d\n", code);
! 	throwAFSException(env, code);
! 	return -1;
      }
  
!     /* Get the PAG we were assigned as the return value */
!     rc = afs_getpag_val();
! 
!     /* clean up */
!     if (cell != NULL)
! 	free(cell);
!     if (username != NULL)
! 	free(username);
!     if (password != NULL)
! 	free(password);
! 
!     /* return PAG ID */
!     return rc;
  }
  
  /**
--- 163,257 ----
   * throws AFSException
   */
  JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Token_klog (JNIEnv *env, jobject obj,
!   jstring jusername, jstring jpassword, jstring jcell, jint id)
  {
!   char *username;
!   char *password;
!   char *cell;
!   char *reason;
!   jint rc = -1;
!   int code;
! 
!   if( jcell != NULL ) { 
!     cell = (char*) (*env)->GetStringUTFChars(env, jcell, 0);
!     if( !cell ) {
!       char *error = "UserToken::klog(): failed to get cell name\n";
!       fprintf(stderr, error);
!       throwMessageException( env, error );
!       return -1;
      }
!   } else {
!     cell = NULL;
!   }
! 
!   if( jusername != NULL ) {
!     username = (char*) (*env)->GetStringUTFChars(env, jusername, 0);
!     if( !username ) {
!       char *error = "UserToken::klog(): failed to get username\n";
!       (*env)->ReleaseStringUTFChars(env, jcell, cell);
!       fprintf(stderr, error);
!       throwMessageException( env, error );
!       return -1;
      }
!   } else {
!     username = NULL;
!   }
!   if( jpassword != NULL ) {
!     password = (char*) (*env)->GetStringUTFChars(env, jpassword, 0);
!     if( !password ) {
!       char *error = "UserToken::klog(): failed to get password\n";
!       (*env)->ReleaseStringUTFChars(env, jcell, cell);
!       (*env)->ReleaseStringUTFChars(env, jusername, username);
!       fprintf(stderr, error);
!       throwMessageException( env, error );
!       return -1;
      }
!   } else {
!     password = NULL;
!   }
! 
!   if (id == 0) {
!     code = uafs_klog(username, cell, password, &reason);
!   } else {
!     /* Use existing PAG for this thread */
!     code = afs_setpag_val(id);
!     if (code != 0) code = 180492L;  /* KABADARGUMENT */
!     if (!code) code = uafs_klog_nopag(username, cell, password, &reason);
!   }
! 
!   if (code != 0) {
!     if( cell != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jcell, cell);
      }
!     if( username != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jusername, username);
      }
+     if( password != NULL ) {
+       (*env)->ReleaseStringUTFChars(env, jpassword, password);
+     }
+     fprintf(stderr, "UserToken::klog(): uafs_klog failed to cell %s: %s\n",
+                      cell, reason);
+     fprintf(stderr, "code = %d\n", code);
+     throwAFSException( env, code );
+   }
+ 
+   /* Get the PAG we were assigned as the return value */
+   rc = afs_getpag_val();
+ 
+   /* clean up */
+   if( cell != NULL ) {
+     (*env)->ReleaseStringUTFChars(env, jcell, cell);
+   }
+   if( username != NULL ) {
+     (*env)->ReleaseStringUTFChars(env, jusername, username);
+   }
+   if( password != NULL ) {
+     (*env)->ReleaseStringUTFChars(env, jpassword, password);
+   }
  
!   /* return PAG ID */
!   return rc;
  }
  
  /**
***************
*** 273,288 ****
   *
   * throws AFSException
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Token_relog(JNIEnv * env, jobject obj, jint id)
  {
!     int rc;
  
!     rc = afs_setpag_val(id);
  
!     if (rc != 0) {
! 	throwAFSException(env, rc);
!     }
  }
  
  /**
--- 268,283 ----
   *
   * throws AFSException
   */
! JNIEXPORT void JNICALL Java_org_openafs_jafs_Token_relog
!   (JNIEnv *env, jobject obj, jint id)
  {
!   int rc;
  
!   rc = afs_setpag_val(id);
  
!   if (rc != 0) {
!     throwAFSException( env, rc );
!   }
  }
  
  /**
***************
*** 294,309 ****
   *
   * throws AFSException
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Token_unlog(JNIEnv * env, jobject obj)
  {
!     int rc;
  
!     rc = uafs_unlog();
  
!     if (rc != 0) {
! 	throwAFSException(env, rc);
!     }
  }
  
  /**
--- 289,304 ----
   *
   * throws AFSException
   */
! JNIEXPORT void JNICALL Java_org_openafs_jafs_Token_unlog
!   (JNIEnv *env, jobject obj)
  {
!   int rc;
  
!   rc = uafs_unlog();
  
!   if (rc != 0) {
!     throwAFSException( env, rc );
!   }
  }
  
  /**
***************
*** 318,325 ****
   *
   * throws AFSException
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Token_shutdown(JNIEnv * env, jobject obj)
  {
!     uafs_Shutdown();
  }
--- 313,324 ----
   *
   * throws AFSException
   */
! JNIEXPORT void JNICALL Java_org_openafs_jafs_Token_shutdown
!   (JNIEnv *env, jobject obj)
  {
!   uafs_Shutdown();
  }
+ 
+ 
+ 
+ 
Index: openafs/src/JAVA/libjafs/Version2.c
diff -c /dev/null openafs/src/JAVA/libjafs/Version2.c:1.1.2.2
*** /dev/null	Sat Oct 22 02:14:46 2005
--- openafs/src/JAVA/libjafs/Version2.c	Fri Oct 14 22:14:12 2005
***************
*** 0 ****
--- 1,14 ----
+ #include "JAFS_Version.h"
+ #include "org_openafs_jafs_VersionInfo.h"
+ 
+ JNIEXPORT jstring JNICALL Java_org_openafs_jafs_VersionInfo_getVersionOfLibjafsadm
+   (JNIEnv *env, jobject obj)
+ {
+ 	return (*env)->NewStringUTF(env, VERSION_LIB_JAVA_OPENAFS);
+ }
+ 
+ JNIEXPORT jstring JNICALL Java_org_openafs_jafs_VersionInfo_getBuildInfoOfLibjafsadm
+   (JNIEnv *env, jobject obj)
+ {
+ 	return (*env)->NewStringUTF(env, cml_version_number);
+ }
Index: openafs/src/JAVA/libjafs/VersionInfo.c
diff -c /dev/null openafs/src/JAVA/libjafs/VersionInfo.c:1.1.2.2
*** /dev/null	Sat Oct 22 02:14:46 2005
--- openafs/src/JAVA/libjafs/VersionInfo.c	Fri Oct 14 22:14:12 2005
***************
*** 0 ****
--- 1,14 ----
+ #include "JAFS_Version.h"
+ #include "org_openafs_jafs_VersionInfo.h"
+  
+ JNIEXPORT jstring JNICALL Java_org_openafs_jafs_VersionInfo_getVersionOfLibjafs
+   (JNIEnv *env, jobject obj)
+ {
+ 	return (*env)->NewStringUTF(env, VERSION_LIB_JAVA_OPENAFS);
+ }
+ 
+ JNIEXPORT jstring JNICALL Java_org_openafs_jafs_VersionInfo_getBuildInfoOfLibjafs
+   (JNIEnv *env, jobject obj)
+ {
+ 	return (*env)->NewStringUTF(env, cml_version_number);
+ }
Index: openafs/src/JAVA/libjafs/Volume.c
diff -c openafs/src/JAVA/libjafs/Volume.c:1.3 openafs/src/JAVA/libjafs/Volume.c:1.3.2.1
*** openafs/src/JAVA/libjafs/Volume.c:1.3	Tue Jul 15 19:11:26 2003
--- openafs/src/JAVA/libjafs/Volume.c	Fri Oct 14 22:14:12 2005
***************
*** 56,223 ****
   * volume      the Volume object to populate with the info
   * volEntry     the container of the volume's information
   */
! extern void
! fillVolumeInfo(JNIEnv * env, jobject volume, vos_volumeEntry_t volEntry)
! {
!     jstring jvolume;
  
!     // get the class fields if need be
!     if (volumeCls == 0) {
! 	internal_getVolumeClass(env, volume);
!     }
!     // set name, just in case it was a completely blank object
!     jvolume = (*env)->NewStringUTF(env, volEntry.name);
!     (*env)->SetObjectField(env, volume, volume_nameField, jvolume);
! 
!     (*env)->SetIntField(env, volume, volume_idField, volEntry.id);
!     (*env)->SetIntField(env, volume, volume_readWriteIdField,
! 			volEntry.readWriteId);
!     (*env)->SetIntField(env, volume, volume_readOnlyIdField,
! 			volEntry.readOnlyId);
!     (*env)->SetIntField(env, volume, volume_backupIdField, volEntry.backupId);
!     (*env)->SetLongField(env, volume, volume_creationDateField,
! 			 volEntry.creationDate);
!     (*env)->SetLongField(env, volume, volume_lastAccessDateField,
! 			 volEntry.lastAccessDate);
!     (*env)->SetLongField(env, volume, volume_lastUpdateDateField,
! 			 volEntry.lastUpdateDate);
!     (*env)->SetLongField(env, volume, volume_lastBackupDateField,
! 			 volEntry.lastBackupDate);
!     (*env)->SetLongField(env, volume, volume_copyCreationDateField,
! 			 volEntry.copyCreationDate);
!     (*env)->SetIntField(env, volume, volume_accessesSinceMidnightField,
! 			volEntry.accessesSinceMidnight);
!     (*env)->SetIntField(env, volume, volume_fileCountField,
! 			volEntry.fileCount);
!     (*env)->SetIntField(env, volume, volume_maxQuotaField, volEntry.maxQuota);
!     (*env)->SetIntField(env, volume, volume_currentSizeField,
! 			volEntry.currentSize);
! 
!     // set status variable
!     switch (volEntry.status) {
!     case VOS_OK:
! 	(*env)->SetIntField(env, volume, volume_statusField,
! 			    org_openafs_jafs_Volume_VOLUME_OK);
! 	break;
!     case VOS_SALVAGE:
! 	(*env)->SetIntField(env, volume, volume_statusField,
! 			    org_openafs_jafs_Volume_VOLUME_SALVAGE);
! 	break;
!     case VOS_NO_VNODE:
! 	(*env)->SetIntField(env, volume, volume_statusField,
! 			    org_openafs_jafs_Volume_VOLUME_NO_VNODE);
! 	break;
!     case VOS_NO_VOL:
! 	(*env)->SetIntField(env, volume, volume_statusField,
! 			    org_openafs_jafs_Volume_VOLUME_NO_VOL);
! 	break;
!     case VOS_VOL_EXISTS:
! 	(*env)->SetIntField(env, volume, volume_statusField,
! 			    org_openafs_jafs_Volume_VOLUME_VOL_EXISTS);
! 	break;
!     case VOS_NO_SERVICE:
! 	(*env)->SetIntField(env, volume, volume_statusField,
! 			    org_openafs_jafs_Volume_VOLUME_NO_SERVICE);
! 	break;
!     case VOS_OFFLINE:
! 	(*env)->SetIntField(env, volume, volume_statusField,
! 			    org_openafs_jafs_Volume_VOLUME_OFFLINE);
! 	break;
!     case VOS_ONLINE:
! 	(*env)->SetIntField(env, volume, volume_statusField,
! 			    org_openafs_jafs_Volume_VOLUME_ONLINE);
! 	break;
!     case VOS_DISK_FULL:
! 	(*env)->SetIntField(env, volume, volume_statusField,
! 			    org_openafs_jafs_Volume_VOLUME_DISK_FULL);
! 	break;
!     case VOS_OVER_QUOTA:
! 	(*env)->SetIntField(env, volume, volume_statusField,
! 			    org_openafs_jafs_Volume_VOLUME_OVER_QUOTA);
! 	break;
!     case VOS_BUSY:
! 	(*env)->SetIntField(env, volume, volume_statusField,
! 			    org_openafs_jafs_Volume_VOLUME_BUSY);
! 	break;
!     case VOS_MOVED:
! 	(*env)->SetIntField(env, volume, volume_statusField,
! 			    org_openafs_jafs_Volume_VOLUME_MOVED);
! 	break;
!     default:
! 	throwAFSException(env, volEntry.status);
!     }
! 
!     // set disposition variable
!     switch (volEntry.volumeDisposition) {
!     case VOS_OK:
! 	(*env)->SetIntField(env, volume, volume_dispositionField,
! 			    org_openafs_jafs_Volume_VOLUME_OK);
! 	break;
!     case VOS_SALVAGE:
! 	(*env)->SetIntField(env, volume, volume_dispositionField,
! 			    org_openafs_jafs_Volume_VOLUME_SALVAGE);
! 	break;
!     case VOS_NO_VNODE:
! 	(*env)->SetIntField(env, volume, volume_dispositionField,
! 			    org_openafs_jafs_Volume_VOLUME_NO_VNODE);
! 	break;
!     case VOS_NO_VOL:
! 	(*env)->SetIntField(env, volume, volume_dispositionField,
! 			    org_openafs_jafs_Volume_VOLUME_NO_VOL);
! 	break;
!     case VOS_VOL_EXISTS:
! 	(*env)->SetIntField(env, volume, volume_dispositionField,
! 			    org_openafs_jafs_Volume_VOLUME_VOL_EXISTS);
! 	break;
!     case VOS_NO_SERVICE:
! 	(*env)->SetIntField(env, volume, volume_dispositionField,
! 			    org_openafs_jafs_Volume_VOLUME_NO_SERVICE);
! 	break;
!     case VOS_OFFLINE:
! 	(*env)->SetIntField(env, volume, volume_dispositionField,
! 			    org_openafs_jafs_Volume_VOLUME_OFFLINE);
! 	break;
!     case VOS_ONLINE:
! 	(*env)->SetIntField(env, volume, volume_dispositionField,
! 			    org_openafs_jafs_Volume_VOLUME_ONLINE);
! 	break;
!     case VOS_DISK_FULL:
! 	(*env)->SetIntField(env, volume, volume_dispositionField,
! 			    org_openafs_jafs_Volume_VOLUME_DISK_FULL);
! 	break;
!     case VOS_OVER_QUOTA:
! 	(*env)->SetIntField(env, volume, volume_dispositionField,
! 			    org_openafs_jafs_Volume_VOLUME_OVER_QUOTA);
! 	break;
!     case VOS_BUSY:
! 	(*env)->SetIntField(env, volume, volume_dispositionField,
! 			    org_openafs_jafs_Volume_VOLUME_BUSY);
! 	break;
!     case VOS_MOVED:
! 	(*env)->SetIntField(env, volume, volume_dispositionField,
! 			    org_openafs_jafs_Volume_VOLUME_MOVED);
! 	break;
!     default:
! 	throwAFSException(env, volEntry.volumeDisposition);
!     }
! 
!     // set type variable
!     switch (volEntry.type) {
!     case VOS_READ_WRITE_VOLUME:
! 	(*env)->SetIntField(env, volume, volume_typeField,
! 			    org_openafs_jafs_Volume_VOLUME_TYPE_READ_WRITE);
! 	break;
!     case VOS_READ_ONLY_VOLUME:
! 	(*env)->SetIntField(env, volume, volume_typeField,
! 			    org_openafs_jafs_Volume_VOLUME_TYPE_READ_ONLY);
! 	break;
!     case VOS_BACKUP_VOLUME:
! 	(*env)->SetIntField(env, volume, volume_typeField,
! 			    org_openafs_jafs_Volume_VOLUME_TYPE_BACKUP);
! 	break;
!     default:
! 	throwAFSException(env, volEntry.type);
!     }
  
  }
  
--- 56,223 ----
   * volume      the Volume object to populate with the info
   * volEntry     the container of the volume's information
   */
! extern void fillVolumeInfo( JNIEnv *env, jobject volume, 
! 			    vos_volumeEntry_t volEntry ) {
  
!   jstring jvolume;
! 
!   // get the class fields if need be
!   if( volumeCls == 0 ) {
!     internal_getVolumeClass( env, volume );
!   }
! 
!   // set name, just in case it was a completely blank object
!   jvolume = (*env)->NewStringUTF(env, volEntry.name);
!   (*env)->SetObjectField(env, volume, volume_nameField, jvolume);
! 
!   (*env)->SetIntField(env, volume, volume_idField, volEntry.id);
!   (*env)->SetIntField(env, volume, volume_readWriteIdField, 
! 		      volEntry.readWriteId);
!   (*env)->SetIntField(env, volume, volume_readOnlyIdField, 
! 		      volEntry.readOnlyId);
!   (*env)->SetIntField(env, volume, volume_backupIdField, volEntry.backupId);
!   (*env)->SetLongField(env, volume, volume_creationDateField, 
! 		       volEntry.creationDate);
!   (*env)->SetLongField(env, volume, volume_lastAccessDateField, 
! 		       volEntry.lastAccessDate);
!   (*env)->SetLongField(env, volume, volume_lastUpdateDateField, 
! 		       volEntry.lastUpdateDate);
!   (*env)->SetLongField(env, volume, volume_lastBackupDateField, 
! 		       volEntry.lastBackupDate);
!   (*env)->SetLongField(env, volume, volume_copyCreationDateField, 
! 		       volEntry.copyCreationDate);
!   (*env)->SetIntField(env, volume, volume_accessesSinceMidnightField, 
! 		      volEntry.accessesSinceMidnight);
!   (*env)->SetIntField(env, volume, volume_fileCountField, volEntry.fileCount);
!   (*env)->SetIntField(env, volume, volume_maxQuotaField, volEntry.maxQuota);
!   (*env)->SetIntField(env, volume, volume_currentSizeField, 
! 		      volEntry.currentSize);
! 
!   // set status variable
!   switch( volEntry.status ) {
!   case VOS_OK :
!       (*env)->SetIntField(env, volume, volume_statusField, 
! 			  org_openafs_jafs_Volume_VOLUME_OK);
!       break;
!   case VOS_SALVAGE :
!       (*env)->SetIntField(env, volume, volume_statusField, 
! 			  org_openafs_jafs_Volume_VOLUME_SALVAGE);
!       break;
!   case VOS_NO_VNODE:
!       (*env)->SetIntField(env, volume, volume_statusField, 
! 			  org_openafs_jafs_Volume_VOLUME_NO_VNODE);
!       break;
!   case VOS_NO_VOL:
!       (*env)->SetIntField(env, volume, volume_statusField, 
! 			  org_openafs_jafs_Volume_VOLUME_NO_VOL);
!       break;
!   case VOS_VOL_EXISTS:
!       (*env)->SetIntField(env, volume, volume_statusField, 
! 			  org_openafs_jafs_Volume_VOLUME_VOL_EXISTS);
!       break;
!   case VOS_NO_SERVICE:
!       (*env)->SetIntField(env, volume, volume_statusField, 
! 			  org_openafs_jafs_Volume_VOLUME_NO_SERVICE);
!       break;
!   case VOS_OFFLINE:
!       (*env)->SetIntField(env, volume, volume_statusField, 
! 			  org_openafs_jafs_Volume_VOLUME_OFFLINE);
!       break;
!   case VOS_ONLINE:
!       (*env)->SetIntField(env, volume, volume_statusField, 
! 			  org_openafs_jafs_Volume_VOLUME_ONLINE);
!       break;
!   case VOS_DISK_FULL:
!       (*env)->SetIntField(env, volume, volume_statusField, 
! 			  org_openafs_jafs_Volume_VOLUME_DISK_FULL);
!       break;
!   case VOS_OVER_QUOTA:
!       (*env)->SetIntField(env, volume, volume_statusField, 
! 			  org_openafs_jafs_Volume_VOLUME_OVER_QUOTA);
!       break;
!   case VOS_BUSY:
!       (*env)->SetIntField(env, volume, volume_statusField, 
! 			  org_openafs_jafs_Volume_VOLUME_BUSY);
!       break;
!   case VOS_MOVED:
!       (*env)->SetIntField(env, volume, volume_statusField, 
! 			  org_openafs_jafs_Volume_VOLUME_MOVED);
!       break;
!   default:
!       throwAFSException( env, volEntry.status );
!   }
! 
!   // set disposition variable
!   switch( volEntry.volumeDisposition ) {
!   case VOS_OK :
!       (*env)->SetIntField(env, volume, volume_dispositionField, 
! 			  org_openafs_jafs_Volume_VOLUME_OK);
!       break;
!   case VOS_SALVAGE :
!       (*env)->SetIntField(env, volume, volume_dispositionField, 
! 			  org_openafs_jafs_Volume_VOLUME_SALVAGE);
!       break;
!   case VOS_NO_VNODE:
!       (*env)->SetIntField(env, volume, volume_dispositionField, 
! 			  org_openafs_jafs_Volume_VOLUME_NO_VNODE);
!       break;
!   case VOS_NO_VOL:
!       (*env)->SetIntField(env, volume, volume_dispositionField, 
! 			  org_openafs_jafs_Volume_VOLUME_NO_VOL);
!       break;
!   case VOS_VOL_EXISTS:
!       (*env)->SetIntField(env, volume, volume_dispositionField, 
! 			  org_openafs_jafs_Volume_VOLUME_VOL_EXISTS);
!       break;
!   case VOS_NO_SERVICE:
!       (*env)->SetIntField(env, volume, volume_dispositionField, 
! 			  org_openafs_jafs_Volume_VOLUME_NO_SERVICE);
!       break;
!   case VOS_OFFLINE:
!       (*env)->SetIntField(env, volume, volume_dispositionField, 
! 			  org_openafs_jafs_Volume_VOLUME_OFFLINE);
!       break;
!   case VOS_ONLINE:
!       (*env)->SetIntField(env, volume, volume_dispositionField, 
! 			  org_openafs_jafs_Volume_VOLUME_ONLINE);
!       break;
!   case VOS_DISK_FULL:
!       (*env)->SetIntField(env, volume, volume_dispositionField, 
! 			  org_openafs_jafs_Volume_VOLUME_DISK_FULL);
!       break;
!   case VOS_OVER_QUOTA:
!       (*env)->SetIntField(env, volume, volume_dispositionField, 
! 			  org_openafs_jafs_Volume_VOLUME_OVER_QUOTA);
!       break;
!   case VOS_BUSY:
!       (*env)->SetIntField(env, volume, volume_dispositionField, 
! 			  org_openafs_jafs_Volume_VOLUME_BUSY);
!       break;
!   case VOS_MOVED:
!       (*env)->SetIntField(env, volume, volume_dispositionField, 
! 			  org_openafs_jafs_Volume_VOLUME_MOVED);
!       break;
!   default:
!       throwAFSException( env, volEntry.volumeDisposition );
!   }
! 
!   // set type variable
!   switch( volEntry.type ) {
!   case VOS_READ_WRITE_VOLUME:
!       (*env)->SetIntField(env, volume, volume_typeField, 
! 			  org_openafs_jafs_Volume_VOLUME_TYPE_READ_WRITE);
!       break;
!   case VOS_READ_ONLY_VOLUME:
!       (*env)->SetIntField(env, volume, volume_typeField, 
! 			  org_openafs_jafs_Volume_VOLUME_TYPE_READ_ONLY);
!       break;
!   case VOS_BACKUP_VOLUME:
!       (*env)->SetIntField(env, volume, volume_typeField, 
! 			  org_openafs_jafs_Volume_VOLUME_TYPE_BACKUP);
!       break;
!   default:
!       throwAFSException( env, volEntry.type );
!   }
  
  }
  
***************
*** 235,258 ****
   * jvolumeObject   the Volume object in which to fill in 
   *                        the information
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Volume_getVolumeInfo(JNIEnv * env, jclass cls,
! 					   jint cellHandle, jint serverHandle,
! 					   jint partition, jint volID,
! 					   jobject jvolumeObject)
! {
!     afs_status_t ast;
!     vos_volumeEntry_t volEntry;
  
!     // get the volume entry
!     if (!vos_VolumeGet
! 	((void *)cellHandle, (void *)serverHandle, NULL,
! 	 (unsigned int)partition, (unsigned int)volID, &volEntry, &ast)) {
! 	throwAFSException(env, ast);
! 	return;
!     }
  
-     fillVolumeInfo(env, jvolumeObject, volEntry);
  }
  
  /**
--- 235,260 ----
   * jvolumeObject   the Volume object in which to fill in 
   *                        the information
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Volume_getVolumeInfo (JNIEnv *env, jclass cls, 
! 					       jlong cellHandle, 
! 					       jlong serverHandle, 
! 					       jint partition, jint volID, 
! 					       jobject jvolumeObject) {
! 
!   afs_status_t ast;
!   vos_volumeEntry_t volEntry;
! 
!   // get the volume entry
!   if ( !vos_VolumeGet( (void *) cellHandle, (void *) serverHandle, NULL, 
! 		       (unsigned int) partition, (unsigned int) volID, 
! 		       &volEntry, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
!   fillVolumeInfo( env, jvolumeObject, volEntry );
  
  }
  
  /**
***************
*** 269,303 ****
   * quota    the amount of space (in KB) to set as this volume's quota
   * returns the numeric ID assigned to the volume
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Volume_create(JNIEnv * env, jclass cls, jint cellHandle,
! 				    jint serverHandle, jint partition,
! 				    jstring jvolName, jint quota)
! {
!     afs_status_t ast;
!     char *volName;
!     int id;
! 
!     if (jvolName != NULL) {
! 	volName = getNativeString(env, jvolName);
! 	if (!volName) {
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return -1;
! 	}
!     } else {
! 	throwAFSException(env, JAFSNULLVOLUME);
! 	return -1;
!     }
! 
!     if (!vos_VolumeCreate
! 	((void *)cellHandle, (void *)serverHandle, NULL,
! 	 (unsigned int)partition, volName, (unsigned int)quota, &id, &ast)) {
! 	throwAFSException(env, ast);
!     }
! 
!     free(volName);
  
-     return (jint) id;
  }
  
  /**
--- 271,311 ----
   * quota    the amount of space (in KB) to set as this volume's quota
   * returns the numeric ID assigned to the volume
   */
! JNIEXPORT jint JNICALL 
! Java_org_openafs_jafs_Volume_create (JNIEnv *env, jclass cls, 
! 					jlong cellHandle, jlong serverHandle, 
! 					jint partition, jstring jvolName, 
! 					jint quota) {
! 
!   afs_status_t ast;
!   const char *volName;
!   int id;
! 
!   if( jvolName != NULL ) {
!     volName = (*env)->GetStringUTFChars(env, jvolName, 0);
!     if( !volName ) {
! 	throwAFSException( env, JAFSADMNOMEM );
! 	return;    
!     }
!   } else {
!     volName = NULL;
!   }
! 
!   if( !vos_VolumeCreate( (void *) cellHandle, (void *) serverHandle, NULL, 
! 			 (unsigned int) partition, volName, 
! 			 (unsigned int) quota, &id, &ast ) ) {
!     if( volName != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jvolName, volName);
!     }
!     throwAFSException( env, ast );
!     return;
!   }
! 
!   if( volName != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, jvolName, volName);
!   }
!   return (jint) id;
  
  }
  
  /**
***************
*** 312,330 ****
   *                    the volume
   * volId   the numeric id of the volume to delete
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Volume_delete(JNIEnv * env, jclass cls, jint cellHandle,
! 				    jint serverHandle, jint partition,
! 				    jint volID)
! {
!     afs_status_t ast;
  
-     if (!vos_VolumeDelete
- 	((void *)cellHandle, (void *)serverHandle, NULL,
- 	 (unsigned int)partition, (unsigned int)volID, &ast)) {
- 	throwAFSException(env, ast);
- 	return;
-     }
  }
  
  /**
--- 320,339 ----
   *                    the volume
   * volId   the numeric id of the volume to delete
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Volume_delete (JNIEnv *env, jclass cls, 
! 					jlong cellHandle, jlong serverHandle, 
! 					jint partition, jint volID) {
! 
!   afs_status_t ast;
! 
!   if( !vos_VolumeDelete( (void *) cellHandle, (void *) serverHandle, NULL, 
! 			 (unsigned int) partition, 
! 			 (unsigned int) volID, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
  }
  
  /**
***************
*** 336,352 ****
   * volId  the numeric id of the volume for which to create a backup 
   *               volume
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Volume_createBackupVolume(JNIEnv * env, jclass cls,
! 						jint cellHandle, jint volID)
! {
!     afs_status_t ast;
  
-     if (!vos_BackupVolumeCreate
- 	((void *)cellHandle, NULL, (unsigned int)volID, &ast)) {
- 	throwAFSException(env, ast);
- 	return;
-     }
  }
  
  /**
--- 345,363 ----
   * volId  the numeric id of the volume for which to create a backup 
   *               volume
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Volume_createBackupVolume (JNIEnv *env, jclass cls, 
! 						    jlong cellHandle, 
! 						    jint volID) {
! 
!   afs_status_t ast;
! 
!   if( !vos_BackupVolumeCreate( (void *) cellHandle, NULL, 
! 			       (unsigned int) volID, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
  }
  
  /**
***************
*** 362,381 ****
   * volId  the numeric id of the volume for which to 
   *               create a read-only volume
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Volume_createReadOnlyVolume(JNIEnv * env, jclass cls,
! 						  jint cellHandle,
! 						  jint serverHandle,
! 						  jint partition, jint volID)
! {
!     afs_status_t ast;
  
-     if (!vos_VLDBReadOnlySiteCreate
- 	((void *)cellHandle, (void *)serverHandle, NULL,
- 	 (unsigned int)partition, (unsigned int)volID, &ast)) {
- 	throwAFSException(env, ast);
- 	return;
-     }
  }
  
  /**
--- 373,394 ----
   * volId  the numeric id of the volume for which to 
   *               create a read-only volume
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Volume_createReadOnlyVolume (JNIEnv *env, jclass cls, 
! 						      jlong cellHandle, 
! 						      jlong serverHandle, 
! 						      jint partition, 
! 						      jint volID) {
! 
!   afs_status_t ast;
! 
!   if( !vos_VLDBReadOnlySiteCreate( (void *) cellHandle, (void *) serverHandle, 
! 				   NULL, (unsigned int) partition, 
! 				   (unsigned int) volID, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
  }
  
  /**
***************
*** 391,410 ****
   * volId  the numeric read-write id of the volume for which to 
   *               delete the read-only volume
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Volume_deleteReadOnlyVolume(JNIEnv * env, jclass cls,
! 						  jint cellHandle,
! 						  jint serverHandle,
! 						  jint partition, jint volID)
! {
!     afs_status_t ast;
  
-     if (!vos_VLDBReadOnlySiteDelete
- 	((void *)cellHandle, (void *)serverHandle, NULL,
- 	 (unsigned int)partition, (unsigned int)volID, &ast)) {
- 	throwAFSException(env, ast);
- 	return;
-     }
  }
  
  /**
--- 404,425 ----
   * volId  the numeric read-write id of the volume for which to 
   *               delete the read-only volume
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Volume_deleteReadOnlyVolume (JNIEnv *env, jclass cls, 
! 						      jlong cellHandle, 
! 						      jlong serverHandle, 
! 						      jint partition, 
! 						      jint volID) {
! 
!   afs_status_t ast;
! 
!   if( !vos_VLDBReadOnlySiteDelete( (void *) cellHandle, (void *) serverHandle, 
! 				   NULL, (unsigned int) partition, 
! 				   (unsigned int) volID, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
  }
  
  /**
***************
*** 420,440 ****
   * volId  the numeric id of the volume for which to change the quota
   * newQuota    the new quota (in KB) to assign the volume
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Volume_changeQuota(JNIEnv * env, jclass cls,
! 					 jint cellHandle, jint serverHandle,
! 					 jint partition, jint volID,
! 					 jint newQuota)
! {
!     afs_status_t ast;
  
-     if (!vos_VolumeQuotaChange
- 	((void *)cellHandle, (void *)serverHandle, NULL,
- 	 (unsigned int)partition, (unsigned int)volID, (unsigned int)newQuota,
- 	 &ast)) {
- 	throwAFSException(env, ast);
- 	return;
-     }
  }
  
  /**
--- 435,457 ----
   * volId  the numeric id of the volume for which to change the quota
   * newQuota    the new quota (in KB) to assign the volume
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Volume_changeQuota (JNIEnv *env, jclass cls, 
! 					     jlong cellHandle, 
! 					     jlong serverHandle, 
! 					     jint partition, jint volID, 
! 					     jint newQuota) {
! 
!   afs_status_t ast;
! 
!   if( !vos_VolumeQuotaChange( (void *) cellHandle, (void *) serverHandle, 
! 			      NULL, (unsigned int) partition, 
! 			      (unsigned int) volID, (unsigned int) newQuota, 
! 			      &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
  }
  
  /**
***************
*** 453,473 ****
   *                      should be moved
   * volId  the numeric id of the volume to move
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Volume_move(JNIEnv * env, jclass cls, jint cellHandle,
! 				  jint fromServerHandle, jint fromPartition,
! 				  jint toServerHandle, jint toPartition,
! 				  jint volID)
! {
!     afs_status_t ast;
  
-     if (!vos_VolumeMove
- 	((void *)cellHandle, NULL, (unsigned int)volID,
- 	 (void *)fromServerHandle, (unsigned int)fromPartition,
- 	 (void *)toServerHandle, (unsigned int)toPartition, &ast)) {
- 	throwAFSException(env, ast);
- 	return;
-     }
  }
  
  /**
--- 470,490 ----
   *                      should be moved
   * volId  the numeric id of the volume to move
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Volume_move
!   (JNIEnv *env, jclass cls, jlong cellHandle, jlong fromServerHandle, 
!    jint fromPartition, jlong toServerHandle, jint toPartition, jint volID)
! {
!   afs_status_t ast;
! 
!   if( !vos_VolumeMove( (void *) cellHandle, NULL, (unsigned int) volID, 
! 		       (void *) fromServerHandle, (unsigned int) fromPartition,
! 		       (void *) toServerHandle, (unsigned int) toPartition, 
! 		       &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
  }
  
  /**
***************
*** 479,503 ****
   * volId  the numeric id of the volume to release
   * forceComplete  whether or not to force a complete release
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Volume_release(JNIEnv * env, jclass cls,
! 				     jint cellHandle, jint volID,
! 				     jboolean forceComplete)
! {
!     afs_status_t ast;
!     vos_force_t force;
! 
!     if (forceComplete) {
! 	force = VOS_FORCE;
!     } else {
! 	force = VOS_NORMAL;
!     }
  
-     if (!vos_VolumeRelease
- 	((void *)cellHandle, NULL, (unsigned int)volID, force, &ast)) {
- 	throwAFSException(env, ast);
- 	return;
-     }
  }
  
  /**
--- 496,520 ----
   * volId  the numeric id of the volume to release
   * forceComplete  whether or not to force a complete release
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Volume_release
!   (JNIEnv *env, jclass cls, jlong cellHandle, jint volID, jboolean forceComplete)
! {
!   afs_status_t ast;
!   vos_force_t force;
! 
!   if( forceComplete ) {
!     force = VOS_FORCE;
!   } else {
!     force = VOS_NORMAL;
!   }
! 
!   if( !vos_VolumeRelease( (void *) cellHandle, NULL, (unsigned int) volID,
!                           force, &ast )) {
!     throwAFSException( env, ast );
!     return;
!   }
  
  }
  
  /**
***************
*** 515,548 ****
   *                    be dumped
   * jdumpFile   the full path of the file to which to dump
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Volume_dump(JNIEnv * env, jclass cls, jint cellHandle,
! 				  jint serverHandle, jint partition,
! 				  jint volID, jint startTime,
! 				  jstring jdumpFile)
! {
!     afs_status_t ast;
!     char *dumpFile;
! 
!     if (jdumpFile != NULL) {
! 	dumpFile = getNativeString(env, jdumpFile);
! 	if (!dumpFile) {
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	throwAFSException(env, JAFSNULLARG);
! 	return;
!     }
! 
!     if (!vos_VolumeDump
! 	((void *)cellHandle, (void *)serverHandle, NULL,
! 	 (unsigned int *)&partition, (unsigned int)volID,
! 	 (unsigned int)startTime, dumpFile, &ast)) {
! 	throwAFSException(env, ast);
!     }
  
-     free(dumpFile);
  }
  
  /**
--- 532,570 ----
   *                    be dumped
   * jdumpFile   the full path of the file to which to dump
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Volume_dump (JNIEnv *env, jclass cls, 
! 				      jlong cellHandle, jlong serverHandle, 
! 				      jint partition, jint volID, 
! 				      jint startTime, jstring jdumpFile) {
! 
!   afs_status_t ast;
!   const char *dumpFile;
! 
!   if( jdumpFile != NULL ) {
!     dumpFile = (*env)->GetStringUTFChars(env, jdumpFile, 0);
!     if( !dumpFile ) {
! 	throwAFSException( env, JAFSADMNOMEM );
! 	return;    
!     }
!   } else {
!     dumpFile = NULL;
!   }
! 
!   if( !vos_VolumeDump( (void *) cellHandle, (void *) serverHandle, NULL, 
! 		       (unsigned int *) &partition, (unsigned int) volID, 
! 		       (unsigned int) startTime, dumpFile, &ast ) ) {
!     if( dumpFile != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jdumpFile, dumpFile);
!     }
!     throwAFSException( env, ast );
!     return;
!   }
! 
!   if( dumpFile != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, jdumpFile, dumpFile);
!   }
  
  }
  
  /**
***************
*** 563,625 ****
   *                     indicate the current position of the existing volume),
   *                     otherwise restores a full dump
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Volume_restore(JNIEnv * env, jclass cls,
! 				     jint cellHandle, jint serverHandle,
! 				     jint partition, jint volID,
! 				     jstring jvolName, jstring jdumpFile,
! 				     jboolean incremental)
! {
!     afs_status_t ast;
!     char *volName;
!     char *dumpFile;
!     int *volumeIDp;
!     vos_volumeRestoreType_t vrt;
! 
!     if (jvolName != NULL) {
! 	volName = getNativeString(env, jvolName);
! 	if (!volName) {
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	throwAFSException(env, JAFSNULLVOLUME);
! 	return;
!     }
! 
!     if (jdumpFile != NULL) {
! 	dumpFile = getNativeString(env, jdumpFile);
! 	if (!dumpFile) {
! 	    free(volName);
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	dumpFile = NULL;
!     }
! 
!     if (volID == 0) {
! 	volumeIDp = NULL;
!     } else {
! 	volumeIDp = (int *)&volID;
!     }
! 
!     if (incremental) {
! 	vrt = VOS_RESTORE_INCREMENTAL;
!     } else {
! 	vrt = VOS_RESTORE_FULL;
!     }
! 
!     if (!vos_VolumeRestore
! 	((void *)cellHandle, (void *)serverHandle, NULL,
! 	 (unsigned int)partition, (unsigned int *)volumeIDp, volName,
! 	 dumpFile, vrt, &ast)) {
! 	throwAFSException(env, ast);
!     }
! 
!     if (dumpFile != NULL)
! 	free(dumpFile);
!     free(volName);
  }
  
  /**
--- 585,658 ----
   *                     indicate the current position of the existing volume),
   *                     otherwise restores a full dump
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Volume_restore (JNIEnv *env, jclass cls, 
! 					 jlong cellHandle, jlong serverHandle, 
! 					 jint partition, jint volID, 
! 					 jstring jvolName, jstring jdumpFile, 
! 					 jboolean incremental) {
! 
!   afs_status_t ast;
!   const char *volName;
!   const char *dumpFile;
!   int *volumeIDp;
!   vos_volumeRestoreType_t vrt;
! 
!   if( jvolName != NULL ) {
!     volName = (*env)->GetStringUTFChars(env, jvolName, 0);
!     if( !volName ) {
! 	throwAFSException( env, JAFSADMNOMEM );
! 	return;    
!     }
!   } else {
!     volName = NULL;
!   }
! 
!   if( jdumpFile != NULL ) {
!     dumpFile = (*env)->GetStringUTFChars(env, jdumpFile, 0);
!     if( !dumpFile ) {
!       if( volName != NULL ) {
! 	(*env)->ReleaseStringUTFChars(env, jvolName, volName);
!       }
!       throwAFSException( env, JAFSADMNOMEM );
!       return;    
!     }
!   } else {
!     dumpFile = NULL;
!   }
! 
!   if( volID == 0 ) {
!     volumeIDp = NULL;
!   } else {
!     volumeIDp = (int *) &volID;
!   }
!   
!   if( incremental ) {
!     vrt = VOS_RESTORE_INCREMENTAL;
!   } else {
!     vrt = VOS_RESTORE_FULL;
!   }
! 
!   if( !vos_VolumeRestore( (void *) cellHandle, (void *) serverHandle, NULL, 
! 			  (unsigned int) partition, (unsigned int *) volumeIDp,
! 			  volName, dumpFile, vrt, &ast ) ) {
!     if( volName != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jvolName, volName);
!     }
!     if( dumpFile != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jdumpFile, dumpFile);
!     }
!     throwAFSException( env, ast );
!     return;
!   }
! 
!   if( dumpFile != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, jdumpFile, dumpFile);
!   }
!   if( volName != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, jvolName, volName);
!   }
! 
  }
  
  /**
***************
*** 631,660 ****
   * volId  the numeric id of the read-write volume to rename
   * jnewName  the new name for the volume
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Volume_rename(JNIEnv * env, jclass cls, jint cellHandle,
! 				    jint volID, jstring jnewName)
! {
!     afs_status_t ast;
!     char *newName;
! 
!     if (jnewName != NULL) {
! 	newName = getNativeString(env, jnewName);
! 	if (!newName) {
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return;
! 	}
!     } else {
! 	throwAFSException(env, JAFSNULLVOLUME);
! 	return;
!     }
! 
!     if (!vos_VolumeRename
! 	((void *)cellHandle, NULL, (unsigned int)volID, newName, &ast)) {
! 	throwAFSException(env, ast);
!     }
  
-     free(newName);
  }
  
  /**
--- 664,700 ----
   * volId  the numeric id of the read-write volume to rename
   * jnewName  the new name for the volume
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Volume_rename (JNIEnv *env, jclass cls, 
! 					jlong cellHandle, jint volID, 
! 					jstring jnewName) {
! 
!   afs_status_t ast;
!   const char *newName;
! 
!   if( jnewName != NULL ) {
!     newName = (*env)->GetStringUTFChars(env, jnewName, 0);
!     if( !newName ) {
! 	throwAFSException( env, JAFSADMNOMEM );
! 	return;    
!     }
!   } else {
!     newName = NULL;
!   }
! 
!   if( !vos_VolumeRename( (void *) cellHandle, NULL, (unsigned int) volID, 
! 			 newName, &ast ) ) {
!     if( newName != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jnewName, newName);
!     }
!     throwAFSException( env, ast );
!     return;
!   }
! 
!   if( newName != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, jnewName, newName);
!   }
  
  }
  
  /**
***************
*** 672,698 ****
   * offline   ?  (not sure what this is either, probably the current 
   *                     status of the volume -- busy or offline)
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Volume_mount(JNIEnv * env, jclass cls,
! 				   jint serverHandle, jint partition,
! 				   jint volID, jint sleepTime,
! 				   jboolean offline)
! {
!     afs_status_t ast;
!     vos_volumeOnlineType_t volumeStatus;
! 
!     if (offline) {
! 	volumeStatus = VOS_ONLINE_OFFLINE;
!     } else {
! 	volumeStatus = VOS_ONLINE_BUSY;
!     }
  
-     if (!vos_VolumeOnline
- 	((void *)serverHandle, NULL, (unsigned int)partition,
- 	 (unsigned int)volID, (unsigned int)sleepTime, volumeStatus, &ast)) {
- 	throwAFSException(env, ast);
- 	return;
-     }
  }
  
  /**
--- 712,739 ----
   * offline   ?  (not sure what this is either, probably the current 
   *                     status of the volume -- busy or offline)
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Volume_mount (JNIEnv *env, jclass cls, 
! 				       jlong serverHandle, jint partition, 
! 				       jint volID, jint sleepTime, 
! 				       jboolean offline) {
! 
!   afs_status_t ast;
!   vos_volumeOnlineType_t volumeStatus;
! 
!   if( offline ) {
!     volumeStatus = VOS_ONLINE_OFFLINE;
!   } else {
!     volumeStatus = VOS_ONLINE_BUSY;
!   }
! 
!   if( !vos_VolumeOnline( (void *) serverHandle, NULL, (unsigned int) partition,
! 			 (unsigned int) volID, (unsigned int) sleepTime, 
! 			 volumeStatus, &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
  }
  
  /**
***************
*** 706,724 ****
   *                    resides
   * volId  the numeric id of the volume to bring offline
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Volume_unmount(JNIEnv * env, jclass cls,
! 				     jint serverHandle, jint partition,
! 				     jint volID)
! {
!     afs_status_t ast;
  
-     if (!vos_VolumeOffline
- 	((void *)serverHandle, NULL, (unsigned int)partition,
- 	 (unsigned int)volID, &ast)) {
- 	throwAFSException(env, ast);
- 	return;
-     }
  }
  
  /**
--- 747,766 ----
   *                    resides
   * volId  the numeric id of the volume to bring offline
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Volume_unmount (JNIEnv *env, jclass cls, 
! 					 jlong serverHandle, jint partition, 
! 					 jint volID) {
! 
!   afs_status_t ast;
! 
!   if( !vos_VolumeOffline( (void *) serverHandle, NULL, 
! 			  (unsigned int) partition, (unsigned int) volID, 
! 			  &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
  }
  
  /**
***************
*** 729,745 ****
   * cellHandle  the handle of the cell on which the volume resides
   * volId  the numeric id of the volume to lock
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Volume_lock(JNIEnv * env, jclass cls, jint cellHandle,
! 				  jint volID)
! {
!     afs_status_t ast;
  
-     if (!vos_VLDBEntryLock
- 	((void *)cellHandle, NULL, (unsigned int)volID, &ast)) {
- 	throwAFSException(env, ast);
- 	return;
-     }
  }
  
  /**
--- 771,788 ----
   * cellHandle  the handle of the cell on which the volume resides
   * volId  the numeric id of the volume to lock
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Volume_lock (JNIEnv *env, jclass cls, 
! 				      jlong cellHandle, jint volID ) {
! 
!   afs_status_t ast;
! 
!   if( !vos_VLDBEntryLock( (void *) cellHandle, NULL, (unsigned int) volID, 
! 			  &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
  }
  
  /**
***************
*** 750,766 ****
   * cellHandle  the handle of the cell on which the volume resides
   * volId  the numeric id of the volume to unlock
   */
! JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Volume_unlock(JNIEnv * env, jclass cls, jint cellHandle,
! 				    jint volID)
! {
!     afs_status_t ast;
  
-     if (!vos_VLDBEntryUnlock
- 	((void *)cellHandle, NULL, (unsigned int)volID, &ast)) {
- 	throwAFSException(env, ast);
- 	return;
-     }
  }
  
  /**
--- 793,810 ----
   * cellHandle  the handle of the cell on which the volume resides
   * volId  the numeric id of the volume to unlock
   */
! JNIEXPORT void JNICALL 
! Java_org_openafs_jafs_Volume_unlock (JNIEnv *env, jclass cls, 
! 					jlong cellHandle, jint volID) {
! 
!   afs_status_t ast;
! 
!   if( !vos_VLDBEntryUnlock( (void *) cellHandle, NULL, (unsigned int) volID, 
! 			    &ast ) ) {
!     throwAFSException( env, ast );
!     return;
!   }
  
  }
  
  /**
***************
*** 778,829 ****
   *              org_openafs_jafs_Volume_VOLUME_TYPE_BACKUP
   * returns   the id of the volume in question
   */
! JNIEXPORT jint JNICALL
! Java_org_openafs_jafs_Volume_translateNameToID(JNIEnv * env, jclass cls,
! 					       jint cellHandle, jstring jname,
! 					       jint type)
! {
!     afs_status_t ast;
!     char *name;
!     vos_vldbEntry_t vldbEntry;
! 
!     if (jname != NULL) {
! 	name = getNativeString(env, jname);
! 	if (!name) {
! 	    throwAFSException(env, JAFSADMNOMEM);
! 	    return -1;
! 	}
!     } else {
! 	throwAFSException(env, JAFSNULLVOLUME);
! 	return -1;
!     }
! 
!     // get the id
!     if (!vos_VLDBGet((void *)cellHandle, NULL, NULL, name, &vldbEntry, &ast)) {
! 	free(name);
! 	throwAFSException(env, ast);
! 	return -1;
!     }
! 
!     free(name);
! 
!     if (type == org_openafs_jafs_Volume_VOLUME_TYPE_READ_WRITE) {
! 	return vldbEntry.volumeId[VOS_READ_WRITE_VOLUME];
!     } else if (type == org_openafs_jafs_Volume_VOLUME_TYPE_READ_ONLY) {
! 	return vldbEntry.volumeId[VOS_READ_ONLY_VOLUME];
!     } else {
! 	return vldbEntry.volumeId[VOS_BACKUP_VOLUME];
!     }
  
  }
  
  
  // reclaim global memory being used by this portion
  JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Volume_reclaimVolumeMemory(JNIEnv * env, jclass cls)
! {
!     if (volumeCls) {
! 	(*env)->DeleteGlobalRef(env, volumeCls);
! 	volumeCls = 0;
!     }
  }
--- 822,901 ----
   *              org_openafs_jafs_Volume_VOLUME_TYPE_BACKUP
   * returns   the id of the volume in question
   */
! JNIEXPORT jint JNICALL 
! Java_org_openafs_jafs_Volume_translateNameToID (JNIEnv *env, jclass cls, 
! 						   jlong cellHandle, 
! 						   jstring jname, jint type) {
! 
!   afs_status_t ast;
!   const char *name;
!   vos_vldbEntry_t vldbEntry;
! 
!   if( jname != NULL ) {
!     name = (*env)->GetStringUTFChars(env, jname, 0);
!     if( !name ) {
! 	throwAFSException( env, JAFSADMNOMEM );
! 	return;    
!     }
!   } else {
!     name = NULL;
!   }
! 
!   // get the id
!   if( !vos_VLDBGet( (void *) cellHandle, NULL, NULL, name, 
! 		    &vldbEntry, &ast ) ) {
!     if( name != NULL ) {
!       (*env)->ReleaseStringUTFChars(env, jname, name);
!     }
!     throwAFSException( env, ast );
!     return -1;
!   } 
! 
!   if( name != NULL ) {
!     (*env)->ReleaseStringUTFChars(env, jname, name);
!   }
! 
!   if( type == org_openafs_jafs_Volume_VOLUME_TYPE_READ_WRITE ) {
!     return vldbEntry.volumeId[VOS_READ_WRITE_VOLUME];
!   } else if( type == org_openafs_jafs_Volume_VOLUME_TYPE_READ_ONLY ) {
!     return vldbEntry.volumeId[VOS_READ_ONLY_VOLUME];
!   } else {
!     return vldbEntry.volumeId[VOS_BACKUP_VOLUME];
!   }
  
  }
  
  
  // reclaim global memory being used by this portion
  JNIEXPORT void JNICALL
! Java_org_openafs_jafs_Volume_reclaimVolumeMemory (JNIEnv *env, jclass cls) {
! 
!   if( volumeCls ) {
!       (*env)->DeleteGlobalRef(env, volumeCls);
!       volumeCls = 0;
!   }
! 
  }
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
Index: openafs/src/WINNT/afsd/afsd_init.c
diff -c openafs/src/WINNT/afsd/afsd_init.c:1.40.2.24.2.1 openafs/src/WINNT/afsd/afsd_init.c:1.40.2.26
*** openafs/src/WINNT/afsd/afsd_init.c:1.40.2.24.2.1	Mon Oct 17 15:35:44 2005
--- openafs/src/WINNT/afsd/afsd_init.c	Mon Oct 17 15:33:04 2005
***************
*** 566,571 ****
--- 566,572 ----
      WSAStartup(0x0101, &WSAjunk);
  
      afsd_initUpperCaseTable();
+     init_et_to_sys_error();
  
      /* setup osidebug server at RPC slot 1000 */
      osi_LongToUID(1000, &debugID);
Index: openafs/src/WINNT/afsd/cm.h
diff -c openafs/src/WINNT/afsd/cm.h:1.9.2.2.4.1 openafs/src/WINNT/afsd/cm.h:1.9.2.5
*** openafs/src/WINNT/afsd/cm.h:1.9.2.2.4.1	Thu Oct  6 22:25:09 2005
--- openafs/src/WINNT/afsd/cm.h	Sat Oct 15 17:48:22 2005
***************
*** 251,256 ****
  #define CM_ERROR_TIDIPC                 (CM_ERROR_BASE+44)
  #define CM_ERROR_TOO_MANY_SYMLINKS      (CM_ERROR_BASE+45)
  #define CM_ERROR_PATH_NOT_COVERED       (CM_ERROR_BASE+46)
! /* 47 and 48 are reserved for the byte range lock support */
  #define CM_ERROR_ALLDOWN                (CM_ERROR_BASE+49)
  #endif /*  __CM_H_ENV__ */
--- 251,259 ----
  #define CM_ERROR_TIDIPC                 (CM_ERROR_BASE+44)
  #define CM_ERROR_TOO_MANY_SYMLINKS      (CM_ERROR_BASE+45)
  #define CM_ERROR_PATH_NOT_COVERED       (CM_ERROR_BASE+46)
! #define CM_ERROR_LOCK_CONFLICT          (CM_ERROR_BASE+47)
! #define CM_ERROR_SHARING_VIOLATION      (CM_ERROR_BASE+48)
  #define CM_ERROR_ALLDOWN                (CM_ERROR_BASE+49)
+ #define CM_ERROR_TOOFEWBUFS		(CM_ERROR_BASE+50)
+ #define CM_ERROR_TOOMANYBUFS		(CM_ERROR_BASE+51)
  #endif /*  __CM_H_ENV__ */
Index: openafs/src/WINNT/afsd/cm_buf.h
diff -c openafs/src/WINNT/afsd/cm_buf.h:1.4.2.6 openafs/src/WINNT/afsd/cm_buf.h:1.4.2.7
*** openafs/src/WINNT/afsd/cm_buf.h:1.4.2.6	Sun Jun  5 02:45:31 2005
--- openafs/src/WINNT/afsd/cm_buf.h	Sat Oct 15 17:48:22 2005
***************
*** 201,207 ****
  
  /* error codes */
  #define CM_BUF_EXISTS	1	/* buffer exists, and shouldn't */
- #define CM_ERROR_BASEBUF	0x33333333
- #define CM_ERROR_TOOFEWBUFS	(CM_ERROR_BASEBUF+0)
- #define CM_ERROR_TOOMANYBUFS	(CM_ERROR_BASEBUF+1)
  #endif /*  _BUF_H__ENV_ */
--- 201,204 ----
Index: openafs/src/WINNT/afsd/cm_conn.c
diff -c openafs/src/WINNT/afsd/cm_conn.c:1.25.2.14.2.1 openafs/src/WINNT/afsd/cm_conn.c:1.25.2.16
*** openafs/src/WINNT/afsd/cm_conn.c:1.25.2.14.2.1	Thu Oct  6 22:25:09 2005
--- openafs/src/WINNT/afsd/cm_conn.c	Thu Oct  6 22:11:17 2005
***************
*** 480,485 ****
--- 480,487 ----
              case VRESTRICTED       : s = "VRESTRICTED";        break;
              case VRESTARTING       : s = "VRESTARTING";        break;
              case VREADONLY         : s = "VREADONLY";          break;
+             case EAGAIN            : s = "EAGAIN";             break;
+             case EACCES            : s = "EACCES";             break;
              }
              osi_Log2(afsd_logp, "cm_Analyze: ignoring error code 0x%x (%s)", 
                       errorCode, s);
Index: openafs/src/WINNT/afsd/cm_dcache.c
diff -c openafs/src/WINNT/afsd/cm_dcache.c:1.11.2.14 openafs/src/WINNT/afsd/cm_dcache.c:1.11.2.15
*** openafs/src/WINNT/afsd/cm_dcache.c:1.11.2.14	Sat Aug 27 23:30:58 2005
--- openafs/src/WINNT/afsd/cm_dcache.c	Fri Oct  7 23:51:26 2005
***************
*** 1263,1269 ****
          callp = rx_NewCall(rxconnp);
          rx_PutConnection(rxconnp);
  
!         osi_Log3(afsd_logp, "CALL FetchData vp %x, off 0x%x, size 0x%x",
                    (long) scp, biod.offset.LowPart, biod.length);
  
          code = StartRXAFS_FetchData(callp, &tfid, biod.offset.LowPart,
--- 1263,1269 ----
          callp = rx_NewCall(rxconnp);
          rx_PutConnection(rxconnp);
  
!         osi_Log3(afsd_logp, "CALL FetchData scp 0x%x, off 0x%x, size 0x%x",
                    (long) scp, biod.offset.LowPart, biod.length);
  
          code = StartRXAFS_FetchData(callp, &tfid, biod.offset.LowPart,
Index: openafs/src/WINNT/afsd/cm_scache.c
diff -c openafs/src/WINNT/afsd/cm_scache.c:1.14.2.13 openafs/src/WINNT/afsd/cm_scache.c:1.14.2.14
*** openafs/src/WINNT/afsd/cm_scache.c:1.14.2.13	Fri Aug  5 20:36:11 2005
--- openafs/src/WINNT/afsd/cm_scache.c	Wed Oct  5 01:12:27 2005
***************
*** 28,33 ****
--- 28,35 ----
  
  /* File locks */
  osi_queue_t *cm_allFileLocks;
+ osi_queue_t *cm_freeFileLocks;
+ unsigned long cm_lockRefreshCycle;
  
  /* lock for globals */
  osi_rwlock_t cm_scacheLock;
***************
*** 133,138 ****
--- 135,147 ----
              memset(&scp->mountRootFid, 0, sizeof(cm_fid_t));
              memset(&scp->dotdotFid, 0, sizeof(cm_fid_t));
  
+             /* reset locking info */
+             scp->fileLocksH = NULL;
+             scp->fileLocksT = NULL;
+             scp->serverLock = (-1);
+             scp->exclusiveLocks = 0;
+             scp->sharedLocks = 0;
+ 
              /* not locked, but there can be no references to this guy
               * while we hold the global refcount lock.
               */
***************
*** 157,162 ****
--- 166,172 ----
      scp->magic = CM_SCACHE_MAGIC;
      lock_InitializeMutex(&scp->mx, "cm_scache_t mutex");
      lock_InitializeRWLock(&scp->bufCreateLock, "cm_scache_t bufCreateLock");
+     scp->serverLock = -1;
  
      /* and put it in the LRU queue */
      osi_QAdd((osi_queue_t **) &cm_data.scacheLRUFirstp, &scp->q);
***************
*** 195,201 ****
          cm_data.fakeSCache.refCount = 1;
      }
      lock_InitializeMutex(&cm_data.fakeSCache.mx, "cm_scache_t mutex");
! }       
  
  long
  cm_ValidateSCache(void)
--- 205,211 ----
          cm_data.fakeSCache.refCount = 1;
      }
      lock_InitializeMutex(&cm_data.fakeSCache.mx, "cm_scache_t mutex");
! }
  
  long
  cm_ValidateSCache(void)
***************
*** 347,353 ****
  
                  scp->cbServerp = NULL;
                  scp->cbExpires = 0;
!                 scp->fileLocks = NULL;
                  scp->openReads = 0;
                  scp->openWrites = 0;
                  scp->openShares = 0;
--- 357,368 ----
  
                  scp->cbServerp = NULL;
                  scp->cbExpires = 0;
!                 scp->fileLocksH = NULL;
!                 scp->fileLocksT = NULL;
!                 scp->serverLock = (-1);
!                 scp->lastRefreshCycle = 0;
!                 scp->exclusiveLocks = 0;
!                 scp->sharedLocks = 0;
                  scp->openReads = 0;
                  scp->openWrites = 0;
                  scp->openShares = 0;
***************
*** 357,362 ****
--- 372,379 ----
              }
          }
          cm_allFileLocks = NULL;
+         cm_freeFileLocks = NULL;
+         cm_lockRefreshCycle = 0;
          cm_fakeSCacheInit(newFile);
          cm_dnlcInit(newFile);
          osi_EndOnce(&once);
Index: openafs/src/WINNT/afsd/cm_scache.h
diff -c openafs/src/WINNT/afsd/cm_scache.h:1.4.2.7 openafs/src/WINNT/afsd/cm_scache.h:1.4.2.9
*** openafs/src/WINNT/afsd/cm_scache.h:1.4.2.7	Sun Jun  5 02:45:31 2005
--- openafs/src/WINNT/afsd/cm_scache.h	Fri Oct  7 23:51:26 2005
***************
*** 31,60 ****
  } cm_accessCache_t;
  #endif
  
  typedef struct cm_file_lock {
! 	osi_queue_t q;			/* list of all locks */
! 	osi_queue_t fileq;		/* per-file list of locks */
! 	cm_user_t *userp;
! 	LARGE_INTEGER LOffset;
! 	LARGE_INTEGER LLength;
! 	cm_fid_t fid;
! 	unsigned char LockType;
! 	unsigned char flags;
  } cm_file_lock_t;
  
! #define CM_FILELOCK_FLAG_INVALID	0x1
! #define CM_FILELOCK_FLAG_WAITING	0x2
  
  typedef struct cm_prefetch {		/* last region scanned for prefetching */
  	osi_hyper_t base;		/* start of region */
          osi_hyper_t end;		/* first char past region */
  } cm_prefetch_t;
  
- 
  #define CM_SCACHE_MAGIC ('S' | 'C'<<8 | 'A'<<16 | 'C'<<24)
  
  typedef struct cm_scache {
! 	osi_queue_t q;			/* lru queue; cm_scacheLock */
          afs_uint32      magic;
          struct cm_scache *nextp;	/* next in hash; cm_scacheLock */
  	cm_fid_t fid;
--- 31,92 ----
  } cm_accessCache_t;
  #endif
  
+ /* Key used for byte range locking.  Each unique key identifies a
+    unique client per cm_scache_t for the purpose of locking. */
+ typedef afs_uint64 cm_key_t;
+ 
+ typedef struct cm_range {
+     afs_int64 offset;
+     afs_int64 length;
+ } cm_range_t;
+ 
+ /* forward dcls */
+ struct cm_scache;
+ typedef struct cm_scache cm_scache_t;
+ 
  typedef struct cm_file_lock {
!     osi_queue_t q;              /* list of all locks [protected by
!                                    cm_scacheLock] */
!     osi_queue_t fileq;		/* per-file list of locks [protected
!                                    by scp->mx]*/
!     
!     cm_user_t *userp;           /* The user to which this lock belongs
!                                    to [immutable; held] */
!     cm_scache_t *scp;           /* The scache to which this lock
!                                    applies to [immutable; held] */
! #ifdef DEBUG
!     cm_fid_t   fid;
! #endif
! 
!     cm_range_t range;           /* Range for the lock [immutable] */
!     cm_key_t key;               /* Key for the lock [immutable] */
!     unsigned char lockType;     /* LockRead or LockWrite [immutable] */
!     unsigned char flags;        /* combination of CM_FILELOCK_FLAG__*
!                                  * [protected by cm_scacheLock] */
!     time_t lastUpdate;          /* time of last assertion with
!                                  * server. [protected by
!                                  * cm_scacheLock] */
  } cm_file_lock_t;
  
! #define CM_FILELOCK_FLAG_DELETED         0x01
! #define CM_FILELOCK_FLAG_LOST            0x02
! 
! /* the following are mutually exclusive */
! #define CM_FILELOCK_FLAG_WAITLOCK        0x04
! #define CM_FILELOCK_FLAG_WAITUNLOCK      0x0C
! 
! /* the following is only to be used for locks on non-RO volumes */
! #define CM_FILELOCK_FLAG_CLIENTONLY      0x100
  
  typedef struct cm_prefetch {		/* last region scanned for prefetching */
  	osi_hyper_t base;		/* start of region */
          osi_hyper_t end;		/* first char past region */
  } cm_prefetch_t;
  
  #define CM_SCACHE_MAGIC ('S' | 'C'<<8 | 'A'<<16 | 'C'<<24)
  
  typedef struct cm_scache {
!     osi_queue_t q;              /* lru queue; cm_scacheLock */
          afs_uint32      magic;
          struct cm_scache *nextp;	/* next in hash; cm_scacheLock */
  	cm_fid_t fid;
***************
*** 116,123 ****
          long anyAccess;			/* anonymous user's access */
          struct cm_aclent *randomACLp;	/* access cache entries */
  
! 	/* file locks */
! 	osi_queue_t *fileLocks;
  	
  	/* volume info */
          struct cm_volume *volp;		/* volume info; held reference */
--- 148,168 ----
          long anyAccess;			/* anonymous user's access */
          struct cm_aclent *randomACLp;	/* access cache entries */
  
!     /* file locks */
!     afs_int32    serverLock;    /* current lock we have acquired on
!                                  * this file.  One of (-1), LockRead
!                                  * or LockWrite. [protected by
!                                  * scp->mx]
!                                  */
!     unsigned long lastRefreshCycle; /* protected with cm_scacheLock
!                                      * for all scaches. */
!     osi_queue_t *fileLocksH;    /* queue of locks (head) */
!     osi_queue_t *fileLocksT;    /* queue of locks (tail) */
!     afs_uint32   sharedLocks;   /* number of shared locks on
!                                  * ::fileLocks */
!     afs_uint32   exclusiveLocks; /* number of exclusive locks on
!                                   * ::fileLocks
!                                   */
  	
  	/* volume info */
          struct cm_volume *volp;		/* volume info; held reference */
***************
*** 266,271 ****
--- 311,320 ----
  
  extern osi_queue_t *cm_allFileLocks;
  
+ extern osi_queue_t *cm_freeFileLocks;
+ 
+ extern unsigned long cm_lockRefreshCycle;
+ 
  extern void cm_DiscardSCache(cm_scache_t *scp);
  
  extern int cm_FindFileType(cm_fid_t *fidp);
Index: openafs/src/WINNT/afsd/cm_utils.c
diff -c openafs/src/WINNT/afsd/cm_utils.c:1.5.14.3 openafs/src/WINNT/afsd/cm_utils.c:1.5.14.5
*** openafs/src/WINNT/afsd/cm_utils.c:1.5.14.3	Wed Mar 30 15:50:16 2005
--- openafs/src/WINNT/afsd/cm_utils.c	Sat Oct 15 17:48:23 2005
***************
*** 13,18 ****
--- 13,57 ----
  #ifndef DJGPP
  #include <windows.h>
  #include <winsock2.h>
+ #ifndef EWOULDBLOCK
+ #define EWOULDBLOCK             WSAEWOULDBLOCK
+ #define EINPROGRESS             WSAEINPROGRESS
+ #define EALREADY                WSAEALREADY
+ #define ENOTSOCK                WSAENOTSOCK
+ #define EDESTADDRREQ            WSAEDESTADDRREQ
+ #define EMSGSIZE                WSAEMSGSIZE
+ #define EPROTOTYPE              WSAEPROTOTYPE
+ #define ENOPROTOOPT             WSAENOPROTOOPT
+ #define EPROTONOSUPPORT         WSAEPROTONOSUPPORT
+ #define ESOCKTNOSUPPORT         WSAESOCKTNOSUPPORT
+ #define EOPNOTSUPP              WSAEOPNOTSUPP
+ #define EPFNOSUPPORT            WSAEPFNOSUPPORT
+ #define EAFNOSUPPORT            WSAEAFNOSUPPORT
+ #define EADDRINUSE              WSAEADDRINUSE
+ #define EADDRNOTAVAIL           WSAEADDRNOTAVAIL
+ #define ENETDOWN                WSAENETDOWN
+ #define ENETUNREACH             WSAENETUNREACH
+ #define ENETRESET               WSAENETRESET
+ #define ECONNABORTED            WSAECONNABORTED
+ #define ECONNRESET              WSAECONNRESET
+ #define ENOBUFS                 WSAENOBUFS
+ #define EISCONN                 WSAEISCONN
+ #define ENOTCONN                WSAENOTCONN
+ #define ESHUTDOWN               WSAESHUTDOWN
+ #define ETOOMANYREFS            WSAETOOMANYREFS
+ #define ETIMEDOUT               WSAETIMEDOUT
+ #define ECONNREFUSED            WSAECONNREFUSED
+ #define ELOOP                   WSAELOOP
+ #define ENAMETOOLONG            WSAENAMETOOLONG
+ #define EHOSTDOWN               WSAEHOSTDOWN
+ #define EHOSTUNREACH            WSAEHOSTUNREACH
+ #define ENOTEMPTY               WSAENOTEMPTY
+ #define EPROCLIM                WSAEPROCLIM
+ #define EUSERS                  WSAEUSERS
+ #define EDQUOT                  WSAEDQUOT
+ #define ESTALE                  WSAESTALE
+ #define EREMOTE                 WSAEREMOTE
+ #endif /* EWOULDBLOCK */
  #endif /* !DJGPP */
  #include <string.h>
  #include <malloc.h>
***************
*** 20,25 ****
--- 59,67 ----
  #include <osi.h>
  #include <rx/rx.h>
  
+ #include <errno.h>
+ #include <afs/unified_afs.h>
+ 
  #include "afsd.h"
  
  static osi_once_t cm_utilsOnce;
***************
*** 28,33 ****
--- 70,216 ----
  
  cm_space_t *cm_spaceListp;
  
+ static int et2sys[512];
+ 
+ void
+ init_et_to_sys_error(void)
+ {
+     memset(&et2sys, 0, sizeof(et2sys));
+     et2sys[(UAEPERM - ERROR_TABLE_BASE_uae)] = EPERM;
+     et2sys[(UAENOENT - ERROR_TABLE_BASE_uae)] = ENOENT;
+     et2sys[(UAESRCH - ERROR_TABLE_BASE_uae)] = ESRCH;
+     et2sys[(UAEINTR - ERROR_TABLE_BASE_uae)] = EINTR;
+     et2sys[(UAEIO - ERROR_TABLE_BASE_uae)] = EIO;
+     et2sys[(UAENXIO - ERROR_TABLE_BASE_uae)] = ENXIO;
+     et2sys[(UAE2BIG - ERROR_TABLE_BASE_uae)] = E2BIG;
+     et2sys[(UAENOEXEC - ERROR_TABLE_BASE_uae)] = ENOEXEC;
+     et2sys[(UAEBADF - ERROR_TABLE_BASE_uae)] = EBADF;
+     et2sys[(UAECHILD - ERROR_TABLE_BASE_uae)] = ECHILD;
+     et2sys[(UAEAGAIN - ERROR_TABLE_BASE_uae)] = EAGAIN;
+     et2sys[(UAENOMEM - ERROR_TABLE_BASE_uae)] = ENOMEM;
+     et2sys[(UAEACCES - ERROR_TABLE_BASE_uae)] = EACCES;
+     et2sys[(UAEFAULT - ERROR_TABLE_BASE_uae)] = EFAULT;
+     et2sys[(UAENOTBLK - ERROR_TABLE_BASE_uae)] = ENOTBLK;
+     et2sys[(UAEBUSY - ERROR_TABLE_BASE_uae)] = EBUSY;
+     et2sys[(UAEEXIST - ERROR_TABLE_BASE_uae)] = EEXIST;
+     et2sys[(UAEXDEV - ERROR_TABLE_BASE_uae)] = EXDEV;
+     et2sys[(UAENODEV - ERROR_TABLE_BASE_uae)] = ENODEV;
+     et2sys[(UAENOTDIR - ERROR_TABLE_BASE_uae)] = ENOTDIR;
+     et2sys[(UAEISDIR - ERROR_TABLE_BASE_uae)] = EISDIR;
+     et2sys[(UAEINVAL - ERROR_TABLE_BASE_uae)] = EINVAL;
+     et2sys[(UAENFILE - ERROR_TABLE_BASE_uae)] = ENFILE;
+     et2sys[(UAEMFILE - ERROR_TABLE_BASE_uae)] = EMFILE;
+     et2sys[(UAENOTTY - ERROR_TABLE_BASE_uae)] = ENOTTY;
+     et2sys[(UAETXTBSY - ERROR_TABLE_BASE_uae)] = ETXTBSY;
+     et2sys[(UAEFBIG - ERROR_TABLE_BASE_uae)] = EFBIG;
+     et2sys[(UAENOSPC - ERROR_TABLE_BASE_uae)] = ENOSPC;
+     et2sys[(UAESPIPE - ERROR_TABLE_BASE_uae)] = ESPIPE;
+     et2sys[(UAEROFS - ERROR_TABLE_BASE_uae)] = EROFS;
+     et2sys[(UAEMLINK - ERROR_TABLE_BASE_uae)] = EMLINK;
+     et2sys[(UAEPIPE - ERROR_TABLE_BASE_uae)] = EPIPE;
+     et2sys[(UAEDOM - ERROR_TABLE_BASE_uae)] = EDOM;
+     et2sys[(UAERANGE - ERROR_TABLE_BASE_uae)] = ERANGE;
+     et2sys[(UAEDEADLK - ERROR_TABLE_BASE_uae)] = EDEADLK;
+     et2sys[(UAENAMETOOLONG - ERROR_TABLE_BASE_uae)] = ENAMETOOLONG;
+     et2sys[(UAENOLCK - ERROR_TABLE_BASE_uae)] = ENOLCK;
+     et2sys[(UAENOSYS - ERROR_TABLE_BASE_uae)] = ENOSYS;
+     et2sys[(UAENOTEMPTY - ERROR_TABLE_BASE_uae)] = ENOTEMPTY;
+     et2sys[(UAELOOP - ERROR_TABLE_BASE_uae)] = ELOOP;
+     et2sys[(UAEWOULDBLOCK - ERROR_TABLE_BASE_uae)] = EWOULDBLOCK;
+     et2sys[(UAENOMSG - ERROR_TABLE_BASE_uae)] = ENOMSG;
+     et2sys[(UAEIDRM - ERROR_TABLE_BASE_uae)] = EIDRM;
+     et2sys[(UAECHRNG - ERROR_TABLE_BASE_uae)] = ECHRNG;
+     et2sys[(UAEL2NSYNC - ERROR_TABLE_BASE_uae)] = EL2NSYNC;
+     et2sys[(UAEL3HLT - ERROR_TABLE_BASE_uae)] = EL3HLT;
+     et2sys[(UAEL3RST - ERROR_TABLE_BASE_uae)] = EL3RST;
+     et2sys[(UAELNRNG - ERROR_TABLE_BASE_uae)] = ELNRNG;
+     et2sys[(UAEUNATCH - ERROR_TABLE_BASE_uae)] = EUNATCH;
+     et2sys[(UAENOCSI - ERROR_TABLE_BASE_uae)] = ENOCSI;
+     et2sys[(UAEL2HLT - ERROR_TABLE_BASE_uae)] = EL2HLT;
+     et2sys[(UAEBADE - ERROR_TABLE_BASE_uae)] = EBADE;
+     et2sys[(UAEBADR - ERROR_TABLE_BASE_uae)] = EBADR;
+     et2sys[(UAEXFULL - ERROR_TABLE_BASE_uae)] = EXFULL;
+     et2sys[(UAENOANO - ERROR_TABLE_BASE_uae)] = ENOANO;
+     et2sys[(UAEBADRQC - ERROR_TABLE_BASE_uae)] = EBADRQC;
+     et2sys[(UAEBADSLT - ERROR_TABLE_BASE_uae)] = EBADSLT;
+     et2sys[(UAEBFONT - ERROR_TABLE_BASE_uae)] = EBFONT;
+     et2sys[(UAENOSTR - ERROR_TABLE_BASE_uae)] = ENOSTR;
+     et2sys[(UAENODATA - ERROR_TABLE_BASE_uae)] = ENODATA;
+     et2sys[(UAETIME - ERROR_TABLE_BASE_uae)] = ETIME;
+     et2sys[(UAENOSR - ERROR_TABLE_BASE_uae)] = ENOSR;
+     et2sys[(UAENONET - ERROR_TABLE_BASE_uae)] = ENONET;
+     et2sys[(UAENOPKG - ERROR_TABLE_BASE_uae)] = ENOPKG;
+     et2sys[(UAEREMOTE - ERROR_TABLE_BASE_uae)] = EREMOTE;
+     et2sys[(UAENOLINK - ERROR_TABLE_BASE_uae)] = ENOLINK;
+     et2sys[(UAEADV - ERROR_TABLE_BASE_uae)] = EADV;
+     et2sys[(UAESRMNT - ERROR_TABLE_BASE_uae)] = ESRMNT;
+     et2sys[(UAECOMM - ERROR_TABLE_BASE_uae)] = ECOMM;
+     et2sys[(UAEPROTO - ERROR_TABLE_BASE_uae)] = EPROTO;
+     et2sys[(UAEMULTIHOP - ERROR_TABLE_BASE_uae)] = EMULTIHOP;
+     et2sys[(UAEDOTDOT - ERROR_TABLE_BASE_uae)] = EDOTDOT;
+     et2sys[(UAEBADMSG - ERROR_TABLE_BASE_uae)] = EBADMSG;
+     et2sys[(UAEOVERFLOW - ERROR_TABLE_BASE_uae)] = EOVERFLOW;
+     et2sys[(UAENOTUNIQ - ERROR_TABLE_BASE_uae)] = ENOTUNIQ;
+     et2sys[(UAEBADFD - ERROR_TABLE_BASE_uae)] = EBADFD;
+     et2sys[(UAEREMCHG - ERROR_TABLE_BASE_uae)] = EREMCHG;
+     et2sys[(UAELIBACC - ERROR_TABLE_BASE_uae)] = ELIBACC;
+     et2sys[(UAELIBBAD - ERROR_TABLE_BASE_uae)] = ELIBBAD;
+     et2sys[(UAELIBSCN - ERROR_TABLE_BASE_uae)] = ELIBSCN;
+     et2sys[(UAELIBMAX - ERROR_TABLE_BASE_uae)] = ELIBMAX;
+     et2sys[(UAELIBEXEC - ERROR_TABLE_BASE_uae)] = ELIBEXEC;
+     et2sys[(UAEILSEQ - ERROR_TABLE_BASE_uae)] = EILSEQ;
+     et2sys[(UAERESTART - ERROR_TABLE_BASE_uae)] = ERESTART;
+     et2sys[(UAESTRPIPE - ERROR_TABLE_BASE_uae)] = ESTRPIPE;
+     et2sys[(UAEUSERS - ERROR_TABLE_BASE_uae)] = EUSERS;
+     et2sys[(UAENOTSOCK - ERROR_TABLE_BASE_uae)] = ENOTSOCK;
+     et2sys[(UAEDESTADDRREQ - ERROR_TABLE_BASE_uae)] = EDESTADDRREQ;
+     et2sys[(UAEMSGSIZE - ERROR_TABLE_BASE_uae)] = EMSGSIZE;
+     et2sys[(UAEPROTOTYPE - ERROR_TABLE_BASE_uae)] = EPROTOTYPE;
+     et2sys[(UAENOPROTOOPT - ERROR_TABLE_BASE_uae)] = ENOPROTOOPT;
+     et2sys[(UAEPROTONOSUPPORT - ERROR_TABLE_BASE_uae)] = EPROTONOSUPPORT;
+     et2sys[(UAESOCKTNOSUPPORT - ERROR_TABLE_BASE_uae)] = ESOCKTNOSUPPORT;
+     et2sys[(UAEOPNOTSUPP - ERROR_TABLE_BASE_uae)] = EOPNOTSUPP;
+     et2sys[(UAEPFNOSUPPORT - ERROR_TABLE_BASE_uae)] = EPFNOSUPPORT;
+     et2sys[(UAEAFNOSUPPORT - ERROR_TABLE_BASE_uae)] = EAFNOSUPPORT;
+     et2sys[(UAEADDRINUSE - ERROR_TABLE_BASE_uae)] = EADDRINUSE;
+     et2sys[(UAEADDRNOTAVAIL - ERROR_TABLE_BASE_uae)] = EADDRNOTAVAIL;
+     et2sys[(UAENETDOWN - ERROR_TABLE_BASE_uae)] = ENETDOWN;
+     et2sys[(UAENETUNREACH - ERROR_TABLE_BASE_uae)] = ENETUNREACH;
+     et2sys[(UAENETRESET - ERROR_TABLE_BASE_uae)] = ENETRESET;
+     et2sys[(UAECONNABORTED - ERROR_TABLE_BASE_uae)] = ECONNABORTED;
+     et2sys[(UAECONNRESET - ERROR_TABLE_BASE_uae)] = ECONNRESET;
+     et2sys[(UAENOBUFS - ERROR_TABLE_BASE_uae)] = ENOBUFS;
+     et2sys[(UAEISCONN - ERROR_TABLE_BASE_uae)] = EISCONN;
+     et2sys[(UAENOTCONN - ERROR_TABLE_BASE_uae)] = ENOTCONN;
+     et2sys[(UAESHUTDOWN - ERROR_TABLE_BASE_uae)] = ESHUTDOWN;
+     et2sys[(UAETOOMANYREFS - ERROR_TABLE_BASE_uae)] = ETOOMANYREFS;
+     et2sys[(UAETIMEDOUT - ERROR_TABLE_BASE_uae)] = ETIMEDOUT;
+     et2sys[(UAECONNREFUSED - ERROR_TABLE_BASE_uae)] = ECONNREFUSED;
+     et2sys[(UAEHOSTDOWN - ERROR_TABLE_BASE_uae)] = EHOSTDOWN;
+     et2sys[(UAEHOSTUNREACH - ERROR_TABLE_BASE_uae)] = EHOSTUNREACH;
+     et2sys[(UAEALREADY - ERROR_TABLE_BASE_uae)] = EALREADY;
+     et2sys[(UAEINPROGRESS - ERROR_TABLE_BASE_uae)] = EINPROGRESS;
+     et2sys[(UAESTALE - ERROR_TABLE_BASE_uae)] = ESTALE;
+     et2sys[(UAEUCLEAN - ERROR_TABLE_BASE_uae)] = EUCLEAN;
+     et2sys[(UAENOTNAM - ERROR_TABLE_BASE_uae)] = ENOTNAM;
+     et2sys[(UAENAVAIL - ERROR_TABLE_BASE_uae)] = ENAVAIL;
+     et2sys[(UAEISNAM - ERROR_TABLE_BASE_uae)] = EISNAM;
+     et2sys[(UAEREMOTEIO - ERROR_TABLE_BASE_uae)] = EREMOTEIO;
+     et2sys[(UAEDQUOT - ERROR_TABLE_BASE_uae)] = EDQUOT;
+     et2sys[(UAENOMEDIUM - ERROR_TABLE_BASE_uae)] = ENOMEDIUM;
+     et2sys[(UAEMEDIUMTYPE - ERROR_TABLE_BASE_uae)] = EMEDIUMTYPE;
+ }
+ 
+ static afs_int32
+ et_to_sys_error(afs_int32 in)
+ {
+     if (in < ERROR_TABLE_BASE_uae || in >= ERROR_TABLE_BASE_uae + 512)
+ 	return in;
+     if (et2sys[in - ERROR_TABLE_BASE_uae] != 0)
+ 	return et2sys[in - ERROR_TABLE_BASE_uae];
+     return in;
+ }
+ 
  long cm_MapRPCError(long error, cm_req_t *reqp)
  {
      if (error == 0) 
***************
*** 44,49 ****
--- 227,234 ----
          return error;
      }
  
+     error = et_to_sys_error(error);
+ 
      if (error < 0) 
          error = CM_ERROR_TIMEDOUT;
      else if (error == 30) 
***************
*** 58,75 ****
          error = CM_ERROR_NOTDIR;
      else if (error == 2) 
          error = CM_ERROR_NOSUCHFILE;
!     else if (error == 11		/* EAGAIN, most servers */
               || error == 35)	/* EAGAIN, Digital UNIX */
          error = CM_ERROR_WOULDBLOCK;
      else if (error == VDISKFULL
!               || error == 28)        /* ENOSPC */ 
          error = CM_ERROR_SPACE;
      else if (error == VOVERQUOTA
!               || error == 49         /* EDQUOT on Solaris */
!               || error == 88		/* EDQUOT on AIX */
!               || error == 69	        /* EDQUOT on Digital UNIX and HPUX */
!               || error == 122        /* EDQUOT on Linux */
!               || error == 1133)      /* EDQUOT on Irix  */
          error = CM_ERROR_QUOTA;
      else if (error == VNOVNODE) 
          error = CM_ERROR_BADFD;
--- 243,260 ----
          error = CM_ERROR_NOTDIR;
      else if (error == 2) 
          error = CM_ERROR_NOSUCHFILE;
!     else if (error == 11        /* EAGAIN, most servers */
               || error == 35)	/* EAGAIN, Digital UNIX */
          error = CM_ERROR_WOULDBLOCK;
      else if (error == VDISKFULL
!               || error == 28)   /* ENOSPC */ 
          error = CM_ERROR_SPACE;
      else if (error == VOVERQUOTA
!               || error == 49    /* EDQUOT on Solaris */
!               || error == 88    /* EDQUOT on AIX */
!               || error == 69    /* EDQUOT on Digital UNIX and HPUX */
!               || error == 122   /* EDQUOT on Linux */
!               || error == 1133) /* EDQUOT on Irix  */
          error = CM_ERROR_QUOTA;
      else if (error == VNOVNODE) 
          error = CM_ERROR_BADFD;
Index: openafs/src/WINNT/afsd/cm_vnodeops.c
diff -c openafs/src/WINNT/afsd/cm_vnodeops.c:1.19.2.20 openafs/src/WINNT/afsd/cm_vnodeops.c:1.19.2.27
*** openafs/src/WINNT/afsd/cm_vnodeops.c:1.19.2.20	Fri Jul 22 21:17:42 2005
--- openafs/src/WINNT/afsd/cm_vnodeops.c	Tue Oct 18 16:53:50 2005
***************
*** 18,23 ****
--- 18,24 ----
  #include <malloc.h>
  #include <string.h>
  #include <stdlib.h>
+ #include <errno.h>
  
  #include <osi.h>
  
***************
*** 263,268 ****
--- 264,321 ----
      code = cm_SyncOp(scp, NULL, userp, reqp, rights,
                        CM_SCACHESYNC_GETSTATUS
                        | CM_SCACHESYNC_NEEDCALLBACK);
+ 
+     if (code == 0 && 
+         ((rights & PRSFS_WRITE) || (rights & PRSFS_READ)) &&
+         scp->fileType == CM_SCACHETYPE_FILE) {
+ 
+         cm_key_t key;
+         unsigned int sLockType;
+         LARGE_INTEGER LOffset, LLength;
+ 
+         /* Check if there's some sort of lock on the file at the
+            moment. */
+ 
+         key = cm_GenerateKey(CM_SESSION_CMINT,0,0);
+ 
+         if (rights & PRSFS_WRITE)
+             sLockType = 0;
+         else
+             sLockType = LOCKING_ANDX_SHARED_LOCK;
+ 
+         /* single byte lock at offset 0x0000 0001 0000 0000 */
+         LOffset.HighPart = 1;
+         LOffset.LowPart = 0;
+         LLength.HighPart = 0;
+         LLength.LowPart = 1;
+ 
+         code = cm_Lock(scp, sLockType, LOffset, LLength, key, 0, userp, reqp, NULL);
+ 
+         if (code == 0) {
+             cm_Unlock(scp, sLockType, LOffset, LLength, key, userp, reqp);
+         } else {
+             /* In this case, we allow the file open to go through even
+                though we can't enforce mandatory locking on the
+                file. */
+             if (code == CM_ERROR_NOACCESS &&
+                 !(rights & PRSFS_WRITE))
+                 code = 0;
+             else {
+ 		switch (code) {
+ 		case CM_ERROR_ALLOFFLINE:
+ 		case CM_ERROR_ALLDOWN:
+ 		case CM_ERROR_ALLBUSY:
+ 		case CM_ERROR_TIMEDOUT:
+ 		case CM_ERROR_RETRY:
+ 		case CM_ERROR_WOULDBLOCK:
+ 		    break;
+ 		default:
+ 		    code = CM_ERROR_SHARING_VIOLATION;
+ 		}
+ 	    }
+         }
+     }
+ 
      lock_ReleaseMutex(&scp->mx);
  
      return code;
***************
*** 293,299 ****
      code = cm_SyncOp(scp, NULL, userp, reqp, rights,
                        CM_SCACHESYNC_GETSTATUS
                        | CM_SCACHESYNC_NEEDCALLBACK);
-     lock_ReleaseMutex(&scp->mx);
  
      /*
       * If the open will fail because the volume is readonly, then we will
--- 346,351 ----
***************
*** 303,308 ****
--- 355,410 ----
       */
      if (code == CM_ERROR_READONLY)
          code = CM_ERROR_NOACCESS;
+     else if (code == 0 &&
+              ((rights & PRSFS_WRITE) || (rights & PRSFS_READ)) &&
+              scp->fileType == CM_SCACHETYPE_FILE) {
+         cm_key_t key;
+         unsigned int sLockType;
+         LARGE_INTEGER LOffset, LLength;
+ 
+         /* Check if there's some sort of lock on the file at the
+            moment. */
+ 
+         key = cm_GenerateKey(CM_SESSION_CMINT,0,0);
+         if (rights & PRSFS_WRITE)
+             sLockType = 0;
+         else
+             sLockType = LOCKING_ANDX_SHARED_LOCK;
+ 
+         /* single byte lock at offset 0x0000 0001 0000 0000 */
+         LOffset.HighPart = 1;
+         LOffset.LowPart = 0;
+         LLength.HighPart = 0;
+         LLength.LowPart = 1;
+ 
+         code = cm_Lock(scp, sLockType, LOffset, LLength, key, 0, userp, reqp, NULL);
+ 
+         if (code == 0) {
+             cm_Unlock(scp, sLockType, LOffset, LLength, key, userp, reqp);
+         } else {
+             /* In this case, we allow the file open to go through even
+                though we can't enforce mandatory locking on the
+                file. */
+             if (code == CM_ERROR_NOACCESS &&
+                 !(rights & PRSFS_WRITE))
+                 code = 0;
+             else {
+ 		switch (code) {
+ 		case CM_ERROR_ALLOFFLINE:
+ 		case CM_ERROR_ALLDOWN:
+ 		case CM_ERROR_ALLBUSY:
+ 		case CM_ERROR_TIMEDOUT:
+ 		case CM_ERROR_RETRY:
+ 		case CM_ERROR_WOULDBLOCK:
+ 		    break;
+ 		default:
+ 		    code = CM_ERROR_SHARING_VIOLATION;
+ 		}
+ 	    }
+         }
+     }
+ 
+     lock_ReleaseMutex(&scp->mx);
  
      return code;
  }
***************
*** 689,695 ****
              match = cm_stricmp(matchName, sp->searchNamep);
          else
              match = strcmp(matchName, sp->searchNamep);
!     }       
  
      if (match != 0)
          return 0;
--- 791,797 ----
              match = cm_stricmp(matchName, sp->searchNamep);
          else
              match = strcmp(matchName, sp->searchNamep);
!     }
  
      if (match != 0)
          return 0;
***************
*** 2677,3006 ****
      return code;
  }
  
! long cm_Lock(cm_scache_t *scp, unsigned char LockType,
!               LARGE_INTEGER LOffset, LARGE_INTEGER LLength,
!               u_long Timeout, cm_user_t *userp, cm_req_t *reqp,
!               void **lockpp)
! {
!     long code;
!     int Which = ((LockType & LOCKING_ANDX_SHARED_LOCK) ? LockRead : LockWrite);
!     AFSFid tfid;
!     AFSVolSync volSync;
!     cm_conn_t *connp;
!     cm_file_lock_t *fileLock;
!     osi_queue_t *q;
!     int found = 0;
!     struct rx_connection * callp;
  
!     osi_Log1(afsd_logp, "cm_Lock scp 0x%x ...", (long) scp);
!     osi_Log4(afsd_logp, "cm_Lock type 0x%x offset %d length %d timeout %d",
!              LockType, (unsigned long)LOffset.QuadPart, (unsigned long)LLength.QuadPart, Timeout);
  
!     /* Look for a conflict.  Also, if we are asking for a shared lock,
!      * look for another shared lock, so we don't have to do an RPC.
!      */
!     q = scp->fileLocks;
!     while (q) {
!         fileLock = (cm_file_lock_t *)((char *) q - offsetof(cm_file_lock_t, fileq));
!         if ((fileLock->flags & (CM_FILELOCK_FLAG_INVALID | CM_FILELOCK_FLAG_WAITING)) == 0) {
!             if ((LockType & LOCKING_ANDX_SHARED_LOCK) == 0 ||
!                 (fileLock->LockType & LOCKING_ANDX_SHARED_LOCK) == 0)
!                 return CM_ERROR_WOULDBLOCK;
!             found = 1;
!         }
!         q = osi_QNext(q);
!     }
  
!     osi_Log1(afsd_logp, "cm_Lock found = %d", found);
  
!     if (found)
!         code = 0;
!     else {
!         tfid.Volume = scp->fid.volume;
!         tfid.Vnode = scp->fid.vnode;
!         tfid.Unique = scp->fid.unique;
!         lock_ReleaseMutex(&scp->mx);
!         do {
!             osi_Log1(afsd_logp, "CALL SetLock scp 0x%x", (long) scp);
!             code = cm_Conn(&scp->fid, userp, reqp, &connp);
!             if (code) 
!                 break;
  
!             callp = cm_GetRxConn(connp);
!             code = RXAFS_SetLock(callp, &tfid, Which,
!                                   &volSync);
!             rx_PutConnection(callp);
  
!         } while (cm_Analyze(connp, userp, reqp, &scp->fid, &volSync,
!                              NULL, NULL, code));
!         if (code)
!             osi_Log1(afsd_logp, "CALL SetLock FAILURE, code 0x%x", code);
!         else
!             osi_Log0(afsd_logp, "CALL SetLock SUCCESS");
!         lock_ObtainMutex(&scp->mx);
!         code = cm_MapRPCError(code, reqp);
!     }
  
!     if (code == 0 || Timeout != 0) {
!         fileLock = malloc(sizeof(cm_file_lock_t));
!         fileLock->LockType = LockType;
!         cm_HoldUser(userp);
!         fileLock->userp = userp;
!         fileLock->fid = scp->fid;
!         fileLock->LOffset = LOffset;
!         fileLock->LLength = LLength;
!         fileLock->flags = (code == 0 ? 0 : CM_FILELOCK_FLAG_WAITING);
!         osi_QAdd(&scp->fileLocks, &fileLock->fileq);
!         lock_ObtainWrite(&cm_scacheLock);
!         osi_QAdd(&cm_allFileLocks, &fileLock->q);
!         lock_ReleaseWrite(&cm_scacheLock);
!         if (code != 0) 
!             *lockpp = fileLock;
!         osi_Log1(afsd_logp, "cm_Lock Lock added 0x%x", (long) fileLock);
!     }
!     return code;
! }
  
! long cm_Unlock(cm_scache_t *scp, unsigned char LockType,
!                 LARGE_INTEGER LOffset, LARGE_INTEGER LLength,
!                 cm_user_t *userp, cm_req_t *reqp)
! {
!     long code = 0;
!     int Which = ((LockType & LOCKING_ANDX_SHARED_LOCK) ? LockRead : LockWrite);
!     AFSFid tfid;
!     AFSVolSync volSync;
!     cm_conn_t *connp;
!     cm_file_lock_t *fileLock, *ourLock;
!     osi_queue_t *q, *qq;
!     int anotherReader = 0;
!     int smallLock = 0;
!     int found = 0;
!     struct rx_connection * callp;
  
!     osi_Log4(afsd_logp, "cm_Unlock scp 0x%x type 0x%x offset %d length %d",
!              (long) scp, LockType, (unsigned long)LOffset.QuadPart, (unsigned long)LLength.QuadPart);
  
!     if (LargeIntegerLessThan(LLength, scp->length))
!         smallLock = 1;
  
!     /* Look for our own lock on the list, so as to remove it.
!      * Also, determine if we're the last reader; if not, avoid an RPC.
!      */
!     q = scp->fileLocks;
!     while (q) {
!         fileLock = (cm_file_lock_t *)
!             ((char *) q - offsetof(cm_file_lock_t, fileq));
!         if (!found
!              && fileLock->userp == userp
!              && LargeIntegerEqualTo(fileLock->LOffset, LOffset)
!              && LargeIntegerEqualTo(fileLock->LLength, LLength)) {
!             found = 1;
!             ourLock = fileLock;
!             qq = q;
!         }
!         else if (fileLock->LockType & LOCKING_ANDX_SHARED_LOCK)
!             anotherReader = 1;
!         q = osi_QNext(q);
!     }
! 
!     /* ignore byte ranges */
!     if (smallLock && !found) {
!         osi_Log0(afsd_logp, "cm_Unlock lock not found and ignored");
!         return 0;
!     }
  
!     /* don't try to unlock other people's locks */
!     if (!found) {
!         osi_Log0(afsd_logp, "cm_Unlock lock not found; failure");
!         return CM_ERROR_WOULDBLOCK;
!     }
  
!     /* discard lock record */
!     osi_QRemove(&scp->fileLocks, qq);
!     /*
!      * Don't delete it here; let the daemon delete it, to simplify
!      * the daemon's traversal of the list.
!      */
!     lock_ObtainWrite(&cm_scacheLock);
!     ourLock->flags |= CM_FILELOCK_FLAG_INVALID;
!     cm_ReleaseUser(ourLock->userp);
!     lock_ReleaseWrite(&cm_scacheLock);
  
!     if (!anotherReader) {
!         tfid.Volume = scp->fid.volume;
!         tfid.Vnode = scp->fid.vnode;
!         tfid.Unique = scp->fid.unique;
!         lock_ReleaseMutex(&scp->mx);
!         osi_Log1(afsd_logp, "CALL ReleaseLock scp 0x%x", (long) scp);
!         do {
!             code = cm_Conn(&scp->fid, userp, reqp, &connp);
!             if (code) 
!                 break;
  
!             callp = cm_GetRxConn(connp);
!             code = RXAFS_ReleaseLock(callp, &tfid, &volSync);
!             rx_PutConnection(callp);
  
!         } while (cm_Analyze(connp, userp, reqp, &scp->fid, &volSync,
!                              NULL, NULL, code));
!         code = cm_MapRPCError(code, reqp);
  
!         if (code)
!             osi_Log1(afsd_logp, "CALL ReleaseLock FAILURE, code 0x%x", code);
!         else
!             osi_Log0(afsd_logp, "CALL ReleaseLock SUCCESS");
  
!         lock_ObtainMutex(&scp->mx);
!     }
  
!     osi_Log1(afsd_logp, "cm_Unlock code 0x%x", code);
!     return code;
! }
  
! void cm_CheckLocks()
! {
!     osi_queue_t *q, *nq;
!     cm_file_lock_t *fileLock;
!     cm_req_t req;
!     AFSFid tfid;
!     AFSVolSync volSync;
!     cm_conn_t *connp;
!     long code;
!     struct rx_connection * callp;
  
!     cm_InitReq(&req);
  
!     lock_ObtainWrite(&cm_scacheLock);
!     q = cm_allFileLocks;
!     while (q) {
!         fileLock = (cm_file_lock_t *) q;
!         nq = osi_QNext(q);
!         if (fileLock->flags & CM_FILELOCK_FLAG_INVALID) {
!             osi_QRemove(&cm_allFileLocks, q);
!             free(fileLock);
!         }
!         else if (!(fileLock->flags & CM_FILELOCK_FLAG_WAITING)) {
!             tfid.Volume = fileLock->fid.volume;
!             tfid.Vnode = fileLock->fid.vnode;
!             tfid.Unique = fileLock->fid.unique;
!             lock_ReleaseWrite(&cm_scacheLock);
!             osi_Log1(afsd_logp, "CALL ExtendLock lock 0x%x", (long) fileLock);
!             do {
!                 code = cm_Conn(&fileLock->fid, fileLock->userp,
!                                 &req, &connp);
!                 if (code) 
!                     break;
  
!                 callp = cm_GetRxConn(connp);
!                 code = RXAFS_ExtendLock(callp, &tfid,
!                                          &volSync);
!                 rx_PutConnection(callp);
  
!             } while (cm_Analyze(connp, fileLock->userp, &req,
!                                  &fileLock->fid, &volSync, NULL, NULL,
!                                  code));
!             code = cm_MapRPCError(code, &req);
!             if (code)
!                 osi_Log1(afsd_logp, "CALL ExtendLock FAILURE, code 0x%x", code);
!             else
!                 osi_Log0(afsd_logp, "CALL ExtendLock SUCCESS");
  
!             lock_ObtainWrite(&cm_scacheLock);
          }
-         q = nq;
      }
!     lock_ReleaseWrite(&cm_scacheLock);
! }       
  
! long cm_RetryLock(cm_file_lock_t *oldFileLock, int vcp_is_dead)
  {
!     long code;
!     int Which = ((oldFileLock->LockType & LOCKING_ANDX_SHARED_LOCK) ? LockRead : LockWrite);
!     cm_scache_t *scp;
!     AFSFid tfid;
!     AFSVolSync volSync;
!     cm_conn_t *connp;
      cm_file_lock_t *fileLock;
      osi_queue_t *q;
!     cm_req_t req;
!     int found = 0;
!     struct rx_connection * callp;
  
!     if (vcp_is_dead) {
!         code = CM_ERROR_TIMEDOUT;
!         goto handleCode;
!     }
  
!     cm_InitReq(&req);
  
!     /* Look for a conflict.  Also, if we are asking for a shared lock,
!      * look for another shared lock, so we don't have to do an RPC.
!      */
!     code = cm_GetSCache(&oldFileLock->fid, &scp, oldFileLock->userp, &req);
!     if (code)
!         return code;
  
!     q = scp->fileLocks;
!     while (q) {
!         fileLock = (cm_file_lock_t *)
!             ((char *) q - offsetof(cm_file_lock_t, fileq));
!         if ((fileLock->flags &
!               (CM_FILELOCK_FLAG_INVALID | CM_FILELOCK_FLAG_WAITING))
!              == 0) {
!             if ((oldFileLock->LockType & LOCKING_ANDX_SHARED_LOCK) == 0
!                  || (fileLock->LockType & LOCKING_ANDX_SHARED_LOCK) == 0) {
!                 cm_ReleaseSCache(scp);
!                 return CM_ERROR_WOULDBLOCK;
              }
!             found = 1;
          }
-         q = osi_QNext(q);
      }
  
!     if (found)
!         code = 0;
!     else {
!         tfid.Volume = oldFileLock->fid.volume;
!         tfid.Vnode = oldFileLock->fid.vnode;
!         tfid.Unique = oldFileLock->fid.unique;
!         osi_Log1(afsd_logp, "CALL SetLock lock 0x%x", (long) oldFileLock);
!         do {
!             code = cm_Conn(&oldFileLock->fid, oldFileLock->userp,
!                             &req, &connp);
!             if (code) 
!                 break;
  
!             callp = cm_GetRxConn(connp);
!             code = RXAFS_SetLock(callp, &tfid, Which,
!                                   &volSync);
!             rx_PutConnection(callp);
  
!         } while (cm_Analyze(connp, oldFileLock->userp, &req,
!                              &oldFileLock->fid, &volSync,
!                              NULL, NULL, code));
!         code = cm_MapRPCError(code, &req);
  
!         if (code)
!             osi_Log1(afsd_logp, "CALL SetLock FAILURE, code 0x%x", code);
!         else
!             osi_Log0(afsd_logp, "CALL SetLock SUCCESS");
!     }
  
-   handleCode:
-     if (code != 0 && code != CM_ERROR_WOULDBLOCK) {
-         lock_ObtainMutex(&scp->mx);
-         osi_QRemove(&scp->fileLocks, &oldFileLock->fileq);
          lock_ReleaseMutex(&scp->mx);
      }
      lock_ObtainWrite(&cm_scacheLock);
!     if (code == 0)
!         oldFileLock->flags = 0;
!     else if (code != CM_ERROR_WOULDBLOCK) {
!         oldFileLock->flags |= CM_FILELOCK_FLAG_INVALID;
          cm_ReleaseUser(oldFileLock->userp);
          oldFileLock->userp = NULL;
      }
      lock_ReleaseWrite(&cm_scacheLock);
  
      return code;
  }
--- 2779,4522 ----
      return code;
  }
  
! /* Byte range locks:
  
!    The OpenAFS Windows client has to fake byte range locks given no
!    server side support for such locks.  This is implemented as keyed
!    byte range locks on the cache manager.
  
!    Keyed byte range locks:
  
!    Each cm_scache_t structure keeps track of a list of keyed locks.
!    The key for a lock is essentially a token which identifies an owner
!    of a set of locks (referred to as a client).  The set of keys used
!    within a specific cm_scache_t structure form a namespace that has a
!    scope of just that cm_scache_t structure.  The same key value can
!    be used with another cm_scache_t structure and correspond to a
!    completely different client.  However it is advantageous for the
!    SMB or IFS layer to make sure that there is a 1-1 mapping between
!    client and keys irrespective of the cm_scache_t.
  
!    Assume a client C has key Key(C) (although, since the scope of the
!    key is a cm_scache_t, the key can be Key(C,S), where S is the
!    cm_scache_t.  But assume a 1-1 relation between keys and clients).
!    A byte range (O,+L) denotes byte addresses (O) through (O+L-1)
!    inclusive (a.k.a. [O,O+L-1]).  The function Key(x) is implemented
!    through cm_generateKey() function for both SMB and IFS.
  
!    The cache manager will set a lock on the AFS file server in order
!    to assert the locks in S->fileLocks.  If only shared locks are in
!    place for S, then the cache manager will obtain a LockRead lock,
!    while if there are any exclusive locks, it will obtain a LockWrite
!    lock.  If the exclusive locks are all released while the shared
!    locks remain, then the cache manager will downgrade the lock from
!    LockWrite to LockRead.
  
!    Lock states:
  
!    A lock exists iff it is in S->fileLocks for some cm_scache_t
!    S. Existing locks are in one of the following states: ACTIVE,
!    WAITLOCK, WAITUNLOCK, LOST, DELETED.
  
!    The following sections describe each lock and the associated
!    transitions.
  
!    1. ACTIVE: A lock L is ACTIVE iff the cache manager has asserted
!       the lock with the AFS file server.  This type of lock can be
!       exercised by a client to read or write to the locked region (as
!       the lock allows).
  
!       1.1 ACTIVE->LOST: When the AFS file server fails to extend a
!         server lock that was required to assert the lock.
  
!       1.2 ACTIVE->DELETED: Lock is released.
  
!    2. WAITLOCK: A lock is in a WAITLOCK state if the cache manager
!       grants the lock but the lock is yet to be asserted with the AFS
!       file server.  Once the file server grants the lock, the state
!       will transition to an ACTIVE lock.
  
!       2.1 WAITLOCK->ACTIVE: The server granted the lock.
  
!       2.2 WAITLOCK->DELETED: Lock is abandoned, or timed out during
!         waiting.
  
!       2.3 WAITLOCK->LOST: One or more locks from this client were
!         marked as LOST.  No further locks will be granted to this
!         client until al lost locks are removed.
  
!    3. WAITUNLOCK: A lock is in a WAITUNLOCK state if the cache manager
!       receives a request for a lock that conflicts with an existing
!       ACTIVE or WAITLOCK lock.  The lock will be placed in the queue
!       and will be granted at such time the conflicting locks are
!       removed, at which point the state will transition to either
!       WAITLOCK or ACTIVE.
  
!       3.1 WAITUNLOCK->ACTIVE: The conflicting lock was removed.  The
!         current serverLock is sufficient to assert this lock, or a
!         sufficient serverLock is obtained.
  
!       3.2 WAITUNLOCK->WAITLOCK: The conflicting lock was removed,
!         however the required serverLock is yet to be asserted with the
!         server.
  
!       3.3 WAITUNLOCK->DELETED: The lock is abandoned or timed out.
  
!       3.5 WAITUNLOCK->LOST: One or more locks from this client were
!         marked as LOST.  No further locks will be granted to this
!         client until all lost locks are removed.
  
!    4. LOST: A lock L is LOST if the server lock that was required to
!       assert the lock could not be obtained or if it could not be
!       extended, or if other locks by the same client were LOST.
!       Effectively, once a lock is LOST, the contract between the cache
!       manager and that specific client is no longer valid.
  
!       The cache manager rechecks the server lock once every minute and
!       extends it as appropriate.  If this is not done for 5 minutes,
!       the AFS file server will release the lock.  Once released, the
!       lock cannot be re-obtained without verifying that the contents
!       of the file hasn't been modified since the time the lock was
!       released.  Doing so may cause data corruption.
  
!       4.1 LOST->DELETED: The lock is released.
  
!       4.2 LOST->ACTIVE: The lock is reassertd.  This requires
!         verifying that the file was not modified in between.
! 
!       4.3 LOST->WAITLOCK: All LOST ACTIVE locks from this client were
!         reasserted.  The cache manager can reinstate this waiting
!         lock.
! 
!       4.4 LOST->WAITUNLOCK: All LOST ACTIVE locks from this client
!         were reasserted.  The cache manager can reinstate this waiting
!         lock.
! 
!    5. DELETED: The lock is no longer relevant.  Eventually, it will
!       get removed from the cm_scache_t. In the meantime, it will be
!       treated as if it does not exist.
! 
!       5.1 DELETED->not exist: The lock is removed from the
!         cm_scache_t.
! 
!    6* A lock L is ACCEPTED if it is ACTIVE or WAITLOCK.
!       These locks have been accepted by the cache manager, but may or
!       may not have been granted back to the client.
! 
!    7* A lock L is QUEUED if it is ACTIVE, WAITLOCK or WAITUNLOCK.
! 
!    8* A lock L is EFFECTIVE if it is ACTIVE or LOST.
! 
!    9* A lock L is WAITING if it is WAITLOCK or WAITUNLOCK.
! 
!    Lock operation:
! 
!    A client C can READ range (Offset,+Length) of cm_scache_t S iff:
! 
!    1. for all _a_ in (Offset,+Length), one of the following is true:
! 
!        1.1 There does NOT exist an ACTIVE lock L in S->fileLocks such
!          that _a_ in (L->LOffset,+L->LLength) (IOW: byte _a_ of S is
!          unowned) 
! 
!          AND 
! 
!          For each LOST lock M in S->fileLocks such that
!          _a_ in (M->LOffset,+M->LLength), M->LockType is shared AND
!          M->key != Key(C).
! 
!          (Note: If this is a different client from one whose shared
!          lock was LOST, then the contract between this client and the
!          cache manager is indistinguishable from that where no lock
!          was lost.  If an exclusive lock was lost, then the range is
!          considered unsafe for consumption.)
! 
!        1.3 There is an ACTIVE lock L in S->fileLocks such that: L->key
!          == Key(C) && _a_ in (L->LOffset,+L->LLength) (IOW: byte _a_
!          of S is owned by C under lock L)
! 
!        1.4 There is an ACTIVE lock L in S->fileLocks such that _a_ in
!          (L->LOffset,L->+LLength) && L->LockType is shared (IOW: byte
!          _a_ of S is shared) AND there is no LOST lock M such that _a_
!          in (M->LOffset,+M->LLength) and M->key == Key(C)
! 
!    A client C can WRITE range (Offset,+Length) of cm_scache_t S iff:
! 
!    2. for all _a_ in (Offset,+Length), one of the following is true:
! 
!        2.1 Byte _a_ of S is unowned (as above) AND for each LOST lock
!          L in S->fileLocks _a_ NOT in (L->LOffset,+L->LLength).
! 
!        2.2 Byte _a_ of S is owned by C under lock L (as above) AND
!          L->LockType is exclusive.
! 
!    A client C can OBTAIN a lock L on cm_scache_t S iff:
! 
!    3. for all _a_ in (L->LOffset,+L->LLength), ALL of the following is
!       true:
! 
!        3.1 L->LockType is exclusive IMPLIES there does NOT exist a QUEUED lock
!          M in S->fileLocks such that _a_ in (M->LOffset,+M->LLength).
! 
!          (Note: If we count all QUEUED locks then we hit cases such as
!          cascading waiting locks where the locks later on in the queue
!          can be granted without compromising file integrity.  On the
!          other hand if only ACCEPTED locks are considered, then locks
!          that were received earlier may end up waiting for locks that
!          were received later to be unlocked. The choice of QUEUED
!          locks were made so that large locks don't consistently get
!          trumped by smaller locks which were requested later.)
! 
!        3.2 L->LockType is shared IMPLIES for each QUEUED lock M in
!          S->fileLocks, if _a_ in (M->LOffset,+M->LLength) then
!          M->LockType is shared.
! 
!    4. For each LOST lock M in S->fileLocks, M->key != Key(C)
! 
!          (Note: If a client loses a lock, it loses all locks.
!          Subsequently, it will not be allowed to obtain any more locks
!          until all existing LOST locks that belong to the client are
!          released.  Once all locks are released by a single client,
!          there exists no further contract between the client and AFS
!          about the contents of the file, hence the client can then
!          proceed to obtain new locks and establish a new contract.)
! 
!    A client C can only unlock locks L in S->fileLocks which have
!    L->key == Key(C).
! 
!    The representation and invariants are as follows:
! 
!    - Each cm_scache_t structure keeps:
! 
!        - A queue of byte-range locks (cm_scache_t::fileLocks) which
!          are of type cm_file_lock_t.
! 
!        - A record of the highest server-side lock that has been
!          obtained for this object (cm_scache_t::serverLock), which is
!          one of (-1), LockRead, LockWrite.
! 
!        - A count of ACCEPTED exclusive and shared locks that are in the
!          queue (cm_scache_t::sharedLocks and
!          cm_scache_t::exclusiveLocks)
! 
!    - Each cm_file_lock_t structure keeps:
! 
!        - The type of lock (cm_file_lock_t::LockType)
! 
!        - The key associated with the lock (cm_file_lock_t::key)
! 
!        - The offset and length of the lock (cm_file_lock_t::LOffset
!          and cm_file_lock_t::LLength)
! 
!        - The state of the lock.
! 
!        - Time of issuance or last successful extension
! 
!    Semantic invariants:
! 
!        I1. The number of ACCEPTED locks in S->fileLocks are
!            (S->sharedLocks + S->exclusiveLocks)
! 
!    External invariants:
! 
!        I3. S->serverLock is the lock that we have asserted with the
!            AFS file server for this cm_scache_t.
! 
!        I4. S->serverLock == LockRead iff there is at least one ACTIVE
!            shared lock, but no ACTIVE exclusive locks.
! 
!        I5. S->serverLock == LockWrite iff there is at least one ACTIVE
!            exclusive lock.
! 
!        I6. If a WAITUNLOCK lock L exists in S->fileLocks, then all
!            locks that L is waiting on are ahead of L in S->fileLocks.
! 
!        I7. If L is a LOST lock, then for each lock M in S->fileLocks,
!            M->key == L->key IMPLIES M is LOST or DELETED.
! 
!    --asanka
!  */
! 
! #define IS_LOCK_ACTIVE(lockp)     (((lockp)->flags & (CM_FILELOCK_FLAG_DELETED|CM_FILELOCK_FLAG_WAITLOCK|CM_FILELOCK_FLAG_WAITUNLOCK|CM_FILELOCK_FLAG_LOST))==0)
! 
! #define IS_LOCK_WAITLOCK(lockp)   (((lockp)->flags & (CM_FILELOCK_FLAG_DELETED|CM_FILELOCK_FLAG_WAITLOCK|CM_FILELOCK_FLAG_WAITUNLOCK|CM_FILELOCK_FLAG_LOST)) == CM_FILELOCK_FLAG_WAITLOCK)
! 
! #define IS_LOCK_WAITUNLOCK(lockp) (((lockp)->flags & (CM_FILELOCK_FLAG_DELETED|CM_FILELOCK_FLAG_WAITLOCK|CM_FILELOCK_FLAG_WAITUNLOCK|CM_FILELOCK_FLAG_LOST)) == CM_FILELOCK_FLAG_WAITUNLOCK)
! 
! #define IS_LOCK_LOST(lockp)       (((lockp)->flags & (CM_FILELOCK_FLAG_DELETED|CM_FILELOCK_FLAG_LOST)) == CM_FILELOCK_FLAG_LOST)
  
! #define IS_LOCK_DELETED(lockp)    (((lockp)->flags & CM_FILELOCK_FLAG_DELETED) == CM_FILELOCK_FLAG_DELETED)
! 
! /* the following macros are unsafe */
! #define IS_LOCK_ACCEPTED(lockp)   (IS_LOCK_ACTIVE(lockp) || IS_LOCK_WAITLOCK(lockp))
! 
! #define IS_LOCK_QUEUED(lockp)     (IS_LOCK_ACTIVE(lockp) || IS_LOCK_WAITLOCK(lockp) || IS_LOCK_WAITUNLOCK(lockp))
! 
! #define IS_LOCK_EFFECTIVE(lockp)  (IS_LOCK_ACTIVE(lockp) || IS_LOCK_LOST(lockp))
! 
! #define IS_LOCK_CLIENTONLY(lockp) ((((lockp)->scp->flags & CM_SCACHEFLAG_RO) == CM_SCACHEFLAG_RO) || (((lockp)->flags & CM_FILELOCK_FLAG_CLIENTONLY) == CM_FILELOCK_FLAG_CLIENTONLY))
! 
! #define INTERSECT_RANGE(r1,r2) (((r2).offset+(r2).length) > (r1).offset && ((r1).offset +(r1).length) > (r2).offset)
! 
! #define CONTAINS_RANGE(r1,r2) (((r2).offset+(r2).length) <= ((r1).offset+(r1).length) && (r1).offset <= (r2).offset)
! 
! static void cm_LockRangeSubtract(cm_range_t * pos, const cm_range_t * neg)
! {
!     afs_int64 int_begin;
!     afs_int64 int_end;
! 
!     int_begin = MAX(pos->offset, neg->offset);
!     int_end = MIN(pos->offset+pos->length, neg->offset+neg->length);
! 
!     if(int_begin < int_end) {
!         if(int_begin == pos->offset) {
!             pos->length = pos->offset + pos->length - int_end;
!             pos->offset = int_end;
!         } else if(int_end == pos->offset + pos->length) {
!             pos->offset = int_begin;
!             pos->length = int_end - int_begin;
          }
      }
! }
  
! /* Called with scp->mx held.  Returns 0 if all is clear to read the
!    specified range by the client identified by key.
!  */
! long cm_LockCheckRead(cm_scache_t *scp, 
!                       LARGE_INTEGER LOffset, 
!                       LARGE_INTEGER LLength, 
!                       cm_key_t key)
  {
! #ifndef ADVISORY_LOCKS
! 
      cm_file_lock_t *fileLock;
      osi_queue_t *q;
!     long code = 0;
!     cm_range_t range;
!     int substract_ranges = FALSE;
  
!     range.offset = LOffset.QuadPart;
!     range.length = LLength.QuadPart;
  
!    /*
!    1. for all _a_ in (Offset,+Length), one of the following is true:
  
!        1.1 There does NOT exist an ACTIVE lock L in S->fileLocks such
!          that _a_ in (L->LOffset,+L->LLength) (IOW: byte _a_ of S is
!          unowned)
! 
!          AND
! 
!          For each LOST lock M in S->fileLocks such that
!          _a_ in (M->LOffset,+M->LLength), M->LockType is shared AND
!          M->key != Key(C).
! 
!        1.3 There is an ACTIVE lock L in S->fileLocks such that: L->key
!          == Key(C) && _a_ in (L->LOffset,+L->LLength) (IOW: byte _a_
!          of S is owned by C under lock L)
! 
!        1.4 There is an ACTIVE lock L in S->fileLocks such that _a_ in
!          (L->LOffset,L->+LLength) && L->LockType is shared (IOW: byte
!          _a_ of S is shared) AND there is no LOST lock M such that _a_
!          in (M->LOffset,+M->LLength) and M->key == Key(C)
!     */
! 
!     lock_ObtainRead(&cm_scacheLock);
! 
!     for(q = scp->fileLocksH; q && range.length > 0; q = osi_QNext(q)) {
!         fileLock = 
!             (cm_file_lock_t *)((char *) q - offsetof(cm_file_lock_t, fileq));
! 
! #if 0
!         if(IS_LOCK_DELETED(fileLock) || 
!            (IS_LOCK_LOST(fileLock) && 
!             fileLock->lockType == LockRead && 
!             fileLock->key != key))
!             continue;
! #endif
  
!         if(INTERSECT_RANGE(range, fileLock->range)) {
!             if(IS_LOCK_ACTIVE(fileLock)) {
!                 if(fileLock->key == key) {
! 
!                     /* if there is an active lock for this client, it
!                        is safe to substract ranges */
!                     cm_LockRangeSubtract(&range, &fileLock->range);
!                     substract_ranges = TRUE;
!                 } else {
!                     if(fileLock->lockType != LockRead) {
!                         code = CM_ERROR_LOCK_CONFLICT;
!                         break;
!                     }
! 
!                     /* even if the entire range is locked for reading,
!                        we still can't grant the lock at this point
!                        because the client may have lost locks. That
!                        is, unless we have already seen an active lock
!                        belonging to the client, in which case there
!                        can't be any lost locks. */
!                     if(substract_ranges)
!                         cm_LockRangeSubtract(&range, &fileLock->range);
!                 }
!             } else if(IS_LOCK_LOST(fileLock)
! #if 0
!                       /* Uncomment for less aggressive handling of
!                          lost locks. */
!                       &&
!                       (fileLock->key == key || fileLock->lockType == LockWrite)
! #endif
!                       ) {
!                 code = CM_ERROR_BADFD;
!                 break;
              }
!         } else if (IS_LOCK_LOST(fileLock)) {
!             code = CM_ERROR_BADFD;
!             break;
          }
      }
  
!     lock_ReleaseRead(&cm_scacheLock);
  
!     osi_Log4(afsd_logp, "cm_LockCheckRead scp 0x%x offset %d length %d code 0x%x",
! 	      scp, (unsigned long)LOffset.QuadPart, (unsigned long)LLength.QuadPart, code);
  
!     return code;
  
! #else
! 
!     return 0;
! 
! #endif
! }
! 
! /* Called with scp->mx held.  Returns 0 if all is clear to write the
!    specified range by the client identified by key.
!  */
! long cm_LockCheckWrite(cm_scache_t *scp,
!                        LARGE_INTEGER LOffset,
!                        LARGE_INTEGER LLength,
!                        cm_key_t key)
! {
! #ifndef ADVISORY_LOCKS
! 
!     cm_file_lock_t *fileLock;
!     osi_queue_t *q;
!     long code = 0;
!     cm_range_t range;
! 
!     range.offset = LOffset.QuadPart;
!     range.length = LLength.QuadPart;
! 
!     /*
!    A client C can WRITE range (Offset,+Length) of cm_scache_t S iff:
! 
!    2. for all _a_ in (Offset,+Length), one of the following is true:
! 
!        2.1 Byte _a_ of S is unowned (as above) AND for each LOST lock
!          L in S->fileLocks _a_ NOT in (L->LOffset,+L->LLength).
! 
!        2.2 Byte _a_ of S is owned by C under lock L (as above) AND
!          L->LockType is exclusive.
! 
!     */
! 
!     lock_ObtainRead(&cm_scacheLock);
! 
!     for(q = scp->fileLocksH; q && range.length > 0; q = osi_QNext(q)) {
!         fileLock = 
!             (cm_file_lock_t *)((char *) q - offsetof(cm_file_lock_t, fileq));
! 
! #if 0
!         if(IS_LOCK_DELETED(fileLock) || 
!            (IS_LOCK_LOST(fileLock) && 
!             fileLock->lockType == LockRead && 
!             fileLock->key != key))
!             continue;
! #endif
! 
!         if(INTERSECT_RANGE(range, fileLock->range)) {
!             if(IS_LOCK_ACTIVE(fileLock)) {
!                 if(fileLock->key == key) {
!                     if(fileLock->lockType == LockWrite) {
! 
!                         /* if there is an active lock for this client, it
!                            is safe to substract ranges */
!                         cm_LockRangeSubtract(&range, &fileLock->range);
!                     } else {
!                         code = CM_ERROR_LOCK_CONFLICT;
!                         break;
!                     }
!                 } else {
!                     code = CM_ERROR_LOCK_CONFLICT;
!                     break;
!                 }
!             } else if(IS_LOCK_LOST(fileLock)) {
!                 code = CM_ERROR_BADFD;
!                 break;
!             }
!         } else if (IS_LOCK_LOST(fileLock)) {
!             code = CM_ERROR_BADFD;
!             break;
!         }
!     }
! 
!     lock_ReleaseRead(&cm_scacheLock);
! 
!     osi_Log4(afsd_logp, "cm_LockCheckWrite scp 0x%x offset %d length %d code 0x%x",
! 	      scp, (unsigned long)LOffset.QuadPart, (unsigned long)LLength.QuadPart, code);
! 
!     return code;
! 
! #else
! 
!     return 0;
! 
! #endif
! }
! 
! /* Forward dcl. */
! static void cm_LockMarkSCacheLost(cm_scache_t * scp);
! 
! /* Called with cm_scacheLock write locked */
! static cm_file_lock_t * cm_GetFileLock(void) {
!     cm_file_lock_t * l;
! 
!     l = (cm_file_lock_t *) cm_freeFileLocks;
!     if(l) {
!         osi_QRemove(&cm_freeFileLocks, &l->q);
!     } else {
!         l = malloc(sizeof(cm_file_lock_t));
!         osi_assert(l);
!     }
! 
!     memset(l, 0, sizeof(cm_file_lock_t));
! 
!     return l;
! }
! 
! /* Called with cm_scacheLock write locked */
! static void cm_PutFileLock(cm_file_lock_t *l) {
!     osi_QAdd(&cm_freeFileLocks, &l->q);
! }
! 
! /* called with scp->mx held */
! long cm_Lock(cm_scache_t *scp, unsigned char sLockType,
!              LARGE_INTEGER LOffset, LARGE_INTEGER LLength,
!              cm_key_t key,
!              int allowWait, cm_user_t *userp, cm_req_t *reqp,
!              cm_file_lock_t **lockpp)
! {
!     long code = 0;
!     int Which = ((sLockType & LOCKING_ANDX_SHARED_LOCK) ? LockRead : LockWrite);
!     AFSFid tfid;
!     AFSVolSync volSync;
!     cm_conn_t *connp;
!     cm_file_lock_t *fileLock;
!     osi_queue_t *q;
!     struct rx_connection * callp;
!     cm_range_t range;
!     int wait_unlock = FALSE;
! 
!     osi_Log4(afsd_logp, "cm_Lock scp 0x%x type 0x%x offset %d length %d",
!              scp, sLockType, (unsigned long)LOffset.QuadPart, (unsigned long)LLength.QuadPart);
!     osi_Log3(afsd_logp, "... allowWait %d key 0x%x:%x", allowWait, 
!              (unsigned long)(key >> 32), (unsigned long)(key & 0xffffffff));
! 
!     /*
!    A client C can OBTAIN a lock L on cm_scache_t S iff:
! 
!    3. for all _a_ in (L->LOffset,+L->LLength), ALL of the following is
!       true:
! 
!        3.1 L->LockType is exclusive IMPLIES there does NOT exist a QUEUED lock
!          M in S->fileLocks such that _a_ in (M->LOffset,+M->LLength).
! 
!        3.2 L->LockType is shared IMPLIES for each QUEUED lock M in
!          S->fileLocks, if _a_ in (M->LOffset,+M->LLength) then
!          M->LockType is shared.
! 
!    4. For each LOST lock M in S->fileLocks, M->key != Key(C)
!     */
! 
!     range.offset = LOffset.QuadPart;
!     range.length = LLength.QuadPart;
! 
!     lock_ObtainRead(&cm_scacheLock);
! 
!     for(q = scp->fileLocksH; q; q = osi_QNext(q)) {
!         fileLock = 
!             (cm_file_lock_t *)((char *) q - offsetof(cm_file_lock_t, fileq));
! 
!         if(IS_LOCK_LOST(fileLock) && fileLock->key == key) {
!             code = CM_ERROR_BADFD;
!             break;
!         }
! 
!         /* we don't need to check for deleted locks here since deleted
!            locks are dequeued from fileLocks */
!         if(INTERSECT_RANGE(range, fileLock->range)) {
! 
!             if((sLockType & LOCKING_ANDX_SHARED_LOCK) == 0 ||
!                 fileLock->lockType != LockRead) {
!                 wait_unlock = TRUE;
!                 code = CM_ERROR_WOULDBLOCK;
!                 break;
!             }
!         }
!     }
! 
!     lock_ReleaseRead(&cm_scacheLock);
! 
!     if(code == 0 && !(scp->flags & CM_SCACHEFLAG_RO)) {
!         if(Which == scp->serverLock ||
!            (Which == LockRead && scp->serverLock == LockWrite)) {
! 
!             /* we already have the lock we need */
!             osi_Log3(afsd_logp, "   we already have the correct lock. exclusives[%d], shared[%d], serverLock[%d]", 
!                      scp->exclusiveLocks, scp->sharedLocks, (int)(signed char) scp->serverLock);
!             code = 0; /* redundant */
! 
!         } else if((scp->exclusiveLocks > 0) ||
!                 (scp->sharedLocks > 0 && scp->serverLock != LockRead)) {
! 
!             /* We are already waiting for some other lock.  We should
!                wait for the daemon to catch up instead of generating a
!                flood of SetLock calls. */
!             osi_Log3(afsd_logp, "   already waiting for other lock. exclusives[%d], shared[%d], serverLock[%d]",
!                      scp->exclusiveLocks, scp->sharedLocks, (int)(signed char) scp->serverLock);
!             code = CM_ERROR_WOULDBLOCK;
! 
!         } else {
!             cm_fid_t cfid;
!             int newLock;
! 
!             if (scp->serverLock == LockRead && Which == LockWrite) {
!             
!                 /* We want to escalate the lock to a LockWrite.
!                    Unfortunately that's not really possible without
!                    letting go of the current lock.  But for now we do
!                    it anyway. */
! 
!                 osi_Log0(afsd_logp, "   attempting to UPGRADE from LockRead to LockWrite.");
! 
!                 tfid.Volume = scp->fid.volume;
!                 tfid.Vnode = scp->fid.vnode;
!                 tfid.Unique = scp->fid.unique;
!                 cfid = scp->fid;
! 
!                 lock_ReleaseMutex(&scp->mx);
! 
!                 osi_Log1(afsd_logp, "CALL ReleaseLock scp 0x%x", (long) scp);
! 
!                 do {
!                     code = cm_Conn(&cfid, userp, reqp, &connp);
!                     if (code) 
!                         break;
! 
!                     callp = cm_GetRxConn(connp);
!                     code = RXAFS_ReleaseLock(callp, &tfid, &volSync);
!                     rx_PutConnection(callp);
! 
!                 } while (cm_Analyze(connp, userp, reqp, &cfid, &volSync,
!                                     NULL, NULL, code));
!                 code = cm_MapRPCError(code, reqp);
! 
!                 if (code)
!                     osi_Log1(afsd_logp, "CALL ReleaseLock FAILURE, code 0x%x", code);
!                 else
!                     osi_Log0(afsd_logp, "CALL ReleaseLock SUCCESS");
!         
!                 lock_ObtainMutex(&scp->mx);
! 
!                 if (code) {
!                     /* We couldn't release the lock */
!                     goto check_code;
!                 } else {
!                     scp->serverLock = -1;
!                 }
!             }
! 
!             /* We need to obtain a server lock of type Which in order
!                to assert this file lock */
!             tfid.Volume = scp->fid.volume;
!             tfid.Vnode = scp->fid.vnode;
!             tfid.Unique = scp->fid.unique;
!             cfid = scp->fid;
! 
! #ifndef AGGRESSIVE_LOCKS
!             newLock = Which;
! #else
!             newLock = LockWrite;
! #endif
!             osi_Log3(afsd_logp, "CALL SetLock scp 0x%x from %d to %d", (long) scp, (int) scp->serverLock, newLock);
! 
!             lock_ReleaseMutex(&scp->mx);
! 
!             do {
!                 code = cm_Conn(&cfid, userp, reqp, &connp);
!                 if (code) 
!                     break;
! 
!                 callp = cm_GetRxConn(connp);
!                 code = RXAFS_SetLock(callp, &tfid, newLock,
!                                      &volSync);
!                 rx_PutConnection(callp);
! 
!             } while (cm_Analyze(connp, userp, reqp, &cfid, &volSync,
!                                 NULL, NULL, code));
! 
!             code = cm_MapRPCError(code, reqp);
!             
!             if (code) {
!                 osi_Log1(afsd_logp, "CALL SetLock FAILURE, code 0x%x", code);
!             } else {
!                 osi_Log0(afsd_logp, "CALL SetLock SUCCESS");
!             }
! 
!             if (code == CM_ERROR_WOULDBLOCK && newLock != Which) {
!                 /* we wanted LockRead.  We tried LockWrite. Now try LockRead again */
!                 newLock = Which;
! 
!                 /* am I sane? */
!                 osi_assert(newLock == LockRead);
!                 
!                 osi_Log3(afsd_logp, "CALL SetLock AGAIN scp 0x%x from %d to %d", 
!                          (long) scp, (int) scp->serverLock, newLock);
! 
!                 do {
!                     code = cm_Conn(&cfid, userp, reqp, &connp);
!                     if (code) 
!                         break;
! 
!                     callp = cm_GetRxConn(connp);
!                     code = RXAFS_SetLock(callp, &tfid, newLock,
!                                          &volSync);
!                     rx_PutConnection(callp);
! 
!                 } while (cm_Analyze(connp, userp, reqp, &cfid, &volSync,
!                                     NULL, NULL, code));
! 
!                 code = cm_MapRPCError(code, reqp);                
! 
!                 if (code) {
!                     osi_Log1(afsd_logp, "CALL SetLock FAILURE AGAIN, code 0x%x", code);
!                 } else {
!                     osi_Log0(afsd_logp, "CALL SetLock SUCCESS");
!                 }
!             }
! 
!             lock_ObtainMutex(&scp->mx);
! 
!             if(code == 0)
!                 scp->serverLock = newLock;
!             else {
!                 if ((scp->sharedLocks > 0 || scp->exclusiveLocks > 0) &&
!                     scp->serverLock == -1) {
!                     /* Oops. We lost the lock. */
!                     cm_LockMarkSCacheLost(scp);
!                 }
!             }
!         }
!     } else if (code == 0 && (scp->flags & CM_SCACHEFLAG_RO)) {
!         osi_Log0(afsd_logp, "  Skipping server lock for RO scp");
!     }
! 
!  check_code:
! 
!     if (code != 0) {
!         /* Special case error translations
! 
!            Applications don't expect certain errors from a
!            LockFile/UnlockFile call.  We need to translate some error
!            code to codes that apps expect and handle. */
! 
!         /* We shouldn't actually need to handle this case since we
!            simulate locks for RO scps anyway. */
!         if (code == CM_ERROR_READONLY) {
!             osi_Log0(afsd_logp, "   Reinterpreting CM_ERROR_READONLY as CM_ERROR_NOACCESS");
!             code = CM_ERROR_NOACCESS;
!         }
!     }
! 
!     if (code == 0 || (code == CM_ERROR_WOULDBLOCK && allowWait)) {
! 
!         lock_ObtainWrite(&cm_scacheLock);
!         fileLock = cm_GetFileLock();
!         lock_ReleaseWrite(&cm_scacheLock);
! #ifdef DEBUG
!         fileLock->fid = scp->fid;
! #endif
!         fileLock->key = key;
!         fileLock->lockType = Which;
!         cm_HoldUser(userp);
!         fileLock->userp = userp;
!         fileLock->range = range;
!         fileLock->flags = (code == 0 ? 0 : 
!                            ((wait_unlock)?
!                             CM_FILELOCK_FLAG_WAITUNLOCK :
!                             CM_FILELOCK_FLAG_WAITLOCK));
! 
!         fileLock->lastUpdate = (code == 0) ? time(NULL) : 0;
! 
!         osi_QAddT(&scp->fileLocksH, &scp->fileLocksT, &fileLock->fileq);
! 
!         lock_ObtainWrite(&cm_scacheLock);
!         cm_HoldSCacheNoLock(scp);
!         fileLock->scp = scp;
!         osi_QAdd(&cm_allFileLocks, &fileLock->q);
!         lock_ReleaseWrite(&cm_scacheLock);
! 
!         if (code != 0) {
!             *lockpp = fileLock;
!         }
! 
!         if (IS_LOCK_ACCEPTED(fileLock)) {
!             if(Which == LockRead)
!                 scp->sharedLocks++;
!             else
!                 scp->exclusiveLocks++;
!         }
! 
!         osi_Log2(afsd_logp, "cm_Lock Lock added 0x%x flags 0x%x", (long) fileLock, fileLock->flags);
!         osi_Log4(afsd_logp, "   scp[0x%x] exclusives[%d] shared[%d] serverLock[%d]",
!                  scp, scp->exclusiveLocks, scp->sharedLocks, (int)(signed char) scp->serverLock);
!     }
! 
!     return code;
! }
! 
! static int cm_KeyEquals(cm_key_t k1, cm_key_t k2, int flags);
! 
! /* Called with scp->mx held */
! long cm_UnlockByKey(cm_scache_t * scp,
!                     cm_key_t key,
!                     int flags,
!                     cm_user_t * userp,
!                     cm_req_t * reqp)
! {
!     long code = 0;
!     AFSFid tfid;
!     AFSVolSync volSync;
!     cm_conn_t *connp;
!     cm_file_lock_t *fileLock;
!     osi_queue_t *q, *qn;
!     struct rx_connection * callp;
!     int n_unlocks = 0;
! 
!     osi_Log3(afsd_logp, "cm_UnlockByKey scp 0x%x key 0x%x:%x",
!              (long) scp, (unsigned long)(key >> 32), (unsigned long)(key & 0xffffffff));
! 
!     lock_ObtainWrite(&cm_scacheLock);
! 
!     for(q = scp->fileLocksH; q; q = qn) {
!         qn = osi_QNext(q);
! 
!         fileLock = (cm_file_lock_t *)
!             ((char *) q - offsetof(cm_file_lock_t, fileq));
! 
! #ifdef DEBUG
!         osi_Log4(afsd_logp, "   Checking lock[0x%x] range[%d,+%d] type[%d]",
!                 fileLock, (unsigned long) fileLock->range.offset, (unsigned long) fileLock->range.length,
!                 fileLock->lockType);
!         osi_Log3(afsd_logp, "     key[0x%x:%x] flags[0x%x]",
!                  (unsigned long)(fileLock->key >> 32),
!                  (unsigned long)(fileLock->key & 0xffffffff),
!                  fileLock->flags);
! 
!         if(cm_FidCmp(&fileLock->fid, &fileLock->scp->fid)) {
!             osi_Log0(afsd_logp, "!!fileLock->fid != scp->fid");
!             osi_Log4(afsd_logp, "  fileLock->fid(cell=[%d], volume=[%d], vnode=[%d], unique=[%d]",
!                      fileLock->fid.cell,
!                      fileLock->fid.volume,
!                      fileLock->fid.vnode,
!                      fileLock->fid.unique);
!             osi_Log4(afsd_logp, "  scp->fid(cell=[%d], volume=[%d], vnode=[%d], unique=[%d]",
!                      fileLock->scp->fid.cell,
!                      fileLock->scp->fid.volume,
!                      fileLock->scp->fid.vnode,
!                      fileLock->scp->fid.unique);
!             osi_assert(FALSE);
!         }
! #endif
! 
!         if (!IS_LOCK_DELETED(fileLock) &&
!             cm_KeyEquals(fileLock->key, key, flags)) {
!             osi_Log3(afsd_logp, "...Unlock range [%d,+%d] type %d",
!                     fileLock->range.offset,
!                     fileLock->range.length,
!                     fileLock->lockType);
! 
!             if (scp->fileLocksT == q)
!                 scp->fileLocksT = osi_QPrev(q);
!             osi_QRemove(&scp->fileLocksH,q);
! 
!             if(IS_LOCK_ACCEPTED(fileLock)) {
!                 if(fileLock->lockType == LockRead)
!                     scp->sharedLocks--;
!                 else
!                     scp->exclusiveLocks--;
!             }
! 
!             fileLock->flags |= CM_FILELOCK_FLAG_DELETED;
! 
!             cm_ReleaseUser(fileLock->userp);
!             cm_ReleaseSCacheNoLock(scp);
! 
!             fileLock->userp = NULL;
!             fileLock->scp = NULL;
! 
!             n_unlocks++;
!         }
!     }
! 
!     lock_ReleaseWrite(&cm_scacheLock);
! 
!     if(n_unlocks == 0) {
!         osi_Log0(afsd_logp, "cm_UnlockByKey no locks found");
!         osi_Log3(afsd_logp, "   Leaving scp with exclusives[%d], shared[%d], serverLock[%d]",
!                  scp->exclusiveLocks, scp->sharedLocks, (int)(signed char) scp->serverLock);
!         
!         return 0;
!     }
! 
!     osi_Log1(afsd_logp, "cm_UnlockByKey done with %d locks", n_unlocks);
! 
!     osi_assertx(scp->sharedLocks >= 0, "scp->sharedLocks < 0");
!     osi_assertx(scp->exclusiveLocks >= 0, "scp->exclusiveLocks < 0");
! 
!     if (scp->flags & CM_SCACHEFLAG_RO) {
!         osi_Log0(afsd_logp, "  Skipping server lock for RO scp");
!         goto done;
!     }
! 
!     /* Ideally we would go through the rest of the locks to determine
!      * if one or more locks that were formerly in WAITUNLOCK can now
!      * be put to ACTIVE or WAITLOCK and update scp->exclusiveLocks and
!      * scp->sharedLocks accordingly.  However, the retrying of locks
!      * in that manner is done cm_RetryLock() manually.
!      */
! 
!     if (scp->serverLock == LockWrite && scp->exclusiveLocks == 0 && scp->sharedLocks > 0) {
! 
!         cm_fid_t cfid;
! 
!         /* The serverLock should be downgraded to LockRead */
!         osi_Log0(afsd_logp, "  DOWNGRADE lock from LockWrite to LockRead");
! 
!         tfid.Volume = scp->fid.volume;
!         tfid.Vnode = scp->fid.vnode;
!         tfid.Unique = scp->fid.unique;
!         cfid = scp->fid;
! 
!         lock_ReleaseMutex(&scp->mx);
! 
!         osi_Log1(afsd_logp, "CALL ReleaseLock scp 0x%x", (long) scp);
! 
!         do {
!             code = cm_Conn(&cfid, userp, reqp, &connp);
!             if (code) 
!                 break;
! 
!             callp = cm_GetRxConn(connp);
!             code = RXAFS_ReleaseLock(callp, &tfid, &volSync);
!             rx_PutConnection(callp);
!             
!         } while (cm_Analyze(connp, userp, reqp, &cfid, &volSync,
!                             NULL, NULL, code));
!         code = cm_MapRPCError(code, reqp);
! 
!         if (code)
!             osi_Log1(afsd_logp, "CALL ReleaseLock FAILURE, code 0x%x", code);
!         else
!             osi_Log0(afsd_logp, "CALL ReleaseLock SUCCESS");
!         
!         lock_ObtainMutex(&scp->mx);
! 
!         if (code) {
!             /* so we couldn't release it.  Just let the lock be for now */
!             code = 0;
!             goto done;
!         } else {
!             scp->serverLock = -1;
!         }
! 
!         tfid.Volume = scp->fid.volume;
!         tfid.Vnode = scp->fid.vnode;
!         tfid.Unique = scp->fid.unique;
!         cfid = scp->fid;
! 
!         osi_Log3(afsd_logp, "CALL SetLock scp 0x%x from %d to %d", (long) scp, (int) scp->serverLock, LockRead);
! 
!         lock_ReleaseMutex(&scp->mx);
! 
!         do {
! 
!             code = cm_Conn(&cfid, userp, reqp, &connp);
!             if (code) 
!                 break;
! 
!             callp = cm_GetRxConn(connp);
!             code = RXAFS_SetLock(callp, &tfid, LockRead,
!                                  &volSync);
! 
!             rx_PutConnection(callp);
!             
!         } while (cm_Analyze(connp, userp, reqp, &cfid, &volSync,
!                             NULL, NULL, code));
! 
!         if (code)
!             osi_Log1(afsd_logp, "CALL SetLock FAILURE, code 0x%x", code);
!         else {
!             osi_Log0(afsd_logp, "CALL SetLock SUCCESS");
!         }
! 
!         lock_ObtainMutex(&scp->mx);
!         
!         if(code == 0)
!             scp->serverLock = LockRead;
!         else {
!             if ((scp->sharedLocks > 0 || scp->exclusiveLocks > 0) &&
!                 (scp->serverLock == -1)) {
!                 /* Oopsie */
!                 cm_LockMarkSCacheLost(scp);
!             }
!         }
! 
!         /* failure here has no bearing on the return value of
!            cm_Unlock() */
!         code = 0;
! 
!     } else if(scp->serverLock != (-1) && scp->exclusiveLocks == 0 && scp->sharedLocks == 0) {
!         cm_fid_t cfid;
! 
!         /* The serverLock should be released entirely */
! 
!         tfid.Volume = scp->fid.volume;
!         tfid.Vnode = scp->fid.vnode;
!         tfid.Unique = scp->fid.unique;
!         cfid = scp->fid;
! 
!         lock_ReleaseMutex(&scp->mx);
! 
!         osi_Log1(afsd_logp, "CALL ReleaseLock scp 0x%x", (long) scp);
! 
!         do {
!             code = cm_Conn(&cfid, userp, reqp, &connp);
!             if (code) 
!                 break;
! 
!             callp = cm_GetRxConn(connp);
!             code = RXAFS_ReleaseLock(callp, &tfid, &volSync);
!             rx_PutConnection(callp);
! 
!         } while (cm_Analyze(connp, userp, reqp, &cfid, &volSync,
!                             NULL, NULL, code));
!         code = cm_MapRPCError(code, reqp);
! 
!         if (code)
!             osi_Log1(afsd_logp, "CALL ReleaseLock FAILURE, code 0x%x", code);
!         else
!             osi_Log0(afsd_logp, "CALL ReleaseLock SUCCESS");
!         
!         lock_ObtainMutex(&scp->mx);
! 
!         if (code == 0)
!             scp->serverLock = (-1);
!     }
! 
!  done:
! 
!     osi_Log1(afsd_logp, "cm_UnlockByKey code 0x%x", code);
!     osi_Log3(afsd_logp, "   Leaving scp with exclusives[%d], shared[%d], serverLock[%d]",
!              scp->exclusiveLocks, scp->sharedLocks, (int)(signed char) scp->serverLock);
! 
!     return code;
! }
! 
! long cm_Unlock(cm_scache_t *scp, 
!                unsigned char sLockType,
!                LARGE_INTEGER LOffset, LARGE_INTEGER LLength,
!                cm_key_t key, 
!                cm_user_t *userp, 
!                cm_req_t *reqp)
! {
!     long code = 0;
!     int Which = ((sLockType & LOCKING_ANDX_SHARED_LOCK) ? LockRead : LockWrite);
!     AFSFid tfid;
!     AFSVolSync volSync;
!     cm_conn_t *connp;
!     cm_file_lock_t *fileLock;
!     osi_queue_t *q;
!     int release_userp = FALSE;
!     struct rx_connection * callp;
! 
!     osi_Log4(afsd_logp, "cm_Unlock scp 0x%x type 0x%x offset %d length %d",
!              (long) scp, sLockType, (unsigned long)LOffset.QuadPart, (unsigned long)LLength.QuadPart);
!     osi_Log2(afsd_logp, "... key 0x%x:%x",
!              (unsigned long) (key >> 32), (unsigned long) (key & 0xffffffff));
! 
!     lock_ObtainRead(&cm_scacheLock);
! 
!     for(q = scp->fileLocksH; q; q = osi_QNext(q)) {
!         fileLock = (cm_file_lock_t *)
!             ((char *) q - offsetof(cm_file_lock_t, fileq));
! 
! #ifdef DEBUG
!         if(cm_FidCmp(&fileLock->fid, &fileLock->scp->fid)) {
!             osi_Log0(afsd_logp, "!!fileLock->fid != scp->fid");
!             osi_Log4(afsd_logp, "  fileLock->fid(cell=[%d], volume=[%d], vnode=[%d], unique=[%d]",
!                      fileLock->fid.cell,
!                      fileLock->fid.volume,
!                      fileLock->fid.vnode,
!                      fileLock->fid.unique);
!             osi_Log4(afsd_logp, "  scp->fid(cell=[%d], volume=[%d], vnode=[%d], unique=[%d]",
!                      fileLock->scp->fid.cell,
!                      fileLock->scp->fid.volume,
!                      fileLock->scp->fid.vnode,
!                      fileLock->scp->fid.unique);
!             osi_assert(FALSE);
!         }
! #endif
!         if (!IS_LOCK_DELETED(fileLock) &&
!             fileLock->key == key &&
!             fileLock->range.offset == LOffset.QuadPart &&
!             fileLock->range.length == LLength.QuadPart) {
!             break;
!         }
!     }
! 
!     if(!q) {
!         osi_Log0(afsd_logp, "cm_Unlock lock not found; failure");
!         
!         lock_ReleaseRead(&cm_scacheLock);
! 
!         /* The lock didn't exist anyway. *shrug* */
!         return 0;
!     }
! 
!     /* discard lock record */
!     if (scp->fileLocksT == q)
!         scp->fileLocksT = osi_QPrev(q);
!     osi_QRemove(&scp->fileLocksH, q);
! 
!     lock_ReleaseRead(&cm_scacheLock);
! 
!     /*
!      * Don't delete it here; let the daemon delete it, to simplify
!      * the daemon's traversal of the list.
!      */
! 
!     lock_ObtainWrite(&cm_scacheLock);
! 
!     if(IS_LOCK_ACCEPTED(fileLock)) {
!         if(fileLock->lockType == LockRead)
!             scp->sharedLocks--;
!         else
!             scp->exclusiveLocks--;
!     }
! 
!     fileLock->flags |= CM_FILELOCK_FLAG_DELETED;
!     if (userp != NULL) {
!         cm_ReleaseUser(fileLock->userp);
!     } else {
!         userp = fileLock->userp;
!         release_userp = TRUE;
!     }
!     fileLock->userp = NULL;
!     cm_ReleaseSCacheNoLock(scp);
!     fileLock->scp = NULL;
!     lock_ReleaseWrite(&cm_scacheLock);
! 
!     if (scp->flags & CM_SCACHEFLAG_RO) {
!         osi_Log0(afsd_logp, "   Skipping server locks for RO scp");
!         goto done;
!     }
! 
!     /* Ideally we would go through the rest of the locks to determine
!      * if one or more locks that were formerly in WAITUNLOCK can now
!      * be put to ACTIVE or WAITLOCK and update scp->exclusiveLocks and
!      * scp->sharedLocks accordingly.  However, the retrying of locks
!      * in that manner is done cm_RetryLock() manually.
!      */
! 
!     if (scp->serverLock == LockWrite && scp->exclusiveLocks == 0 && scp->sharedLocks > 0) {
! 
!         cm_fid_t cfid;
! 
!         /* The serverLock should be downgraded to LockRead */
!         osi_Log0(afsd_logp, "  DOWNGRADE lock from LockWrite to LockRead");
! 
!         tfid.Volume = scp->fid.volume;
!         tfid.Vnode = scp->fid.vnode;
!         tfid.Unique = scp->fid.unique;
!         cfid = scp->fid;
! 
!         lock_ReleaseMutex(&scp->mx);
! 
!         osi_Log1(afsd_logp, "CALL ReleaseLock scp 0x%x", (long) scp);
! 
!         do {
!             code = cm_Conn(&cfid, userp, reqp, &connp);
!             if (code) 
!                 break;
! 
!             callp = cm_GetRxConn(connp);
!             code = RXAFS_ReleaseLock(callp, &tfid, &volSync);
!             rx_PutConnection(callp);
!             
!         } while (cm_Analyze(connp, userp, reqp, &cfid, &volSync,
!                             NULL, NULL, code));
! 
!         code = cm_MapRPCError(code, reqp);
! 
!         if (code)
!             osi_Log1(afsd_logp, "CALL ReleaseLock FAILURE, code 0x%x", code);
!         else
!             osi_Log0(afsd_logp, "CALL ReleaseLock SUCCESS");
!         
!         lock_ObtainMutex(&scp->mx);
! 
!         if (code) {
!             /* so we couldn't release it.  Just let the lock be for now */
!             code = 0;
!             goto done;
!         } else {
!             scp->serverLock = -1;
!         }
! 
!         tfid.Volume = scp->fid.volume;
!         tfid.Vnode = scp->fid.vnode;
!         tfid.Unique = scp->fid.unique;
!         cfid = scp->fid;
! 
!         osi_Log3(afsd_logp, "CALL SetLock scp 0x%x from %d to %d", (long) scp, (int) scp->serverLock, LockRead);
! 
!         lock_ReleaseMutex(&scp->mx);
! 
!         do {
! 
!             code = cm_Conn(&cfid, userp, reqp, &connp);
!             if (code) 
!                 break;
! 
!             callp = cm_GetRxConn(connp);
!             code = RXAFS_SetLock(callp, &tfid, LockRead,
!                                  &volSync);
! 
!             rx_PutConnection(callp);
!             
!         } while (cm_Analyze(connp, userp, reqp, &cfid, &volSync,
!                             NULL, NULL, code));
! 
!         if (code)
!             osi_Log1(afsd_logp, "CALL SetLock FAILURE, code 0x%x", code);
!         else {
!             osi_Log0(afsd_logp, "CALL SetLock SUCCESS");
!         }
! 
!         lock_ObtainMutex(&scp->mx);
!         
!         if(code == 0)
!             scp->serverLock = LockRead;
!         else {
!             if ((scp->sharedLocks > 0 || scp->exclusiveLocks > 0) &&
!                 (scp->serverLock == -1)) {
!                 /* Oopsie */
!                 cm_LockMarkSCacheLost(scp);
!             }
!         }
! 
!         /* failure here has no bearing on the return value of
!            cm_Unlock() */
!         code = 0;
! 
!     } else if(scp->serverLock != (-1) && scp->exclusiveLocks == 0 && scp->sharedLocks == 0) {
!         cm_fid_t cfid;
! 
!         /* The serverLock should be released entirely */
! 
!         tfid.Volume = scp->fid.volume;
!         tfid.Vnode = scp->fid.vnode;
!         tfid.Unique = scp->fid.unique;
!         cfid = scp->fid;
  
          lock_ReleaseMutex(&scp->mx);
+ 
+         osi_Log1(afsd_logp, "CALL ReleaseLock scp 0x%x", (long) scp);
+ 
+         do {
+             code = cm_Conn(&cfid, userp, reqp, &connp);
+             if (code) 
+                 break;
+ 
+             callp = cm_GetRxConn(connp);
+             code = RXAFS_ReleaseLock(callp, &tfid, &volSync);
+             rx_PutConnection(callp);
+ 
+         } while (cm_Analyze(connp, userp, reqp, &cfid, &volSync,
+                             NULL, NULL, code));
+         code = cm_MapRPCError(code, reqp);
+ 
+         if (code)
+             osi_Log1(afsd_logp, "CALL ReleaseLock FAILURE, code 0x%x", code);
+         else
+             osi_Log0(afsd_logp, "CALL ReleaseLock SUCCESS");
+         
+         lock_ObtainMutex(&scp->mx);
+ 
+         if (code == 0) {
+             scp->serverLock = (-1);
+         }
      }
+ 
+     if (release_userp)
+         cm_ReleaseUser(userp);
+ 
+  done:
+ 
+     osi_Log4(afsd_logp, "cm_Unlock code 0x%x leaving scp with exclusives[%d], shared[%d], serverLock[%d]",
+              code, scp->exclusiveLocks, scp->sharedLocks, (int)(signed char) scp->serverLock);
+ 
+     return code;
+ }
+ 
+ /* called with scp->mx held */
+ static void cm_LockMarkSCacheLost(cm_scache_t * scp)
+ {
+     cm_file_lock_t *fileLock;
+     osi_queue_t *q;
+ 
+     osi_Log1(afsd_logp, "cm_LockMarkSCacheLost scp 0x%x", scp);
+ 
+ #ifdef DEBUG
+     /* With the current code, we can't lose a lock on a RO scp */
+     osi_assert(!(scp->flags & CM_SCACHEFLAG_RO));
+ #endif
+ 
+     /* cm_scacheLock needed because we are modifying fileLock->flags */
      lock_ObtainWrite(&cm_scacheLock);
! 
!     for(q = scp->fileLocksH; q; q = osi_QNext(q)) {
!         fileLock = 
!             (cm_file_lock_t *)((char *) q - offsetof(cm_file_lock_t, fileq));
! 
!         if(IS_LOCK_ACTIVE(fileLock)) {
!             if (fileLock->lockType == LockRead)
!                 scp->sharedLocks--;
!             else
!                 scp->exclusiveLocks--;
! 
!             fileLock->flags |= CM_FILELOCK_FLAG_LOST;
!         }
!     }
! 
!     scp->serverLock = -1;
!     lock_ReleaseWrite(&cm_scacheLock);
! }
! 
! /* Called with no relevant locks held */
! void cm_CheckLocks()
! {
!     osi_queue_t *q, *nq;
!     cm_file_lock_t *fileLock;
!     cm_req_t req;
!     AFSFid tfid;
!     AFSVolSync volSync;
!     cm_conn_t *connp;
!     long code;
!     struct rx_connection * callp;
!     cm_scache_t * scp;
! 
!     cm_InitReq(&req);
! 
!     lock_ObtainWrite(&cm_scacheLock);
! 
!     cm_lockRefreshCycle++;
! 
!     osi_Log1(afsd_logp, "cm_CheckLocks starting lock check cycle %d", cm_lockRefreshCycle);
! 
!     for(q = cm_allFileLocks; q; q = nq) {
!         fileLock = (cm_file_lock_t *) q;
! 
!         nq = osi_QNext(q);
! 
!         if (IS_LOCK_DELETED(fileLock)) {
! 
!             osi_QRemove(&cm_allFileLocks, q);
!             cm_PutFileLock(fileLock);
! 
!         } else if (IS_LOCK_ACTIVE(fileLock) && !IS_LOCK_CLIENTONLY(fileLock)) {
! 
!             scp = fileLock->scp;
!             osi_assert(scp != NULL);
! 
!             cm_HoldSCacheNoLock(scp);
! 
! #ifdef DEBUG
!             if(cm_FidCmp(&fileLock->fid, &fileLock->scp->fid)) {
!                 osi_Log0(afsd_logp, "!!fileLock->fid != scp->fid");
!                 osi_Log4(afsd_logp, "  fileLock->fid(cell=[%d], volume=[%d], vnode=[%d], unique=[%d]",
!                          fileLock->fid.cell,
!                          fileLock->fid.volume,
!                          fileLock->fid.vnode,
!                          fileLock->fid.unique);
!                 osi_Log4(afsd_logp, "  scp->fid(cell=[%d], volume=[%d], vnode=[%d], unique=[%d]",
!                          fileLock->scp->fid.cell,
!                          fileLock->scp->fid.volume,
!                          fileLock->scp->fid.vnode,
!                          fileLock->scp->fid.unique);
!                 osi_assert(FALSE);
!             }
! #endif
!             /* Server locks are extended once per scp per refresh
!                cycle. */
!             if (scp->lastRefreshCycle != cm_lockRefreshCycle) {
! 
!                 int scp_done = FALSE;
! 
!                 osi_Log1(afsd_logp, "cm_CheckLocks Updating scp 0x%x", scp);
! 
!                 lock_ReleaseWrite(&cm_scacheLock);
!                 lock_ObtainMutex(&scp->mx);
! 
!                 /* did the lock change while we weren't holding the lock? */
!                 if (!IS_LOCK_ACTIVE(fileLock))
!                     goto post_syncopdone;
! 
!                 code = cm_SyncOp(scp, NULL, fileLock->userp, &req, 0,
!                                  CM_SCACHESYNC_NEEDCALLBACK
!                                  | CM_SCACHESYNC_GETSTATUS
!                                  | CM_SCACHESYNC_LOCK);
! 
!                 if (code) {
!                     osi_Log1(smb_logp, "cm_CheckLocks SyncOp failure code 0x%x", code);
!                     goto post_syncopdone;
!                 }
! 
!                 /* cm_SyncOp releases scp->mx during which the lock
!                    may get released. */
!                 if (!IS_LOCK_ACTIVE(fileLock))
!                     goto pre_syncopdone;
! 
!                 if(scp->serverLock != -1) {
!                     cm_fid_t cfid;
!                     cm_user_t * userp;
! 
!                     tfid.Volume = scp->fid.volume;
!                     tfid.Vnode = scp->fid.vnode;
!                     tfid.Unique = scp->fid.unique;
!                     cfid = scp->fid;
!                     userp = fileLock->userp;
!                     
!                     osi_Log3(afsd_logp, "CALL ExtendLock lock 0x%x for scp=0x%x with lock %d", 
!                              (long) fileLock,
!                              (long) scp,
!                              (int) scp->serverLock);
! 
!                     lock_ReleaseMutex(&scp->mx);
! 
!                     do {
!                         code = cm_Conn(&cfid, userp,
!                                        &req, &connp);
!                         if (code) 
!                             break;
! 
!                         callp = cm_GetRxConn(connp);
!                         code = RXAFS_ExtendLock(callp, &tfid,
!                                                 &volSync);
!                         rx_PutConnection(callp);
! 
!                         osi_Log1(afsd_logp, "   ExtendLock returns %d", code);
! 
!                     } while (cm_Analyze(connp, userp, &req,
!                                         &cfid, &volSync, NULL, NULL,
!                                         code));
! 
!                     code = cm_MapRPCError(code, &req);
! 
!                     lock_ObtainMutex(&scp->mx);
! 
!                     if (code) {
!                         osi_Log1(afsd_logp, "CALL ExtendLock FAILURE, code 0x%x", code);
! 			if (code == EINVAL || code == CM_ERROR_INVAL)
! 			    cm_LockMarkSCacheLost(scp);
!                     } else {
!                         osi_Log0(afsd_logp, "CALL ExtendLock SUCCESS");
!                     }
!                 } else {
!                     /* interestingly, we have found an active lock
!                        belonging to an scache that has no
!                        serverLock */
!                     cm_LockMarkSCacheLost(scp);
!                 }
! 
!                 scp_done = TRUE;
! 
!             pre_syncopdone:
! 
!                 cm_SyncOpDone(scp, NULL, CM_SCACHESYNC_LOCK);
! 
!             post_syncopdone:
!                 lock_ReleaseMutex(&scp->mx);
! 
!                 lock_ObtainWrite(&cm_scacheLock);
! 
!                 if (code == 0) {
!                     fileLock->lastUpdate = time(NULL);
!                 }
!                 
!                 if (scp_done)
!                     scp->lastRefreshCycle = cm_lockRefreshCycle;
! 
!             } else {
!                 /* we have already refreshed the locks on this scp */
!                 fileLock->lastUpdate = time(NULL);
!             }
! 
!             cm_ReleaseSCacheNoLock(scp);
! 
!         } else if (IS_LOCK_ACTIVE(fileLock) && IS_LOCK_CLIENTONLY(fileLock)) {
!             /* TODO: Check callbacks */
!         }
!     }
! 
!     lock_ReleaseWrite(&cm_scacheLock);
!     osi_Log1(afsd_logp, "cm_CheckLocks completes lock check cycle %d", cm_lockRefreshCycle);
! }
! 
! /* NOT called with scp->mx held. */
! long cm_RetryLock(cm_file_lock_t *oldFileLock, int client_is_dead)
! {
!     long code = 0;
!     cm_scache_t *scp;
!     AFSFid tfid;
!     AFSVolSync volSync;
!     cm_conn_t *connp;
!     cm_file_lock_t *fileLock;
!     osi_queue_t *q;
!     cm_req_t req;
!     struct rx_connection * callp;
!     int newLock = -1;
! 
!     cm_InitReq(&req);
! 
!     if (client_is_dead) {
!         code = CM_ERROR_TIMEDOUT;
!         goto handleCode;
!     }
! 
!     lock_ObtainRead(&cm_scacheLock);
! 
!     /* if the lock has already been granted, then we have nothing to do */
!     if(IS_LOCK_ACTIVE(oldFileLock)) {
!         lock_ReleaseRead(&cm_scacheLock);
!         return 0;
!     }
! 
!     /* we can't do anything with lost or deleted locks at the moment. */
!     if(IS_LOCK_LOST(oldFileLock) || IS_LOCK_DELETED(oldFileLock)) {
!         code = CM_ERROR_BADFD;
!         lock_ReleaseRead(&cm_scacheLock);
!         goto handleCode;
!     }
! 
!     scp = oldFileLock->scp;
! 
!     osi_assert(scp != NULL);
! 
!     lock_ReleaseRead(&cm_scacheLock);
!     lock_ObtainMutex(&scp->mx);
!     lock_ObtainWrite(&cm_scacheLock);
! 
!     /* Check if we already have a sufficient server lock to allow this
!        lock to go through */
!     if(IS_LOCK_WAITLOCK(oldFileLock) &&
!        (scp->serverLock == oldFileLock->lockType ||
!         scp->serverLock == LockWrite)) {
! 
!         oldFileLock->flags &= ~CM_FILELOCK_FLAG_WAITLOCK;
! 
!         lock_ReleaseWrite(&cm_scacheLock);
!         lock_ReleaseMutex(&scp->mx);
! 
!         return 0;
!     }
! 
!     if(IS_LOCK_WAITUNLOCK(oldFileLock)) {
! 
!         /* check if the conflicting locks have dissappeared already */
! 
!         for(q = scp->fileLocksH; q; q = osi_QNext(q)) {
! 
!             fileLock = (cm_file_lock_t *)
!                 ((char *) q - offsetof(cm_file_lock_t, fileq));
! 
!             /* a oldFileLock can only depend on locks that are ahead
!                of it in the queue.  If we came this far, then all
!                should be ok */
!             if(fileLock == oldFileLock) {
!                 break;
!             }
! 
!             if(IS_LOCK_LOST(fileLock)
! #if 0
!                && fileLock->key == oldFileLock->key
! #endif
!                ) {
!                 code = CM_ERROR_BADFD;
!                 oldFileLock->flags |= CM_FILELOCK_FLAG_LOST;
!                 break;
!             }
! 
!             /* we don't need to check for deleted locks here since deleted
!                locks are dequeued from fileLocks */
!             if(INTERSECT_RANGE(oldFileLock->range, fileLock->range)) {
! 
!                 if(oldFileLock->lockType != LockRead ||
!                    fileLock->lockType != LockRead) {
!                     code = CM_ERROR_WOULDBLOCK;
!                     break;
!                 }
!             }
!         }
!     }
! 
!     if (code != 0) {
!         lock_ReleaseWrite(&cm_scacheLock);
!         lock_ReleaseMutex(&scp->mx);
! 
!         goto handleCode;
!     }
! 
!     /* when we get here, the lock is either a WAITUNLOCK or WAITLOCK.
!        If it is WAITUNLOCK, then we didn't find any conflicting lock
!        but we haven't verfied whether the serverLock is sufficient to
!        assert it.  If it is WAITLOCK, then the serverLock is
!        insufficient to assert it. Eitherway, we are ready to accept
!        the lock as either ACTIVE or WAITLOCK depending on the
!        serverLock. */
! 
!     /* First, promote the WAITUNLOCK to a WAITLOCK */
!     if (IS_LOCK_WAITUNLOCK(oldFileLock)) {
!         if (oldFileLock->lockType == LockRead)
!             scp->sharedLocks++;
!         else
!             scp->exclusiveLocks++;
! 
!         oldFileLock->flags &= ~CM_FILELOCK_FLAG_WAITUNLOCK;
!         oldFileLock->flags |= CM_FILELOCK_FLAG_WAITLOCK;
!     }
! 
!     if (scp->serverLock == oldFileLock->lockType ||
!         (oldFileLock->lockType == LockRead && scp->serverLock == LockWrite) ||
!         (scp->flags & CM_SCACHEFLAG_RO)) {
! 
!         oldFileLock->flags &= ~CM_FILELOCK_FLAG_WAITLOCK;
! 
!         lock_ReleaseWrite(&cm_scacheLock);
!         lock_ReleaseMutex(&scp->mx);
! 
!         return 0;
! 
!     } else {
!         cm_fid_t cfid;
!         cm_user_t * userp;
! 
!         code = cm_SyncOp(scp, NULL, oldFileLock->userp, &req, 0,
!                          CM_SCACHESYNC_NEEDCALLBACK
! 			 | CM_SCACHESYNC_GETSTATUS
! 			 | CM_SCACHESYNC_LOCK);
!         if (code) {
!             osi_Log1(smb_logp, "cm_RetryLock SyncOp failure code 0x%x", code);
!             lock_ReleaseWrite(&cm_scacheLock);
!             goto post_syncopdone;
!         }
! 
!         if(!IS_LOCK_WAITLOCK(oldFileLock))
!             goto pre_syncopdone;
! 
!         tfid.Volume = scp->fid.volume;
!         tfid.Vnode = scp->fid.vnode;
!         tfid.Unique = scp->fid.unique;
!         cfid = scp->fid;
!         userp = oldFileLock->userp;
! 
! #ifndef AGGRESSIVE_LOCKS
!         newLock = oldFileLock->lockType;
! #else
!         newLock = LockWrite;
! #endif
! 
!         osi_Log1(afsd_logp, "CALL SetLock lock 0x%x", (long) oldFileLock);
! 
!         lock_ReleaseWrite(&cm_scacheLock);
!         lock_ReleaseMutex(&scp->mx);
! 
!         do {
!             code = cm_Conn(&cfid, userp, &req, &connp);
!             if (code) 
!                 break;
! 
!             callp = cm_GetRxConn(connp);
!             code = RXAFS_SetLock(callp, &tfid, newLock,
!                                   &volSync);
!             rx_PutConnection(callp);
! 
!         } while (cm_Analyze(connp, userp, &req,
!                              &cfid, &volSync,
!                              NULL, NULL, code));
!         code = cm_MapRPCError(code, &req);
! 
!         if (code) {
!             osi_Log1(afsd_logp, "CALL SetLock FAILURE, code 0x%x", code);
!         } else {
!             osi_Log0(afsd_logp, "CALL SetLock SUCCESS");
!         }
! 
!         lock_ObtainMutex(&scp->mx);
!     pre_syncopdone:
!         cm_SyncOpDone(scp, NULL, CM_SCACHESYNC_LOCK);
!     post_syncopdone:
!         ;
!     }
! 
!   handleCode:
!     if (code != 0 && code != CM_ERROR_WOULDBLOCK) {
!         if (scp->fileLocksT == &oldFileLock->fileq)
!             scp->fileLocksT = osi_QPrev(&oldFileLock->fileq);
!         osi_QRemove(&scp->fileLocksH, &oldFileLock->fileq);
!     } else if (code == 0 && IS_LOCK_WAITLOCK(oldFileLock)) {
!         scp->serverLock = newLock;
!     }
!     lock_ReleaseMutex(&scp->mx);
! 
!     lock_ObtainWrite(&cm_scacheLock);
!     if (code == 0) {
!         oldFileLock->flags &= ~CM_FILELOCK_FLAG_WAITLOCK;
!     } else if (code != CM_ERROR_WOULDBLOCK) {
!         oldFileLock->flags |= CM_FILELOCK_FLAG_DELETED;
          cm_ReleaseUser(oldFileLock->userp);
          oldFileLock->userp = NULL;
+         cm_ReleaseSCacheNoLock(scp);
+         oldFileLock->scp = NULL;
      }
      lock_ReleaseWrite(&cm_scacheLock);
  
      return code;
  }
+ 
+ cm_key_t cm_GenerateKey(unsigned int session_id, unsigned long process_id, unsigned int file_id)
+ {
+     return (((cm_key_t) process_id) << 32) |
+         (((cm_key_t) session_id) << 16) |
+         (((cm_key_t) file_id));
+ }
+ 
+ static int cm_KeyEquals(cm_key_t k1, cm_key_t k2, int flags)
+ {
+     if (flags & CM_UNLOCK_BY_FID) {
+         return ((k1 & 0xffffffff) == (k2 & 0xffffffff));
+     } else {
+         return (k1 == k2);
+     }
+ }
Index: openafs/src/WINNT/afsd/cm_vnodeops.h
diff -c openafs/src/WINNT/afsd/cm_vnodeops.h:1.5.2.5 openafs/src/WINNT/afsd/cm_vnodeops.h:1.5.2.6
*** openafs/src/WINNT/afsd/cm_vnodeops.h:1.5.2.5	Fri Mar 11 01:58:43 2005
--- openafs/src/WINNT/afsd/cm_vnodeops.h	Wed Oct  5 01:12:27 2005
***************
*** 145,162 ****
  extern long cm_EvaluateSymLink(cm_scache_t *dscp, cm_scache_t *linkScp,
  	cm_scache_t **outScpp, cm_user_t *userp, cm_req_t *reqp);
  
! extern long cm_Lock(cm_scache_t *scp, unsigned char LockType,
! 	LARGE_INTEGER LOffset, LARGE_INTEGER LLength,
! 	u_long Timeout, cm_user_t *userp, cm_req_t *reqp,
! 	void **lockpp);
  
! extern long cm_Unlock(cm_scache_t *scp, unsigned char LockType,
! 	LARGE_INTEGER LOffset, LARGE_INTEGER LLength,
  	cm_user_t *userp, cm_req_t *reqp);
  
  extern void cm_CheckLocks();
  
! extern long cm_RetryLock(cm_file_lock_t *oldFileLock, int vcp_is_dead);
  
  #define MAX_SYMLINK_COUNT 16
  #endif /*  __CM_VNODEOPS_H_ENV__ */
--- 145,187 ----
  extern long cm_EvaluateSymLink(cm_scache_t *dscp, cm_scache_t *linkScp,
  	cm_scache_t **outScpp, cm_user_t *userp, cm_req_t *reqp);
  
! extern long cm_Lock(cm_scache_t *scp, unsigned char sLockType,
!         LARGE_INTEGER LOffset, LARGE_INTEGER LLength, cm_key_t key,
! 	int allowWait, cm_user_t *userp, cm_req_t *reqp,
! 	cm_file_lock_t **lockpp);
  
! #define CM_UNLOCK_BY_FID 1
! 
! extern long cm_UnlockByKey(cm_scache_t * scp,
!         cm_key_t key,
!         int flags,
!         cm_user_t * userp,
!         cm_req_t * reqp);
! 
! extern long cm_Unlock(cm_scache_t *scp, unsigned char sLockType,
!         LARGE_INTEGER LOffset, LARGE_INTEGER LLength, cm_key_t key,
  	cm_user_t *userp, cm_req_t *reqp);
  
+ extern long cm_LockCheckRead(cm_scache_t *scp, 
+         LARGE_INTEGER LOffset, 
+         LARGE_INTEGER LLength, 
+         cm_key_t key);
+ 
+ extern long cm_LockCheckWrite(cm_scache_t *scp,
+         LARGE_INTEGER LOffset,
+         LARGE_INTEGER LLength,
+         cm_key_t key);
+ 
  extern void cm_CheckLocks();
  
! extern long cm_RetryLock(cm_file_lock_t *oldFileLock, int client_is_dead);
! 
! #define CM_SESSION_SMB      0xffff
! #define CM_SESSION_IFS      0xfffe
! #define CM_SESSION_CMINT    0xfffd
! #define CM_SESSION_RESERVED 0xfff0
! 
! extern cm_key_t cm_GenerateKey(unsigned int session, unsigned long process_id, unsigned int file_id);
  
  #define MAX_SYMLINK_COUNT 16
  #endif /*  __CM_VNODEOPS_H_ENV__ */
Index: openafs/src/WINNT/afsd/smb.c
diff -c openafs/src/WINNT/afsd/smb.c:1.55.2.27.2.2 openafs/src/WINNT/afsd/smb.c:1.55.2.31
*** openafs/src/WINNT/afsd/smb.c:1.55.2.27.2.2	Wed Oct 19 03:00:23 2005
--- openafs/src/WINNT/afsd/smb.c	Wed Oct 19 02:58:46 2005
***************
*** 175,181 ****
  
  smb_username_t *usernamesp = NULL;
  
! smb_waitingLock_t *smb_allWaitingLocks;
  
  /* forward decl */
  void smb_DispatchPacket(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp,
--- 175,181 ----
  
  smb_username_t *usernamesp = NULL;
  
! smb_waitingLockRequest_t *smb_allWaitingLocks;
  
  /* forward decl */
  void smb_DispatchPacket(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp,
***************
*** 860,865 ****
--- 860,870 ----
          }
          else
              memset(vcp->encKey, 0, MSV1_0_CHALLENGE_LENGTH);
+ 
+         if (numVCs >= CM_SESSION_RESERVED) {
+             numVCs = 0;
+             osi_Log0(smb_logp, "WARNING: numVCs wrapping around");
+         }
      }
      lock_ReleaseWrite(&smb_rctLock);
      return vcp;
***************
*** 1141,1147 ****
      return 1;
  }
  
! /* find a file ID.  If we pass in 0 we select an used File ID.
   * If the SMB_FLAG_CREATE flag is set, we allocate a new  
   * smb_fid_t data structure if desired File ID cannot be found.
   */
--- 1146,1152 ----
      return 1;
  }
  
! /* find a file ID.  If we pass in 0 we select an unused File ID.
   * If the SMB_FLAG_CREATE flag is set, we allocate a new  
   * smb_fid_t data structure if desired File ID cannot be found.
   */
***************
*** 1173,1178 ****
--- 1178,1184 ----
              break;
          }
      }
+ 
      if (!fidp && (flags & SMB_FLAG_CREATE)) {
          char eventName[MAX_PATH];
          EVENT_HANDLE event;
***************
*** 1203,1208 ****
--- 1209,1215 ----
                  vcp->fidCounter = 1;
          }
      }
+ 
      lock_ReleaseWrite(&smb_rctLock);
      return fidp;
  }
***************
*** 2327,2333 ****
      }
      else if (code == CM_ERROR_READONLY) {
          NTStatus = 0xC00000A2L;	/* Write protected */
!     }	
      else if (code == CM_ERROR_NOSUCHFILE) {
          NTStatus = 0xC000000FL;	/* No such file */
      }
--- 2334,2340 ----
      }
      else if (code == CM_ERROR_READONLY) {
          NTStatus = 0xC00000A2L;	/* Write protected */
!     }
      else if (code == CM_ERROR_NOSUCHFILE) {
          NTStatus = 0xC000000FL;	/* No such file */
      }
***************
*** 2407,2412 ****
--- 2414,2425 ----
      else if (code == CM_ERROR_WOULDBLOCK) {
          NTStatus = 0xC0000055L;	/* Lock not granted */
      }
+     else if (code == CM_ERROR_SHARING_VIOLATION) {
+         NTStatus = 0xC0000043L; /* Sharing violation */
+     }
+     else if (code == CM_ERROR_LOCK_CONFLICT) {
+         NTStatus = 0xC0000054L; /* Lock conflict */
+     }
      else if (code == CM_ERROR_PARTIALWRITE) {
          NTStatus = 0xC000007FL;	/* Disk full */
      }
***************
*** 2597,2602 ****
--- 2610,2623 ----
          class = 1;
          error = 33;	/* lock conflict */
      }
+     else if (code == CM_ERROR_LOCK_CONFLICT) {
+         class = 1;
+         error = 33;     /* lock conflict */
+     }
+     else if (code == CM_ERROR_SHARING_VIOLATION) {
+         class = 1;
+         error = 33;     /* lock conflict */
+     }
      else if (code == CM_ERROR_NOFILES) {
          class = 1;
          error = 18;	/* no files in search */
***************
*** 2655,2660 ****
--- 2676,2682 ----
      osi_hyper_t offset;
      long count, minCount, finalCount;
      unsigned short fd;
+     unsigned pid;
      smb_fid_t *fidp;
      long code = 0;
      cm_user_t *userp = NULL;
***************
*** 2683,2688 ****
--- 2705,2730 ----
      if (!fidp)
          goto send1;
  
+     pid = ((smb_t *) inp)->pid;
+     {
+         LARGE_INTEGER LOffset, LLength;
+         cm_key_t key;
+ 
+         key = cm_GenerateKey(vcp->vcID, pid, fd);
+ 
+         LOffset.HighPart = 0;
+         LOffset.LowPart = offset.LowPart;
+         LLength.HighPart = 0;
+         LLength.LowPart = count;
+ 
+         lock_ObtainMutex(&fidp->scp->mx);
+         code = cm_LockCheckRead(fidp->scp, LOffset, LLength, key);
+         lock_ReleaseMutex(&fidp->scp->mx);
+     }    
+     if (code) {
+         goto send1a;
+     }
+ 
      lock_ObtainMutex(&smb_RawBufLock);
      if (smb_RawBufs) {
          /* Get a raw buf, from head of list */
***************
*** 3060,3066 ****
  
  void smb_WaitingLocksDaemon()
  {
!     smb_waitingLock_t *wL, *nwL;
      int first;
      smb_vc_t *vcp;
      smb_packet_t *inp, *outp;
--- 3102,3109 ----
  
  void smb_WaitingLocksDaemon()
  {
!     smb_waitingLockRequest_t *wlRequest, *nwlRequest;
!     smb_waitingLock_t *wl, *wlNext;
      int first;
      smb_vc_t *vcp;
      smb_packet_t *inp, *outp;
***************
*** 3069,3076 ****
  
      while (smbShutdownFlag == 0) {
          lock_ObtainWrite(&smb_globalLock);
!         nwL = smb_allWaitingLocks;
!         if (nwL == NULL) {
              osi_SleepW((long)&smb_allWaitingLocks, &smb_globalLock);
              thrd_Sleep(1000);
              continue;
--- 3112,3119 ----
  
      while (smbShutdownFlag == 0) {
          lock_ObtainWrite(&smb_globalLock);
!         nwlRequest = smb_allWaitingLocks;
!         if (nwlRequest == NULL) {
              osi_SleepW((long)&smb_allWaitingLocks, &smb_globalLock);
              thrd_Sleep(1000);
              continue;
***************
*** 3082,3104 ****
                  first = 0;
              else
                  lock_ObtainWrite(&smb_globalLock);
!             wL = nwL;
!             nwL = (smb_waitingLock_t *) osi_QNext(&wL->q);
              lock_ReleaseWrite(&smb_globalLock);
!             code = cm_RetryLock((cm_file_lock_t *) wL->lockp,
!                                  wL->vcp->flags & SMB_VCFLAG_ALREADYDEAD);
              if (code == CM_ERROR_WOULDBLOCK) {
                  /* no progress */
!                 if (wL->timeRemaining != 0xffffffff
!                      && (wL->timeRemaining -= 1000) < 0)
                      goto endWait;
                  continue;
              }
  
            endWait:
!             vcp = wL->vcp;
!             inp = wL->inp;
!             outp = wL->outp;
              ncbp = GetNCB();
              ncbp->ncb_length = inp->ncb_length;
              inp->spacep = cm_GetSpace();
--- 3125,3200 ----
                  first = 0;
              else
                  lock_ObtainWrite(&smb_globalLock);
! 
!             wlRequest = nwlRequest;
!             nwlRequest = (smb_waitingLockRequest_t *) osi_QNext(&wlRequest->q);
              lock_ReleaseWrite(&smb_globalLock);
! 
!             code = 0;
! 
!             for (wl = wlRequest->locks; wl; wl = (smb_waitingLock_t *) osi_QNext(&wl->q)) {
!                 if (wl->state == SMB_WAITINGLOCKSTATE_DONE)
!                     continue;
!                 
!                 /* wl->state is either _DONE or _WAITING.  _ERROR
!                    would no longer be on the queue. */
!                 code = cm_RetryLock( wl->lockp,
!                                      !!(wlRequest->vcp->flags & SMB_VCFLAG_ALREADYDEAD) );
! 
!                 if (code == 0) {
!                     wl->state = SMB_WAITINGLOCKSTATE_DONE;
!                 } else if (code != CM_ERROR_WOULDBLOCK) {
!                     wl->state = SMB_WAITINGLOCKSTATE_ERROR;
!                     break;
!                 }
!             }
! 
              if (code == CM_ERROR_WOULDBLOCK) {
+ 
                  /* no progress */
!                 if (wlRequest->timeRemaining != 0xffffffff
!                      && (wlRequest->timeRemaining -= 1000) < 0)
                      goto endWait;
+ 
                  continue;
              }
  
            endWait:
! 
!             if (code != 0) {
!                 cm_scache_t * scp;
!                 cm_req_t req;
! 
!                 scp = wlRequest->scp;
! 
!                 cm_InitReq(&req);
! 
!                 lock_ObtainMutex(&scp->mx);
! 
!                 for (wl = wlRequest->locks; wl; wl = wlNext) {
!                     wlNext = (smb_waitingLock_t *) osi_QNext(&wl->q);
!                     
!                     cm_Unlock(scp, wlRequest->lockType, wl->LOffset, 
!                               wl->LLength, wl->key, NULL, &req);
! 
!                     osi_QRemove((osi_queue_t **) &wlRequest->locks, &wl->q);
! 
!                     free(wl);
!                 }
!                 
!                 lock_ReleaseMutex(&scp->mx);
! 
!             } else {
!                 for (wl = wlRequest->locks; wl; wl = wlNext) {
!                     wlNext = (smb_waitingLock_t *) osi_QNext(&wl->q);
!                     osi_QRemove((osi_queue_t **) &wlRequest->locks, &wl->q);
!                     free(wl);
!                 }
!             }
! 
!             vcp = wlRequest->vcp;
!             inp = wlRequest->inp;
!             outp = wlRequest->outp;
              ncbp = GetNCB();
              ncbp->ncb_length = inp->ncb_length;
              inp->spacep = cm_GetSpace();
***************
*** 3106,3112 ****
              /* Remove waitingLock from list */
              lock_ObtainWrite(&smb_globalLock);
              osi_QRemove((osi_queue_t **)&smb_allWaitingLocks,
!                          &wL->q);
              lock_ReleaseWrite(&smb_globalLock);
  
              /* Resume packet processing */
--- 3202,3208 ----
              /* Remove waitingLock from list */
              lock_ObtainWrite(&smb_globalLock);
              osi_QRemove((osi_queue_t **)&smb_allWaitingLocks,
!                          &wlRequest->q);
              lock_ReleaseWrite(&smb_globalLock);
  
              /* Resume packet processing */
***************
*** 3122,3130 ****
              smb_FreePacket(inp);
              smb_FreePacket(outp);
              smb_ReleaseVC(vcp);
              FreeNCB(ncbp);
!             free(wL);
!         } while (nwL && smbShutdownFlag == 0);
          thrd_Sleep(1000);
      }
  }
--- 3218,3227 ----
              smb_FreePacket(inp);
              smb_FreePacket(outp);
              smb_ReleaseVC(vcp);
+             cm_ReleaseSCache(wlRequest->scp);
              FreeNCB(ncbp);
!             free(wlRequest);
!         } while (nwlRequest && smbShutdownFlag == 0);
          thrd_Sleep(1000);
      }
  }
***************
*** 4745,4761 ****
      spacep = inp->spacep;
      smb_StripLastComponent(spacep->data, &oldLastNamep, oldPathp);
  
-     /*
-      * Changed to use CASEFOLD always.  This enables us to rename Foo/baz when
-      * what actually exists is foo/baz.  I don't know why the code used to be
-      * the way it was.  1/29/96
-      *
-      *     	caseFold = ((vcp->flags & SMB_VCFLAG_USEV3) ? 0: CM_FLAG_CASEFOLD);
-      *
-      * Changed to use CM_FLAG_FOLLOW.  7/24/96
-      *
-      *	caseFold = CM_FLAG_CASEFOLD;
-      */
      caseFold = CM_FLAG_FOLLOW | CM_FLAG_CASEFOLD;
      code = cm_NameI(cm_data.rootSCachep, spacep->data, caseFold,
                      userp, tidPathp, &req, &oldDscp);
--- 4842,4847 ----
***************
*** 4868,4873 ****
--- 4954,4960 ----
      thyper.HighPart = 0;
  
      code = cm_ApplyDir(oldDscp, smb_RenameProc, &rock, &thyper, userp, &req, NULL);
+     osi_Log1(smb_logp, "smb_RenameProc returns %ld", code);
  
      if (code == CM_ERROR_STOPNOW)
          code = 0;
***************
*** 5348,5353 ****
--- 5435,5474 ----
      else 
          code = 0;
  
+     /* unlock any pending locks */
+     if (!(fidp->flags & SMB_FID_IOCTL) && fidp->scp &&
+         fidp->scp->fileType == CM_SCACHETYPE_FILE) {
+         cm_key_t key;
+         unsigned pid;
+         cm_scache_t * scp;
+         long tcode;
+ 
+         pid = ((smb_t *) inp)->pid;
+         key = cm_GenerateKey(vcp->vcID, pid, fid);
+         scp = fidp->scp;
+         cm_HoldSCache(scp);
+         lock_ObtainMutex(&scp->mx);
+ 
+         tcode = cm_SyncOp(scp, NULL, userp, &req, 0,
+                           CM_SCACHESYNC_NEEDCALLBACK
+                           | CM_SCACHESYNC_GETSTATUS
+                           | CM_SCACHESYNC_LOCK);
+ 
+         if (tcode) {
+             osi_Log1(smb_logp, "smb CoreClose SyncOp failure code 0x%x", tcode);
+             goto post_syncopdone;
+         }
+ 
+         cm_UnlockByKey(scp, key, CM_UNLOCK_BY_FID, userp, &req);
+ 
+         cm_SyncOpDone(scp, NULL, CM_SCACHESYNC_LOCK);
+ 
+     post_syncopdone:
+ 
+         lock_ReleaseMutex(&scp->mx);
+         cm_ReleaseSCache(scp);
+     }
+ 
      if (fidp->flags & SMB_FID_DELONCLOSE) {
          cm_scache_t *dscp = fidp->NTopen_dscp;
          char *pathp = fidp->NTopen_pathp;
***************
*** 5426,5432 ****
          }
          if (fidp->curr_chunk == fidp->prev_chunk + 1)
              sequential = 1;
!     }       
  
      /* start by looking up the file's end */
      code = cm_SyncOp(scp, NULL, userp, &req, 0,
--- 5547,5553 ----
          }
          if (fidp->curr_chunk == fidp->prev_chunk + 1)
              sequential = 1;
!     }
  
      /* start by looking up the file's end */
      code = cm_SyncOp(scp, NULL, userp, &req, 0,
***************
*** 5792,5797 ****
--- 5913,5919 ----
      osi_hyper_t offset;
      long count, written = 0, total_written = 0;
      unsigned short fd;
+     unsigned pid;
      smb_fid_t *fidp;
      long code = 0;
      cm_user_t *userp;
***************
*** 5821,5827 ****
          
      userp = smb_GetUser(vcp, inp);
  
! 	/* special case: 0 bytes transferred means truncate to this position */
      if (count == 0) {
          cm_req_t req;
  
--- 5943,5949 ----
          
      userp = smb_GetUser(vcp, inp);
  
!     /* special case: 0 bytes transferred means truncate to this position */
      if (count == 0) {
          cm_req_t req;
  
***************
*** 5839,5844 ****
--- 5961,5987 ----
          goto done;
      }
  
+     {
+         cm_key_t key;
+         LARGE_INTEGER LOffset;
+         LARGE_INTEGER LLength;
+ 
+         pid = ((smb_t *) inp)->pid;
+         key = cm_GenerateKey(vcp->vcID, pid, fd);
+ 
+         LOffset.HighPart = offset.HighPart;
+         LOffset.LowPart = offset.LowPart;
+         LLength.HighPart = 0;
+         LLength.LowPart = count;
+ 
+         lock_ObtainMutex(&fidp->scp->mx);
+         code = cm_LockCheckWrite(fidp->scp, LOffset, LLength, key);
+         lock_ReleaseMutex(&fidp->scp->mx);
+ 
+         if (code)
+             goto done;
+     }
+ 
      /*
       * Work around bug in NT client
       *
***************
*** 5990,5995 ****
--- 6133,6162 ----
      if (!fidp) {
          return CM_ERROR_BADFD;
      }
+ 
+     {
+         unsigned pid;
+         cm_key_t key;
+         LARGE_INTEGER LOffset;
+         LARGE_INTEGER LLength;
+ 
+         pid = ((smb_t *) inp)->pid;
+         key = cm_GenerateKey(vcp->vcID, pid, fd);
+ 
+         LOffset.HighPart = offset.HighPart;
+         LOffset.LowPart = offset.LowPart;
+         LLength.HighPart = 0;
+         LLength.LowPart = count;
+ 
+         lock_ObtainMutex(&fidp->scp->mx);
+         code = cm_LockCheckWrite(fidp->scp, LOffset, LLength, key);
+         lock_ReleaseMutex(&fidp->scp->mx);
+ 
+         if (code) {
+             smb_ReleaseFID(fidp);
+             return code;
+         }
+     }
          
      userp = smb_GetUser(vcp, inp);
  
***************
*** 6084,6089 ****
--- 6251,6257 ----
      osi_hyper_t offset;
      long count, finalCount;
      unsigned short fd;
+     unsigned pid;
      smb_fid_t *fidp;
      long code = 0;
      cm_user_t *userp;
***************
*** 6106,6111 ****
--- 6274,6300 ----
      if (fidp->flags & SMB_FID_IOCTL) {
          return smb_IoctlRead(fidp, vcp, inp, outp);
      }
+ 
+     {
+         LARGE_INTEGER LOffset, LLength;
+         cm_key_t key;
+ 
+         pid = ((smb_t *) inp)->pid;
+         key = cm_GenerateKey(vcp->vcID, pid, fd);
+ 
+         LOffset.HighPart = 0;
+         LOffset.LowPart = offset.LowPart;
+         LLength.HighPart = 0;
+         LLength.LowPart = count;
+         
+         lock_ObtainMutex(&fidp->scp->mx);
+         code = cm_LockCheckRead(fidp->scp, LOffset, LLength, key);
+         lock_ReleaseMutex(&fidp->scp->mx);
+     }
+     if (code) {
+         smb_ReleaseFID(fidp);
+         return code;
+     }
          
      userp = smb_GetUser(vcp, inp);
  
Index: openafs/src/WINNT/afsd/smb.h
diff -c openafs/src/WINNT/afsd/smb.h:1.14.2.12 openafs/src/WINNT/afsd/smb.h:1.14.2.13
*** openafs/src/WINNT/afsd/smb.h:1.14.2.12	Tue Apr 19 01:11:18 2005
--- openafs/src/WINNT/afsd/smb.h	Wed Oct  5 01:12:28 2005
***************
*** 346,351 ****
--- 346,359 ----
  #define SMB_FID_LOOKSLIKECOPY	(SMB_FID_LENGTHSETDONE | SMB_FID_MTIMESETDONE)
  #define SMB_FID_NTOPEN			0x100	/* have dscp and pathp */
  
+ #define SMB_FID_SHARE_READ              0x1000
+ #define SMB_FID_SHARE_WRITE             0x2000
+ 
+ #define SMB_FID_QLOCK_HIGH              0x0fe00000
+ #define SMB_FID_QLOCK_LOW               0x00000000
+ #define SMB_FID_QLOCK_LENGTH            1
+ #define SMB_FID_QLOCK_PID               0
+ 
  /*
   * SMB file attributes (32-bit)
   */
***************
*** 406,422 ****
   * Note: will not be set if smb_hideDotFiles is false 
   */
  
! /* waiting lock list elements */
  typedef struct smb_waitingLock {
!     osi_queue_t q;
!     smb_vc_t *vcp;
      smb_packet_t *inp;
      smb_packet_t *outp;
!     time_t timeRemaining;
!     void *lockp;
! } smb_waitingLock_t;
  
! extern smb_waitingLock_t *smb_allWaitingLocks;
  
  typedef long (smb_proc_t)(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
  
--- 414,446 ----
   * Note: will not be set if smb_hideDotFiles is false 
   */
  
! /* individual lock on a waiting lock request */
  typedef struct smb_waitingLock {
!     osi_queue_t      q;
!     cm_key_t         key;
!     LARGE_INTEGER    LOffset;
!     LARGE_INTEGER    LLength;
!     cm_file_lock_t * lockp;
!     int              state;
! } smb_waitingLock_t;
! 
! #define SMB_WAITINGLOCKSTATE_WAITING 0
! #define SMB_WAITINGLOCKSTATE_DONE    1
! #define SMB_WAITINGLOCKSTATE_ERROR   2
! 
! /* waiting lock request */
! typedef struct smb_waitingLockRequest {
!     osi_queue_t   q;
!     smb_vc_t *    vcp;
!     cm_scache_t * scp;
      smb_packet_t *inp;
      smb_packet_t *outp;
!     int           lockType;
!     time_t        timeRemaining;
!     smb_waitingLock_t * locks;
! } smb_waitingLockRequest_t;
  
! extern smb_waitingLockRequest_t *smb_allWaitingLocks;
  
  typedef long (smb_proc_t)(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
  
Index: openafs/src/WINNT/afsd/smb3.c
diff -c openafs/src/WINNT/afsd/smb3.c:1.42.2.28.2.1 openafs/src/WINNT/afsd/smb3.c:1.42.2.31
*** openafs/src/WINNT/afsd/smb3.c:1.42.2.28.2.1	Fri Oct 14 07:24:26 2005
--- openafs/src/WINNT/afsd/smb3.c	Fri Oct 14 07:19:55 2005
***************
*** 121,127 ****
      return inp;
  }   
  
- /*DEBUG do not checkin*/
  void OutputDebugF(char * format, ...) {
      va_list args;
      int len;
--- 121,126 ----
***************
*** 174,182 ****
          OutputDebugString(buf);
      }   
  }
- /**/
  
  #define SMB_EXT_SEC_PACKAGE_NAME "Negotiate"
  void smb_NegotiateExtendedSecurity(void ** secBlob, int * secBlobLength) {
      SECURITY_STATUS status, istatus;
      CredHandle creds = {0,0};
--- 173,181 ----
          OutputDebugString(buf);
      }   
  }
  
  #define SMB_EXT_SEC_PACKAGE_NAME "Negotiate"
+ 
  void smb_NegotiateExtendedSecurity(void ** secBlob, int * secBlobLength) {
      SECURITY_STATUS status, istatus;
      CredHandle creds = {0,0};
***************
*** 201,207 ****
                                         &creds,
                                         &expiry);
  
!     if (status != SEC_E_OK) {       
          /* Really bad. We return an empty security blob */
          OutputDebugF("AcquireCredentialsHandle failed with %lX", status);
          goto nes_0;
--- 200,206 ----
                                         &creds,
                                         &expiry);
  
!     if (status != SEC_E_OK) {
          /* Really bad. We return an empty security blob */
          OutputDebugF("AcquireCredentialsHandle failed with %lX", status);
          goto nes_0;
***************
*** 649,659 ****
      return 0;
  }
  
! /* When using SMB auth, all SMB sessions have to pass through here first to
!  * authenticate the user. 
!  * Caveat: If not use the SMB auth the protocol does not require sending a
!  * session setup packet, which means that we can't rely on a UID in subsequent
!  * packets.  Though in practice we get one anyway.
   */
  long smb_ReceiveV3SessionSetupX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
  {
--- 648,659 ----
      return 0;
  }
  
! /* When using SMB auth, all SMB sessions have to pass through here
!  * first to authenticate the user.  
!  *
!  * Caveat: If not using SMB auth, the protocol does not require
!  * sending a session setup packet, which means that we can't rely on a
!  * UID in subsequent packets.  Though in practice we get one anyway.
   */
  long smb_ReceiveV3SessionSetupX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
  {
***************
*** 3185,3191 ****
      char requestFileName[1024] = "";
      smb_tran2Packet_t *outp = 0;
      cm_user_t *userp = 0;
-     cm_scache_t *scp;
      cm_req_t req;
      CPINFO CodePageInfo;
      int i, nbnLen, reqLen;
--- 3185,3190 ----
***************
*** 4515,4531 ****
  
      scp = NULL;
          
!     extraInfo = (smb_GetSMBParm(inp, 2) & 1);	/* return extra info */
!     openFun = smb_GetSMBParm(inp, 8);	/* open function */
      excl = ((openFun & 3) == 0);
!     trunc = ((openFun & 3) == 2);		/* truncate it */
      openMode = (smb_GetSMBParm(inp, 3) & 0x7);
!     openAction = 0;			/* tracks what we did */
  
      attributes = smb_GetSMBParm(inp, 5);
      dosTime = smb_GetSMBParm(inp, 6) | (smb_GetSMBParm(inp, 7) << 16);
  
! 	/* compute initial mode bits based on read-only flag in attributes */
      initialModeBits = 0666;
      if (attributes & 1) initialModeBits &= ~0222;
          
--- 4514,4530 ----
  
      scp = NULL;
          
!     extraInfo = (smb_GetSMBParm(inp, 2) & 1); /* return extra info */
!     openFun = smb_GetSMBParm(inp, 8); /* open function */
      excl = ((openFun & 3) == 0);
!     trunc = ((openFun & 3) == 2); /* truncate it */
      openMode = (smb_GetSMBParm(inp, 3) & 0x7);
!     openAction = 0;             /* tracks what we did */
  
      attributes = smb_GetSMBParm(inp, 5);
      dosTime = smb_GetSMBParm(inp, 6) | (smb_GetSMBParm(inp, 7) << 16);
  
!                                 /* compute initial mode bits based on read-only flag in attributes */
      initialModeBits = 0666;
      if (attributes & 1) initialModeBits &= ~0222;
          
***************
*** 4786,4800 ****
      return 0;
  }       
  
! /* The file locking code is incomplete and that which is implemented in cm_Lock()
!  * is broken.  What exists functions only because it is rarely if ever called.
!  * The tests activated by FULL_LOCKS_ONLY ensure that cm_Lock() is only called
!  * if the lock covers the entire file.  Therefore, RXAFS_SetLock is only called 
!  * rarely.   That means that AFS locks are ignored by Windows clients.
!  * When cm_Lock is re-written, undefine or better yet remove, the FULL_LOCKS_ONLY
!  * code.
!  */
! #define FULL_LOCKS_ONLY
  long smb_ReceiveV3LockingX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
  {
      cm_req_t req;
--- 4785,4816 ----
      return 0;
  }       
  
! static void smb_GetLockParams(unsigned char LockType, 
!                               char ** buf, 
!                               unsigned int * ppid, 
!                               LARGE_INTEGER * pOffset, 
!                               LARGE_INTEGER * pLength)
! {
!     if (LockType & LOCKING_ANDX_LARGE_FILES) {
!         /* Large Files */
!         *ppid = *((USHORT *) *buf);
!         pOffset->HighPart = *((LONG *)(*buf + 4));
!         pOffset->LowPart = *((DWORD *)(*buf + 8));
!         pLength->HighPart = *((LONG *)(*buf + 12));
!         pLength->LowPart = *((DWORD *)(*buf + 16));
!         *buf += 20;
!     }
!     else {
!         /* Not Large Files */
!         *ppid = *((USHORT *) *buf);
!         pOffset->HighPart = 0;
!         pOffset->LowPart = *((DWORD *)(*buf + 2));
!         pLength->HighPart = 0;
!         pLength->LowPart = *((DWORD *)(*buf + 6));
!         *buf += 10;
!     }
! }
! 
  long smb_ReceiveV3LockingX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
  {
      cm_req_t req;
***************
*** 4804,4816 ****
      cm_scache_t *scp;
      unsigned char LockType;
      unsigned short NumberOfUnlocks, NumberOfLocks;
!     unsigned long Timeout;
      char *op;
      LARGE_INTEGER LOffset, LLength;
!     smb_waitingLock_t *waitingLock;
!     void *lockp;
      long code = 0;
      int i;
  
      cm_InitReq(&req);
  
--- 4820,4835 ----
      cm_scache_t *scp;
      unsigned char LockType;
      unsigned short NumberOfUnlocks, NumberOfLocks;
!     long Timeout;
      char *op;
+     char *op_locks;
      LARGE_INTEGER LOffset, LLength;
!     smb_waitingLockRequest_t *wlRequest = NULL;
!     cm_file_lock_t *lockp;
      long code = 0;
      int i;
+     cm_key_t key;
+     unsigned int pid;
  
      cm_InitReq(&req);
  
***************
*** 4844,4946 ****
      NumberOfUnlocks = smb_GetSMBParm(inp, 6);
      NumberOfLocks = smb_GetSMBParm(inp, 7);
  
      op = smb_GetSMBData(inp, NULL);
  
      for (i=0; i<NumberOfUnlocks; i++) {
!         if (LockType & LOCKING_ANDX_LARGE_FILES) {
!             /* Large Files */
!             LOffset.HighPart = *((LONG *)(op + 4));
!             LOffset.LowPart = *((DWORD *)(op + 8));
!             LLength.HighPart = *((LONG *)(op + 12));
!             LLength.LowPart = *((DWORD *)(op + 16));
!             op += 20;
!         }
!         else {
!             /* Not Large Files */
!             LOffset.HighPart = 0;
!             LOffset.LowPart = *((DWORD *)(op + 2));
!             LLength.HighPart = 0;
!             LLength.LowPart = *((DWORD *)(op + 6));
!             op += 10;
!         }
! #ifdef FULL_LOCKS_ONLY
!         if (LargeIntegerNotEqualToZero(LOffset)) {
!             osi_Log2(smb_logp, "smb_ReceiveV3Locking Unlock %d offset 0x%x != Zero",
!                      i, (long)LOffset.QuadPart);
!             continue;
!         }
! #endif /* FULL_LOCKS_ONLY */
!         /* Do not check length -- length check done in cm_Unlock */
  
!         code = cm_Unlock(scp, LockType, LOffset, LLength, userp, &req);
!         if (code) goto done;
!     }       
  
      for (i=0; i<NumberOfLocks; i++) {
!         if (LockType & LOCKING_ANDX_LARGE_FILES) {
!             /* Large Files */
!             LOffset.HighPart = *((LONG *)(op + 4));
!             LOffset.LowPart = *((DWORD *)(op + 8));
!             LLength.HighPart = *((LONG *)(op + 12));
!             LLength.LowPart = *((DWORD *)(op + 16));
!             op += 20;
!         }
!         else {
!             /* Not Large Files */
!             LOffset.HighPart = 0;
!             LOffset.LowPart = *((DWORD *)(op + 2));
!             LLength.HighPart = 0;
!             LLength.LowPart = *((DWORD *)(op + 6));
!             op += 10;
!         }
! #ifdef FULL_LOCKS_ONLY
!         if (LargeIntegerNotEqualToZero(LOffset)) {
!             osi_Log2(smb_logp, "smb_ReceiveV3Locking Lock %d offset 0x%x != Zero",
!                      i, (long)LOffset.QuadPart);
!             continue;
!         }
!         if (LargeIntegerLessThan(LOffset, scp->length)) {
!             osi_Log3(smb_logp, "smb_ReceiveV3Locking Unlock %d offset 0x%x < 0x%x",
!                      i, (long)LOffset.QuadPart, (long)scp->length.QuadPart);
!             continue;
!         }
! #endif /* FULL_LOCKS_ONLY */
!         code = cm_Lock(scp, LockType, LOffset, LLength, Timeout,
                          userp, &req, &lockp);
          if (code == CM_ERROR_WOULDBLOCK && Timeout != 0) {
              /* Put on waiting list */
!             waitingLock = malloc(sizeof(smb_waitingLock_t));
!             waitingLock->vcp = vcp;
!             smb_HoldVC(vcp);
!             waitingLock->inp = smb_CopyPacket(inp);
!             waitingLock->outp = smb_CopyPacket(outp);
!             waitingLock->timeRemaining = Timeout;
!             waitingLock->lockp = lockp;
!             lock_ObtainWrite(&smb_globalLock);
!             osi_QAdd((osi_queue_t **)&smb_allWaitingLocks,
!                       &waitingLock->q);
!             osi_Wakeup((long) &smb_allWaitingLocks);
!             lock_ReleaseWrite(&smb_globalLock);
!             /* don't send reply immediately */
!             outp->flags |= SMB_PACKETFLAG_NOSEND;
              osi_Log1(smb_logp, "smb_ReceiveV3Locking WaitingLock created 0x%x",
!                      (long) waitingLock);
              continue;
          }
          if (code) {
              osi_Log1(smb_logp, "smb_ReceiveV3Locking cm_Lock failure code 0x%x", code);
              break;
          }
!     }           
  
      if (code) {
!         /* release any locks acquired before the failure */
!         osi_Log0(smb_logp, "smb_ReceiveV3Locking - failure; should be releasing locks but don't!!!!");
!     }
!     else
          smb_SetSMBDataLength(outp, 0);
    done:   
      cm_SyncOpDone(scp, NULL, CM_SCACHESYNC_LOCK);
    doneSync:
      lock_ReleaseMutex(&scp->mx);
      cm_ReleaseUser(userp);
--- 4863,5048 ----
      NumberOfUnlocks = smb_GetSMBParm(inp, 6);
      NumberOfLocks = smb_GetSMBParm(inp, 7);
  
+     if ((LockType & LOCKING_ANDX_CANCEL_LOCK) ||
+         (LockType & LOCKING_ANDX_CHANGE_LOCKTYPE)) {
+ 
+         /* We don't support these requests.  Apparently, we can safely
+            not deal with them too. */
+         osi_Log1(smb_logp, "smb_ReceiveV3Locking received unsupported request [%s]",
+                  ((LockType & LOCKING_ANDX_CANCEL_LOCK)?
+                   "LOCKING_ANDX_CANCEL_LOCK":
+                   "LOCKING_ANDX_CHANGE_LOCKTYPE")); 
+         /* No need to call osi_LogSaveString since these are string
+            constants.*/
+ 
+         code = CM_ERROR_BADOP;
+         goto done;
+ 
+     }
+ 
      op = smb_GetSMBData(inp, NULL);
  
      for (i=0; i<NumberOfUnlocks; i++) {
!         smb_GetLockParams(LockType, &op, &pid, &LOffset, &LLength);
  
!         key = cm_GenerateKey(vcp->vcID, pid, fidp->fid);
! 
!         code = cm_Unlock(scp, LockType, LOffset, LLength, key, userp, &req);
! 
!         if (code) 
!             goto done;
!     }
! 
!     op_locks = op;
  
      for (i=0; i<NumberOfLocks; i++) {
!         smb_GetLockParams(LockType, &op, &pid, &LOffset, &LLength);
! 
!         key = cm_GenerateKey(vcp->vcID, pid, fidp->fid);
! 
!         code = cm_Lock(scp, LockType, LOffset, LLength, key, (Timeout != 0),
                          userp, &req, &lockp);
+ 
          if (code == CM_ERROR_WOULDBLOCK && Timeout != 0) {
+             smb_waitingLock_t * wLock;
+ 
              /* Put on waiting list */
!             if(wlRequest == NULL) {
!                 int j;
!                 char * opt;
!                 cm_key_t tkey;
!                 LARGE_INTEGER tOffset, tLength;
! 
!                 wlRequest = malloc(sizeof(smb_waitingLockRequest_t));
! 
!                 osi_assert(wlRequest != NULL);
! 
!                 wlRequest->vcp = vcp;
!                 smb_HoldVC(vcp);
!                 wlRequest->scp = scp;
!                 cm_HoldSCache(scp);
!                 wlRequest->inp = smb_CopyPacket(inp);
!                 wlRequest->outp = smb_CopyPacket(outp);
!                 wlRequest->lockType = LockType;
!                 wlRequest->timeRemaining = Timeout;
!                 wlRequest->locks = NULL;
! 
!                 /* The waiting lock request needs to have enough
!                    information to undo all the locks in the request.
!                    We do the following to store info about locks that
!                    have already been granted.  Sure, we can get most
!                    of the info from the packet, but the packet doesn't
!                    hold the result of cm_Lock call.  In practice we
!                    only receive packets with one or two locks, so we
!                    are only wasting a few bytes here and there and
!                    only for a limited period of time until the waiting
!                    lock times out or is freed. */
! 
!                 for(opt = op_locks, j=i; j > 0; j--) {
!                     smb_GetLockParams(LockType, &opt, &pid, &tOffset, &tLength);
! 
!                     tkey = cm_GenerateKey(vcp->vcID, pid, fidp->fid);
! 
!                     wLock = malloc(sizeof(smb_waitingLock_t));
! 
!                     osi_assert(wLock != NULL);
! 
!                     wLock->key = tkey;
!                     wLock->LOffset = tOffset;
!                     wLock->LLength = tLength;
!                     wLock->lockp = NULL;
!                     wLock->state = SMB_WAITINGLOCKSTATE_DONE;
!                     osi_QAdd((osi_queue_t **) &wlRequest->locks,
!                              &wLock->q);
!                 }
!             }
! 
!             wLock = malloc(sizeof(smb_waitingLock_t));
! 
!             osi_assert(wLock != NULL);
! 
!             wLock->key = key;
!             wLock->LOffset = LOffset;
!             wLock->LLength = LLength;
!             wLock->lockp = lockp;
!             wLock->state = SMB_WAITINGLOCKSTATE_WAITING;
!             osi_QAdd((osi_queue_t **) &wlRequest->locks,
!                      &wLock->q);
! 
              osi_Log1(smb_logp, "smb_ReceiveV3Locking WaitingLock created 0x%x",
!                      (long) wLock);
! 
!             code = 0;
              continue;
          }
+ 
          if (code) {
              osi_Log1(smb_logp, "smb_ReceiveV3Locking cm_Lock failure code 0x%x", code);
              break;
          }
!     }
  
      if (code) {
! 
!         /* Since something went wrong with the lock number i, we now
!            have to go ahead and release any locks acquired before the
!            failure.  All locks before lock number i (of which there
!            are i of them) have either been successful or are waiting.
!            Either case requires calling cm_Unlock(). */
! 
!         /* And purge the waiting lock */
!         if(wlRequest != NULL) {
!             smb_waitingLock_t * wl;
!             smb_waitingLock_t * wlNext;
!             long ul_code;
! 
!             for(wl = wlRequest->locks; wl; wl = wlNext) {
! 
!                 wlNext = (smb_waitingLock_t *) osi_QNext(&wl->q);
! 
!                 ul_code = cm_Unlock(scp, LockType, wl->LOffset, wl->LLength, wl->key, userp, &req);
!                 
!                 if(ul_code != 0) {
!                     osi_Log1(smb_logp, "smb_ReceiveV3Locking cm_Unlock returns code %d", ul_code);
!                 } else {
!                     osi_Log0(smb_logp, "smb_ReceiveV3Locking cm_Unlock successful");
!                 }
! 
!                 osi_QRemove((osi_queue_t **) &wlRequest->locks, &wl->q);
!                 free(wl);
! 
!             }
! 
!             smb_ReleaseVC(wlRequest->vcp);
!             cm_ReleaseSCache(wlRequest->scp);
!             smb_FreePacket(wlRequest->inp);
!             smb_FreePacket(wlRequest->outp);
! 
!             free(wlRequest);
! 
!             wlRequest = NULL;
!         }
! 
!     } else {
! 
!         if (wlRequest != NULL) {
! 
!             lock_ObtainWrite(&smb_globalLock);
!             osi_QAdd((osi_queue_t **)&smb_allWaitingLocks,
!                      &wlRequest->q);
!             osi_Wakeup((long) &smb_allWaitingLocks);
!             lock_ReleaseWrite(&smb_globalLock);
! 
!             /* don't send reply immediately */
!             outp->flags |= SMB_PACKETFLAG_NOSEND;
!         }
! 
          smb_SetSMBDataLength(outp, 0);
+     }
+ 
    done:   
      cm_SyncOpDone(scp, NULL, CM_SCACHESYNC_LOCK);
+ 
    doneSync:
      lock_ReleaseMutex(&scp->mx);
      cm_ReleaseUser(userp);
***************
*** 5067,5077 ****
  long smb_ReceiveV3ReadX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
  {
      osi_hyper_t offset;
!     long count, finalCount;
      unsigned short fd;
      smb_fid_t *fidp;
      long code = 0;
      cm_user_t *userp;
      char *op;
          
      fd = smb_GetSMBParm(inp, 2);
--- 5169,5182 ----
  long smb_ReceiveV3ReadX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
  {
      osi_hyper_t offset;
!     long count;
!     long finalCount = 0;
      unsigned short fd;
+     unsigned pid;
      smb_fid_t *fidp;
      long code = 0;
      cm_user_t *userp;
+     cm_key_t key;
      char *op;
          
      fd = smb_GetSMBParm(inp, 2);
***************
*** 5087,5099 ****
      if (!fidp) {
          return CM_ERROR_BADFD;
      }
      /* set inp->fid so that later read calls in same msg can find fid */
      inp->fid = fd;
  
      if (fidp->flags & SMB_FID_IOCTL) {
          return smb_IoctlV3Read(fidp, vcp, inp, outp);
      }
!         
      userp = smb_GetUser(vcp, inp);
  
      /* 0 and 1 are reserved for request chaining, were setup by our caller,
--- 5192,5225 ----
      if (!fidp) {
          return CM_ERROR_BADFD;
      }
+ 
+     pid = ((smb_t *) inp)->pid;
+     key = cm_GenerateKey(vcp->vcID, pid, fd);
+     {
+         LARGE_INTEGER LOffset, LLength;
+ 
+         LOffset.HighPart = offset.HighPart;
+         LOffset.LowPart = offset.LowPart;
+         LLength.HighPart = 0;
+         LLength.LowPart = count;
+ 
+         lock_ObtainMutex(&fidp->scp->mx);
+         code = cm_LockCheckRead(fidp->scp, LOffset, LLength, key);
+         lock_ReleaseMutex(&fidp->scp->mx);
+     }
+ 
+     if (code) {
+         smb_ReleaseFID(fidp);
+         return code;
+     }
+ 
      /* set inp->fid so that later read calls in same msg can find fid */
      inp->fid = fd;
  
      if (fidp->flags & SMB_FID_IOCTL) {
          return smb_IoctlV3Read(fidp, vcp, inp, outp);
      }
! 
      userp = smb_GetUser(vcp, inp);
  
      /* 0 and 1 are reserved for request chaining, were setup by our caller,
***************
*** 5188,5193 ****
--- 5314,5320 ----
      unsigned int extAttributes;
      unsigned int createDisp;
      unsigned int createOptions;
+     unsigned int shareAccess;
      int initialModeBits;
      unsigned short baseFid;
      smb_fid_t *baseFidp;
***************
*** 5232,5237 ****
--- 5359,5366 ----
          | (smb_GetSMBOffsetParm(inp, 8, 1) << 16);
      extAttributes = smb_GetSMBOffsetParm(inp, 13, 1)
          | (smb_GetSMBOffsetParm(inp, 14, 1) << 16);
+     shareAccess = smb_GetSMBOffsetParm(inp, 15, 1)
+         | (smb_GetSMBOffsetParm(inp, 16, 1) << 16);
      createDisp = smb_GetSMBOffsetParm(inp, 17, 1)
          | (smb_GetSMBOffsetParm(inp, 18, 1) << 16);
      createOptions = smb_GetSMBOffsetParm(inp, 19, 1)
***************
*** 5252,5258 ****
       * extended attributes
       */
      initialModeBits = 0666;
!     if (extAttributes & 1) 
          initialModeBits &= ~0222;
  
      pathp = smb_GetSMBData(inp, NULL);
--- 5381,5387 ----
       * extended attributes
       */
      initialModeBits = 0666;
!     if (extAttributes & SMB_ATTR_READONLY) 
          initialModeBits &= ~0222;
  
      pathp = smb_GetSMBData(inp, NULL);
***************
*** 5268,5274 ****
  
      osi_Log1(smb_logp,"NTCreateX for [%s]",osi_LogSaveString(smb_logp,realPathp));
      osi_Log4(smb_logp,"... da=[%x] ea=[%x] cd=[%x] co=[%x]", desiredAccess, extAttributes, createDisp, createOptions);
!     osi_Log2(smb_logp,"... flags=[%x] lastNamep=[%s]", flags, osi_LogSaveString(smb_logp,(lastNamep?lastNamep:"null")));
  
      if (lastNamep && strcmp(lastNamep, SMB_IOCTL_FILENAME) == 0) {
          /* special case magic file name for receiving IOCTL requests
--- 5397,5403 ----
  
      osi_Log1(smb_logp,"NTCreateX for [%s]",osi_LogSaveString(smb_logp,realPathp));
      osi_Log4(smb_logp,"... da=[%x] ea=[%x] cd=[%x] co=[%x]", desiredAccess, extAttributes, createDisp, createOptions);
!     osi_Log3(smb_logp,"... share=[%x] flags=[%x] lastNamep=[%s]", shareAccess, flags, osi_LogSaveString(smb_logp,(lastNamep?lastNamep:"null")));
  
      if (lastNamep && strcmp(lastNamep, SMB_IOCTL_FILENAME) == 0) {
          /* special case magic file name for receiving IOCTL requests
***************
*** 5316,5321 ****
--- 5445,5451 ----
      	free(hexp);
      }
  #endif
+ 
      userp = smb_GetUser(vcp, inp);
      if (!userp) {
      	osi_Log1(smb_logp, "NTCreateX Invalid user [%d]", ((smb_t *) inp)->uid);
***************
*** 5364,5369 ****
--- 5494,5505 ----
      if (createOptions & FILE_DELETE_ON_CLOSE)
          fidflags |= SMB_FID_DELONCLOSE;
  
+     /* and the share mode */
+     if (shareAccess & FILE_SHARE_READ)
+         fidflags |= SMB_FID_SHARE_READ;
+     if (shareAccess & FILE_SHARE_WRITE)
+         fidflags |= SMB_FID_SHARE_WRITE;
+ 
      code = 0;
  
      /* For an exclusive create, we want to do a case sensitive match for the last component. */
***************
*** 5539,5545 ****
          /* we have scp but not dscp */
          if (baseFid != 0) 
              smb_ReleaseFID(baseFidp);
!     }       
  
      /* if we get here, if code is 0, the file exists and is represented by
       * scp.  Otherwise, we have to create it.  The dir may be represented
--- 5675,5681 ----
          /* we have scp but not dscp */
          if (baseFid != 0) 
              smb_ReleaseFID(baseFidp);
!     }
  
      /* if we get here, if code is 0, the file exists and is represented by
       * scp.  Otherwise, we have to create it.  The dir may be represented
***************
*** 5560,5565 ****
--- 5696,5702 ----
  
          if ( createDisp == FILE_OVERWRITE || 
               createDisp == FILE_OVERWRITE_IF) {
+ 
              setAttr.mask = CM_ATTRMASK_LENGTH;
              setAttr.length.LowPart = 0;
              setAttr.length.HighPart = 0;
***************
*** 5784,5789 ****
--- 5921,5966 ----
      /* open the file itself */
      fidp = smb_FindFID(vcp, 0, SMB_FLAG_CREATE);
      osi_assert(fidp);
+ 
+     /* If we are restricting sharing, we should do so with a suitable
+        share lock. */
+     if (scp->fileType == CM_SCACHETYPE_FILE &&
+         !(fidflags & SMB_FID_SHARE_WRITE)) {
+         cm_key_t key;
+         LARGE_INTEGER LOffset, LLength;
+         int sLockType;
+ 
+         LOffset.HighPart = SMB_FID_QLOCK_HIGH;
+         LOffset.LowPart = SMB_FID_QLOCK_LOW;
+         LLength.HighPart = 0;
+         LLength.LowPart = SMB_FID_QLOCK_LENGTH;
+ 
+         if (fidflags & SMB_FID_SHARE_READ) {
+             sLockType = LOCKING_ANDX_SHARED_LOCK;
+         } else {
+             sLockType = 0;
+         }
+ 
+         key = cm_GenerateKey(vcp->vcID, SMB_FID_QLOCK_PID, fidp->fid);
+         
+         lock_ObtainMutex(&scp->mx);
+         code = cm_Lock(scp, sLockType, LOffset, LLength, key, 0, userp, &req, NULL);
+         lock_ReleaseMutex(&scp->mx);
+ 
+         if (code) {
+             fidp->flags = SMB_FID_DELETE;
+             smb_ReleaseFID(fidp);
+ 
+             cm_ReleaseSCache(scp);
+             if (dscp)
+                 cm_ReleaseSCache(dscp);
+             cm_ReleaseUser(userp);
+             free(realPathp);
+             
+             return code;
+         }
+     }
+ 
      /* save a pointer to the vnode */
      fidp->scp = scp;    /* Hold transfered to fidp->scp and no longer needed */
  
***************
*** 5803,5808 ****
--- 5980,5986 ----
          cm_ReleaseSCache(dscp);
          dscp = NULL;
      }
+ 
      cm_Open(scp, 0, userp);
  
      /* set inp->fid so that later read calls in same msg can find fid */
***************
*** 5837,5843 ****
  
      cm_ReleaseUser(userp);
  
!     /* Can't free realPathp if we get here since fidp->NTopen_wholepathp is pointing there */
  
      /* leave scp held since we put it in fidp->scp */
      return 0;
--- 6015,6022 ----
  
      cm_ReleaseUser(userp);
  
!     /* Can't free realPathp if we get here since
!        fidp->NTopen_wholepathp is pointing there */
  
      /* leave scp held since we put it in fidp->scp */
      return 0;
***************
*** 5868,5875 ****
      unsigned int desiredAccess;
  #ifdef DEBUG_VERBOSE    
      unsigned int allocSize;
-     unsigned int shareAccess;
  #endif
      unsigned int extAttributes;
      unsigned int createDisp;
  #ifdef DEBUG_VERBOSE
--- 6047,6054 ----
      unsigned int desiredAccess;
  #ifdef DEBUG_VERBOSE    
      unsigned int allocSize;
  #endif
+     unsigned int shareAccess;
      unsigned int extAttributes;
      unsigned int createDisp;
  #ifdef DEBUG_VERBOSE
***************
*** 5921,5929 ****
      allocSize = lparmp[3];
  #endif /* DEBUG_VERSOSE */
      extAttributes = lparmp[5];
- #ifdef DEBUG_VEROSE
      shareAccess = lparmp[6];
- #endif
      createDisp = lparmp[7];
      createOptions = lparmp[8];
  #ifdef DEBUG_VERBOSE
--- 6100,6106 ----
***************
*** 6027,6032 ****
--- 6204,6215 ----
      if (createOptions & FILE_DELETE_ON_CLOSE)
          fidflags |= SMB_FID_DELONCLOSE;
  
+     /* And the share mode */
+     if (shareAccess & FILE_SHARE_READ)
+         fidflags |= SMB_FID_SHARE_READ;
+     if (shareAccess & FILE_SHARE_WRITE)
+         fidflags |= SMB_FID_SHARE_WRITE;
+ 
      dscp = NULL;
      code = 0;
      if ( createDisp == FILE_OPEN || 
***************
*** 6327,6332 ****
--- 6510,6552 ----
      fidp = smb_FindFID(vcp, 0, SMB_FLAG_CREATE);
      osi_assert(fidp);
  
+     /* If we are restricting sharing, we should do so with a suitable
+        share lock. */
+     if (scp->fileType == CM_SCACHETYPE_FILE &&
+         !(fidflags & SMB_FID_SHARE_WRITE)) {
+         cm_key_t key;
+         LARGE_INTEGER LOffset, LLength;
+         int sLockType;
+ 
+         LOffset.HighPart = SMB_FID_QLOCK_HIGH;
+         LOffset.LowPart = SMB_FID_QLOCK_LOW;
+         LLength.HighPart = 0;
+         LLength.LowPart = SMB_FID_QLOCK_LENGTH;
+ 
+         if (fidflags & SMB_FID_SHARE_READ) {
+             sLockType = LOCKING_ANDX_SHARED_LOCK;
+         } else {
+             sLockType = 0;
+         }
+ 
+         key = cm_GenerateKey(vcp->vcID, SMB_FID_QLOCK_PID, fidp->fid);
+         
+         lock_ObtainMutex(&scp->mx);
+         code = cm_Lock(scp, sLockType, LOffset, LLength, key, 0, userp, &req, NULL);
+         lock_ReleaseMutex(&scp->mx);
+ 
+         if (code) {
+             fidp->flags = SMB_FID_DELETE;
+             smb_ReleaseFID(fidp);
+ 
+             cm_ReleaseSCache(scp);
+             cm_ReleaseUser(userp);
+             free(realPathp);
+             
+             return CM_ERROR_SHARING_VIOLATION;
+         }
+     }
+ 
      /* save a pointer to the vnode */
      fidp->scp = scp;
  
Index: openafs/src/WINNT/client_exp/gui2fs.cpp
diff -c openafs/src/WINNT/client_exp/gui2fs.cpp:1.10.2.7 openafs/src/WINNT/client_exp/gui2fs.cpp:1.10.2.8
*** openafs/src/WINNT/client_exp/gui2fs.cpp:1.10.2.7	Sun Oct  2 05:08:18 2005
--- openafs/src/WINNT/client_exp/gui2fs.cpp	Sat Oct 15 17:48:27 2005
***************
*** 32,37 ****
--- 32,38 ----
  #include <afsint.h>
  #include <afs/auth.h>
  #include <WINNT\afsreg.h>
+ #include <cm.h>
  }
  
  
***************
*** 298,307 ****
--- 299,352 ----
      dlg.DoModal();
  }       
  
+ static int
+ CMtoUNIXerror(int cm_code)
+ {
+     switch (cm_code) {
+     case CM_ERROR_TIMEDOUT:
+ 	return ETIMEDOUT;
+     case CM_ERROR_NOACCESS:
+ 	return EACCES;
+     case CM_ERROR_NOSUCHFILE:
+ 	return ENOENT;
+     case CM_ERROR_INVAL:
+ 	return EINVAL;
+     case CM_ERROR_BADFD:
+ 	return EBADF;
+     case CM_ERROR_EXISTS:
+ 	return EEXIST;
+     case CM_ERROR_CROSSDEVLINK:
+ 	return EXDEV;
+     case CM_ERROR_NOTDIR:
+ 	return ENOTDIR;
+     case CM_ERROR_ISDIR:
+ 	return EISDIR;
+     case CM_ERROR_READONLY:
+ 	return EROFS;
+     case CM_ERROR_WOULDBLOCK:
+ 	return EWOULDBLOCK;
+     case CM_ERROR_NOSUCHCELL:
+ 	return ESRCH;		/* hack */
+     case CM_ERROR_NOSUCHVOLUME:
+ 	return EPIPE;		/* hack */
+     case CM_ERROR_NOMORETOKENS:
+ 	return EDOM;		/* hack */
+     case CM_ERROR_TOOMANYBUFS:
+ 	return EFBIG;		/* hack */
+     default:
+ 	if (cm_code > 0 && cm_code < EILSEQ)
+ 	    return cm_code;
+ 	else
+ 	    return ENOTTY;
+     }
+ }
+ 
  CString GetAfsError(int code, const char *filename)
  {
      CString strMsg;
  
+     code = CMtoUNIXerror(code);
+ 
      if (code == EINVAL) {
          if (filename)
              strMsg.Format("Invalid argument; it is possible that the file is not in AFS");
Index: openafs/src/WINNT/client_exp/set_afs_acl.cpp
diff -c openafs/src/WINNT/client_exp/set_afs_acl.cpp:1.2.20.1 openafs/src/WINNT/client_exp/set_afs_acl.cpp:1.2.20.2
*** openafs/src/WINNT/client_exp/set_afs_acl.cpp:1.2.20.1	Wed Jul  6 20:29:14 2005
--- openafs/src/WINNT/client_exp/set_afs_acl.cpp	Sat Oct 15 17:48:27 2005
***************
*** 350,360 ****
  
  void CSetAfsAcl::OnNothingSelected()
  {
! 	m_NormalRights.SetSel(-1, FALSE);	// Unselect any selected normal rights
! 	m_NegativeRights.SetSel(-1, FALSE);	// Unselect any selected negative rights
! 	ShowRights("");						// Show no rights
! 	EnablePermChanges(FALSE);			// Allow no rights changes
! 	m_Remove.EnableWindow(FALSE);		// Disable remove button
  }
  
  void CSetAfsAcl::OnSelection()
--- 350,369 ----
  
  void CSetAfsAcl::OnNothingSelected()
  {
!     //m_NormalRights.SetSel(-1,FALSE);	// Unselect any selected normal rights
!     //m_NegativeRights.SetSel(-1,FALSE);	// Unselect any selected negative rights
! 
!     for (int i=0;i < m_NormalRights.GetCount();i++)
!     {
! 	m_NormalRights.SetSel(i, FALSE);
!     }
!     for (int i=0;i < m_NegativeRights.GetCount();i++)
!     {
! 	m_NegativeRights.SetSel(i, FALSE);
!     }
!     ShowRights("");				// Show no rights
!     EnablePermChanges(FALSE);		// Allow no rights changes
!     m_Remove.EnableWindow(FALSE);		// Disable remove button
  }
  
  void CSetAfsAcl::OnSelection()
Index: openafs/src/afs/afs.h
diff -c openafs/src/afs/afs.h:1.48.2.21 openafs/src/afs/afs.h:1.48.2.24
*** openafs/src/afs/afs.h:1.48.2.21	Mon Jul 11 15:29:55 2005
--- openafs/src/afs/afs.h	Thu Oct 13 14:23:36 2005
***************
*** 329,334 ****
--- 329,335 ----
   */
  #define	QTOV(e)	    ((struct vcache *)(((char *) (e)) - (((char *)(&(((struct vcache *)(e))->vlruq))) - ((char *)(e)))))
  #define	QTOC(e)	    ((struct cell *)((char *) (e)))
+ #define	QTOVH(e)   ((struct vcache *)(((char *) (e)) - (((char *)(&(((struct vcache *)(e))->vhashq))) - ((char *)(e)))))
  
  #define	SRVADDR_MH	1
  #define	SRVADDR_ISDOWN	0x20	/* same as SRVR_ISDOWN */
***************
*** 526,537 ****
--- 527,542 ----
  #ifdef	AFS_OSF_ENV
  #define CWired		0x00000800	/* OSF hack only */
  #else
+ #ifdef AFS_DARWIN80_ENV
+ #define CDeadVnode        0x00000800
+ #else
  #ifdef AFS_DARWIN_ENV
  #define CUBCinit        0x00000800
  #else
  #define CWRITE_IGN	0x00000800	/* Next OS hack only */
  #endif
  #endif
+ #endif
  #define CUnique		0x00001000	/* vc's uniquifier - latest unifiquier for fid */
  #define CForeign	0x00002000	/* this is a non-afs vcache */
  #define CUnlinked	0x00010000
***************
*** 545,550 ****
--- 550,556 ----
  #define CDCLock		0x02000000	/* Vnode lock held over call to GetDownD */
  #define CBulkFetching	0x04000000	/* stats are being fetched by bulk stat */
  #define CExtendedFile	0x08000000	/* extended file via ftruncate call. */
+ #define CVInit          0x10000000      /* being initialized */
  
  /* vcache vstate bits */
  #define VRevokeWait   0x1
***************
*** 557,569 ****
  #define vrefCount   v.v_count
  #endif /* AFS_XBSD_ENV */
  
! #if defined(AFS_LINUX24_ENV)
  #define VREFCOUNT(v)		atomic_read(&(AFSTOV(v)->v_count))
  #define VREFCOUNT_SET(v, c)	atomic_set(&(AFSTOV(v)->v_count), c)
  #define VREFCOUNT_DEC(v)	atomic_dec(&(AFSTOV(v)->v_count))
  #define VREFCOUNT_INC(v)	atomic_inc(&(AFSTOV(v)->v_count))
  #else
  #define VREFCOUNT(v)		((v)->vrefCount)
  #define VREFCOUNT_SET(v, c)	(v)->vrefCount = c;
  #define VREFCOUNT_DEC(v)	(v)->vrefCount--;
  #define VREFCOUNT_INC(v)	(v)->vrefCount++;
--- 563,582 ----
  #define vrefCount   v.v_count
  #endif /* AFS_XBSD_ENV */
  
! #if defined(AFS_DARWIN80_ENV)
! #define VREFCOUNT_GT(v, y)    vnode_isinuse(AFSTOV(v), (y))
! #elif defined(AFS_XBSD_ENV) || defined(AFS_DARWIN_ENV)
! #define VREFCOUNT(v)          ((v)->vrefCount)
! #define VREFCOUNT_GT(v, y)    (AFSTOV(v)->v_usecount > (y))
! #elif defined(AFS_LINUX24_ENV)
  #define VREFCOUNT(v)		atomic_read(&(AFSTOV(v)->v_count))
+ #define VREFCOUNT_GT(v, y)    ((atomic_read(&((vnode_t *) v)->v_count)>y)?1:0)
  #define VREFCOUNT_SET(v, c)	atomic_set(&(AFSTOV(v)->v_count), c)
  #define VREFCOUNT_DEC(v)	atomic_dec(&(AFSTOV(v)->v_count))
  #define VREFCOUNT_INC(v)	atomic_inc(&(AFSTOV(v)->v_count))
  #else
  #define VREFCOUNT(v)		((v)->vrefCount)
+ #define VREFCOUNT_GT(v,y)     ((v)->vrefCount > (y))
  #define VREFCOUNT_SET(v, c)	(v)->vrefCount = c;
  #define VREFCOUNT_DEC(v)	(v)->vrefCount--;
  #define VREFCOUNT_INC(v)	(v)->vrefCount++;
***************
*** 580,586 ****
  
  extern afs_int32 vmPageHog;	/* counter for # of vnodes which are page hogs. */
  
! #if defined(AFS_XBSD_ENV) || defined(AFS_DARWIN_ENV) || (defined(AFS_LINUX22_ENV) && !defined(STRUCT_SUPER_HAS_ALLOC_INODE))
  #define VTOAFS(v) ((struct vcache *)(v)->v_data)
  #define AFSTOV(vc) ((vc)->v)
  #else
--- 593,602 ----
  
  extern afs_int32 vmPageHog;	/* counter for # of vnodes which are page hogs. */
  
! #if defined(AFS_DARWIN80_ENV)
! #define VTOAFS(v) ((struct vcache *)vnode_fsnode((v)))
! #define AFSTOV(vc) ((vc)->v)
! #elif defined(AFS_XBSD_ENV) || defined(AFS_DARWIN_ENV) || (defined(AFS_LINUX22_ENV) && !defined(STRUCT_SUPER_HAS_ALLOC_INODE))
  #define VTOAFS(v) ((struct vcache *)(v)->v_data)
  #define AFSTOV(vc) ((vc)->v)
  #else
***************
*** 603,609 ****
      struct vcache *nextfree;	/* next on free list (if free) */
  #endif
      struct vcache *hnext;	/* Hash next */
!     struct vcache *vhnext;	/* vol hash next */
      struct VenusFid fid;
      struct mstat {
  	afs_size_t Length;
--- 619,625 ----
      struct vcache *nextfree;	/* next on free list (if free) */
  #endif
      struct vcache *hnext;	/* Hash next */
!     struct afs_q vhashq;	/* Hashed per-volume list */
      struct VenusFid fid;
      struct mstat {
  	afs_size_t Length;
***************
*** 613,619 ****
--- 629,639 ----
  	afs_uint32 Group;
  	afs_uint16 Mode;	/* XXXX Should be afs_int32 XXXX */
  	afs_uint16 LinkCount;
+ #ifdef AFS_DARWIN80_ENV
+         afs_uint16 Type;
+ #else
  	/* vnode type is in v.v_type */
+ #endif
      } m;
      afs_rwlock_t lock;		/* The lock on the vcache contents. */
  #if	defined(AFS_SUN5_ENV)
***************
*** 641,647 ****
  #ifdef AFS_AIX_ENV
      int ownslock;		/* pid of owner of excl lock, else 0 - defect 3083 */
  #endif
! #ifdef AFS_DARWIN_ENV
      struct lock__bsd__ rwlock;
  #endif
  #ifdef AFS_XBSD_ENV
--- 661,669 ----
  #ifdef AFS_AIX_ENV
      int ownslock;		/* pid of owner of excl lock, else 0 - defect 3083 */
  #endif
! #ifdef AFS_DARWIN80_ENV
!     lck_mtx_t *rwlock;
! #elif defined(AFS_DARWIN_ENV)
      struct lock__bsd__ rwlock;
  #endif
  #ifdef AFS_XBSD_ENV
***************
*** 1042,1048 ****
  extern afs_int32 afs_cacheBlocks;	/*1K blocks in cache */
  extern afs_int32 afs_cacheStats;	/*Stat entries in cache */
  extern struct vcache *afs_vhashT[VCSIZE];	/*Stat cache hash table */
! extern struct vcache *afs_vhashTV[VCSIZE]; /* cache hash table on volume */
  extern afs_int32 afs_initState;	/*Initialization state */
  extern afs_int32 afs_termState;	/* Termination state */
  extern struct VenusFid afs_rootFid;	/*Root for whole file system */
--- 1064,1070 ----
  extern afs_int32 afs_cacheBlocks;	/*1K blocks in cache */
  extern afs_int32 afs_cacheStats;	/*Stat entries in cache */
  extern struct vcache *afs_vhashT[VCSIZE];	/*Stat cache hash table */
! extern struct afs_q afs_vhashTV[VCSIZE]; /* cache hash table on volume */
  extern afs_int32 afs_initState;	/*Initialization state */
  extern afs_int32 afs_termState;	/* Termination state */
  extern struct VenusFid afs_rootFid;	/*Root for whole file system */
***************
*** 1112,1122 ****
  #define CM_CACHESIZEDRAINEDPCT	95	/* wakeup processes when down to here. */
  #define CM_WAITFORDRAINPCT	98	/* sleep if cache is this full. */
  
  #define afs_CacheIsTooFull() \
      (afs_blocksUsed - afs_blocksDiscarded > \
! 	(CM_DCACHECOUNTFREEPCT*afs_cacheBlocks)/100 || \
       afs_freeDCCount - afs_discardDCCount < \
! 	((100-CM_DCACHECOUNTFREEPCT)*afs_cacheFiles)/100)
  
  /* Handy max length of a numeric string. */
  #define	CVBS	12		/* max afs_int32 is 2^32 ~ 4*10^9, +1 for NULL, +luck */
--- 1134,1148 ----
  #define CM_CACHESIZEDRAINEDPCT	95	/* wakeup processes when down to here. */
  #define CM_WAITFORDRAINPCT	98	/* sleep if cache is this full. */
  
+ /* when afs_cacheBlocks is large, settle for slightly decreased precision */
+ #define PERCENT(p, v) \
+     ((afs_cacheBlocks & 0xffe00000) ? ((v) / 100 * (p)) : ((p) * (v) / 100))
+ 
  #define afs_CacheIsTooFull() \
      (afs_blocksUsed - afs_blocksDiscarded > \
! 	PERCENT(CM_DCACHECOUNTFREEPCT, afs_cacheBlocks) || \
       afs_freeDCCount - afs_discardDCCount < \
! 	PERCENT(100 - CM_DCACHECOUNTFREEPCT, afs_cacheFiles))
  
  /* Handy max length of a numeric string. */
  #define	CVBS	12		/* max afs_int32 is 2^32 ~ 4*10^9, +1 for NULL, +luck */
Index: openafs/src/afs/afs_call.c
diff -c openafs/src/afs/afs_call.c:1.74.2.10 openafs/src/afs/afs_call.c:1.74.2.11
*** openafs/src/afs/afs_call.c:1.74.2.10	Tue Jun 21 16:13:48 2005
--- openafs/src/afs/afs_call.c	Wed Oct  5 01:58:26 2005
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_call.c,v 1.74.2.10 2005/06/21 20:13:48 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_call.c,v 1.74.2.11 2005/10/05 05:58:26 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 61,69 ****
  simple_lock_data_t afs_global_lock;
  #endif
  
! #if defined(AFS_DARWIN_ENV)
  struct lock__bsd__ afs_global_lock;
  #endif
  
  #if defined(AFS_XBSD_ENV) && !defined(AFS_FBSD50_ENV)
  struct lock afs_global_lock;
--- 61,73 ----
  simple_lock_data_t afs_global_lock;
  #endif
  
! #if defined(AFS_DARWIN_ENV) 
! #ifdef AFS_DARWIN80_ENV
! lck_mtx_t  *afs_global_lock;
! #else
  struct lock__bsd__ afs_global_lock;
  #endif
+ #endif
  
  #if defined(AFS_XBSD_ENV) && !defined(AFS_FBSD50_ENV)
  struct lock afs_global_lock;
***************
*** 374,379 ****
--- 378,386 ----
  #endif
      }
      AFS_GLOCK();
+ #ifdef AFS_DARWIN80_ENV
+     put_vfs_context();
+ #endif
  #if defined(AFS_LINUX24_ENV) && defined(COMPLETION_H_EXISTS) && !defined(UKERNEL)
      if (parm < AFSOP_ADDCELL || parm == AFSOP_RXEVENT_DAEMON
  	|| parm == AFSOP_RXLISTENER_DAEMON) {
***************
*** 642,652 ****
--- 649,665 ----
  	while (afs_initState < AFSOP_START_BKG)
  	    afs_osi_Sleep(&afs_initState);
  
+ #ifdef AFS_DARWIN80_ENV
+     get_vfs_context();
+ #endif
  	/* do it by inode */
  #ifdef AFS_SGI62_ENV
  	ainode = (ainode << 32) | (parm3 & 0xffffffff);
  #endif
  	code = afs_InitCacheFile(NULL, ainode);
+ #ifdef AFS_DARWIN80_ENV
+     put_vfs_context();
+ #endif
      } else if (parm == AFSOP_ROOTVOLUME) {
  	/* wait for basic init */
  	while (afs_initState < AFSOP_START_BKG)
***************
*** 673,678 ****
--- 686,694 ----
  	if (!code) {
  	    tbuffer[AFS_SMALLOCSIZ - 1] = '\0';	/* null-terminate the name */
  	    /* We have the cache dir copied in.  Call the cache init routine */
+ #ifdef AFS_DARWIN80_ENV
+     get_vfs_context();
+ #endif
  	    if (parm == AFSOP_CACHEFILE)
  		code = afs_InitCacheFile(tbuffer, 0);
  	    else if (parm == AFSOP_CACHEINFO)
***************
*** 681,686 ****
--- 697,705 ----
  		code = afs_InitVolumeInfo(tbuffer);
  	    else if (parm == AFSOP_CELLINFO)
  		code = afs_InitCellInfo(tbuffer);
+ #ifdef AFS_DARWIN80_ENV
+     put_vfs_context();
+ #endif
  	}
  	osi_FreeSmallSpace(tbuffer);
      } else if (parm == AFSOP_GO) {
***************
*** 821,830 ****
  	i = rxi_Findcbi(parm2);
  	mtu = ((i == -1) ? htonl(1500) : afs_cb_interface.mtu[i]);
  #else /* AFS_USERSPACE_IP_ADDR */
! 	struct ifnet *tifnp;
  
  	tifnp = rxi_FindIfnet(parm2, NULL);	/*  make iterative */
! 	mtu = (tifnp ? tifnp->if_mtu : htonl(1500));
  #endif /* else AFS_USERSPACE_IP_ADDR */
  #endif /* !AFS_SUN5_ENV */
  	if (!code)
--- 840,849 ----
  	i = rxi_Findcbi(parm2);
  	mtu = ((i == -1) ? htonl(1500) : afs_cb_interface.mtu[i]);
  #else /* AFS_USERSPACE_IP_ADDR */
! 	AFS_IFNET_T tifnp;
  
  	tifnp = rxi_FindIfnet(parm2, NULL);	/*  make iterative */
! 	mtu = (tifnp ? ifnet_mtu(tifnp) : htonl(1500));
  #endif /* else AFS_USERSPACE_IP_ADDR */
  #endif /* !AFS_SUN5_ENV */
  	if (!code)
***************
*** 858,864 ****
  	    code = -1;
  	}
  #else /* AFS_USERSPACE_IP_ADDR */
! 	struct ifnet *tifnp;
  
  	tifnp = rxi_FindIfnet(parm2, &mask);	/* make iterative */
  	if (!tifnp)
--- 877,883 ----
  	    code = -1;
  	}
  #else /* AFS_USERSPACE_IP_ADDR */
! 	AFS_IFNET_T tifnp;
  
  	tifnp = rxi_FindIfnet(parm2, &mask);	/* make iterative */
  	if (!tifnp)
***************
*** 911,916 ****
--- 930,938 ----
  	code = EINVAL;
  
    out:
+ #ifdef AFS_DARWIN80_ENV /* to balance the put in afs3_syscall() */
+     get_vfs_context();
+ #endif
      AFS_GUNLOCK();
  #ifdef AFS_LINUX20_ENV
      return -code;
***************
*** 1229,1235 ****
       struct proc *p;
  #endif
       void *args;
!      int *retval;
  {
      register struct a {
  	long syscall;
--- 1251,1257 ----
       struct proc *p;
  #endif
       void *args;
!      long *retval;
  {
      register struct a {
  	long syscall;
***************
*** 1351,1357 ****
  	uap->parm6 = 0;
      }
  #endif
! 
  #if defined(AFS_HPUX_ENV)
      /*
       * There used to be code here (duplicated from osi_Init()) for
--- 1373,1382 ----
  	uap->parm6 = 0;
      }
  #endif
! #if defined(AFS_DARWIN80_ENV)
!     get_vfs_context();
!     osi_Assert(*retval == 0);
! #endif
  #if defined(AFS_HPUX_ENV)
      /*
       * There used to be code here (duplicated from osi_Init()) for
***************
*** 1398,1403 ****
--- 1423,1432 ----
  	code =
  	    afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3, uap->parm4,
  			       p->td_ucred);
+ #elif defined(AFS_DARWIN80_ENV)
+ 	code =
+ 	    afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3, uap->parm4,
+ 			       kauth_cred_get());
  #elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
  	code =
  	    afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3, uap->parm4,
***************
*** 1486,1491 ****
--- 1515,1523 ----
  #endif
      }
  
+ #if defined(AFS_DARWIN80_ENV)
+     put_vfs_context();
+ #endif
  #ifdef AFS_LINUX20_ENV
      code = -code;
      unlock_kernel();
Index: openafs/src/afs/afs_callback.c
diff -c openafs/src/afs/afs_callback.c:1.27.2.2 openafs/src/afs/afs_callback.c:1.27.2.4
*** openafs/src/afs/afs_callback.c:1.27.2.2	Mon May 30 00:05:40 2005
--- openafs/src/afs/afs_callback.c	Thu Oct 13 14:08:39 2005
***************
*** 17,23 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_callback.c,v 1.27.2.2 2005/05/30 04:05:40 shadow Exp $");
  
  #include "afs/sysincludes.h"	/*Standard vendor system headers */
  #include "afsincludes.h"	/*AFS-based standard headers */
--- 17,23 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_callback.c,v 1.27.2.4 2005/10/13 18:08:39 shadow Exp $");
  
  #include "afs/sysincludes.h"	/*Standard vendor system headers */
  #include "afsincludes.h"	/*AFS-based standard headers */
***************
*** 151,157 ****
--- 151,165 ----
      a_result->DataVersion = hgetlo(tvc->m.DataVersion);
      a_result->callback = afs_data_pointer_to_int32(tvc->callback);	/* XXXX Now a pointer; change it XXXX */
      a_result->cbExpires = tvc->cbExpires;
+     if (tvc->states & CVInit) {
+         a_result->refCount = 1;
+     } else {
+ #ifdef AFS_DARWIN80_ENV
+     a_result->refCount = vnode_isinuse(AFSTOV(tvc),0)?1:0; /* XXX fix */
+ #else
      a_result->refCount = VREFCOUNT(tvc);
+ #endif
+     }
      a_result->opens = tvc->opens;
      a_result->writers = tvc->execsOrWriters;
      a_result->mvstat = tvc->mvstat;
***************
*** 230,236 ****
--- 238,252 ----
      a_result->DataVersion = hgetlo(tvc->m.DataVersion);
      a_result->callback = afs_data_pointer_to_int32(tvc->callback);	/* XXXX Now a pointer; change it XXXX */
      a_result->cbExpires = tvc->cbExpires;
+     if (tvc->states & CVInit) {
+         a_result->refCount = 1;
+     } else {
+ #ifdef AFS_DARWIN80_ENV
+     a_result->refCount = vnode_isinuse(AFSTOV(tvc),0)?1:0; /* XXX fix */
+ #else
      a_result->refCount = VREFCOUNT(tvc);
+ #endif
+     }
      a_result->opens = tvc->opens;
      a_result->writers = tvc->execsOrWriters;
      a_result->mvstat = tvc->mvstat;
***************
*** 384,395 ****
       */
      if (a_fid->Volume != 0) {
  	if (a_fid->Vnode == 0) {
  	    /*
  	     * Clear callback for the whole volume.  Zip through the
  	     * hash chain, nullifying entries whose volume ID matches.
  	     */
  		i = VCHashV(&localFid);
! 		for (tvc = afs_vhashTV[i]; tvc; tvc = tvc->vhnext) {
  		    if (tvc->fid.Fid.Volume == a_fid->Volume) {
  			tvc->callback = NULL;
  			if (!localFid.Cell)
--- 400,414 ----
       */
      if (a_fid->Volume != 0) {
  	if (a_fid->Vnode == 0) {
+ 		struct afs_q *tq, *uq;
  	    /*
  	     * Clear callback for the whole volume.  Zip through the
  	     * hash chain, nullifying entries whose volume ID matches.
  	     */
  		i = VCHashV(&localFid);
! 		for (tq = afs_vhashTV[i].prev; tq != &afs_vhashTV[i]; tq = uq) {
! 		    uq = QPrev(tq);
! 		    tvc = QTOVH(tq);      
  		    if (tvc->fid.Fid.Volume == a_fid->Volume) {
  			tvc->callback = NULL;
  			if (!localFid.Cell)
***************
*** 404,410 ****
  			else
  			    afs_evenCBs++;
  			ReleaseWriteLock(&afs_xcbhash);
! 			if (tvc->fid.Fid.Vnode & 1 || (vType(tvc) == VDIR))
  			    osi_dnlc_purgedp(tvc);
  			afs_Trace3(afs_iclSetp, CM_TRACE_CALLBACK,
  				   ICL_TYPE_POINTER, tvc, ICL_TYPE_INT32,
--- 423,430 ----
  			else
  			    afs_evenCBs++;
  			ReleaseWriteLock(&afs_xcbhash);
! 			if (!(tvc->states & CVInit) &&
! 			    (tvc->fid.Fid.Vnode & 1 || (vType(tvc) == VDIR)))
  			    osi_dnlc_purgedp(tvc);
  			afs_Trace3(afs_iclSetp, CM_TRACE_CALLBACK,
  				   ICL_TYPE_POINTER, tvc, ICL_TYPE_INT32,
***************
*** 448,454 ****
  		    afs_DequeueCallback(tvc);
  		    tvc->states &= ~(CStatd | CUnique | CBulkFetching);
  		    ReleaseWriteLock(&afs_xcbhash);
! 		    if (a_fid->Vnode & 1 || (vType(tvc) == VDIR))
  			osi_dnlc_purgedp(tvc);
  		    afs_Trace3(afs_iclSetp, CM_TRACE_CALLBACK,
  			       ICL_TYPE_POINTER, tvc, ICL_TYPE_INT32,
--- 468,475 ----
  		    afs_DequeueCallback(tvc);
  		    tvc->states &= ~(CStatd | CUnique | CBulkFetching);
  		    ReleaseWriteLock(&afs_xcbhash);
! 		    if (!(tvc->states & CVInit) &&
! 		        (tvc->fid.Fid.Vnode & 1 || (vType(tvc) == VDIR)))
  			osi_dnlc_purgedp(tvc);
  		    afs_Trace3(afs_iclSetp, CM_TRACE_CALLBACK,
  			       ICL_TYPE_POINTER, tvc, ICL_TYPE_INT32,
Index: openafs/src/afs/afs_cbqueue.c
diff -c openafs/src/afs/afs_cbqueue.c:1.9.2.1 openafs/src/afs/afs_cbqueue.c:1.9.2.2
*** openafs/src/afs/afs_cbqueue.c:1.9.2.1	Mon May 30 00:05:40 2005
--- openafs/src/afs/afs_cbqueue.c	Wed Oct  5 01:58:26 2005
***************
*** 75,81 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_cbqueue.c,v 1.9.2.1 2005/05/30 04:05:40 shadow Exp $");
  
  #include "afs/sysincludes.h"	/*Standard vendor system headers */
  #include "afsincludes.h"	/*AFS-based standard headers */
--- 75,81 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_cbqueue.c,v 1.9.2.2 2005/10/05 05:58:26 shadow Exp $");
  
  #include "afs/sysincludes.h"	/*Standard vendor system headers */
  #include "afsincludes.h"	/*AFS-based standard headers */
***************
*** 222,229 ****
  			    QRemove(tq);
  			    tq->prev = tq->next = NULL;
  			    tvc->states &= ~(CStatd | CMValid | CUnique);
! 			    if ((tvc->fid.Fid.Vnode & 1)
! 				|| (vType(tvc) == VDIR))
  				osi_dnlc_purgedp(tvc);
  			    tvc->dchint = NULL;	/*invalidate em */
  			    afs_ResetVolumeInfo(tvp);
--- 222,230 ----
  			    QRemove(tq);
  			    tq->prev = tq->next = NULL;
  			    tvc->states &= ~(CStatd | CMValid | CUnique);
!                             if (!(tvc->states & CVInit) &&
!                                 (tvc->fid.Fid.Vnode & 1 ||
!                                  (vType(tvc) == VDIR)))
  				osi_dnlc_purgedp(tvc);
  			    tvc->dchint = NULL;	/*invalidate em */
  			    afs_ResetVolumeInfo(tvp);
***************
*** 239,245 ****
  		QRemove(tq);
  		tq->prev = tq->next = NULL;
  		tvc->states &= ~(CStatd | CMValid | CUnique);
! 		if ((tvc->fid.Fid.Vnode & 1) || (vType(tvc) == VDIR))
  		    osi_dnlc_purgedp(tvc);
  	    }
  	}
--- 240,247 ----
  		QRemove(tq);
  		tq->prev = tq->next = NULL;
  		tvc->states &= ~(CStatd | CMValid | CUnique);
!                 if (!(tvc->states & CVInit) &&
!                     (tvc->fid.Fid.Vnode & 1 || (vType(tvc) == VDIR)))
  		    osi_dnlc_purgedp(tvc);
  	    }
  	}
***************
*** 309,317 ****
  	    tvc->callback = 0;
  	    tvc->dchint = NULL;	/* invalidate hints */
  	    tvc->states &= ~(CStatd);
- 	    if ((tvc->fid.Fid.Vnode & 1) || (vType(tvc) == VDIR))
- 		osi_dnlc_purgedp(tvc);
  	    tvc->callsort.prev = tvc->callsort.next = NULL;
  	}
  
      afs_InitCBQueue(0);
--- 311,320 ----
  	    tvc->callback = 0;
  	    tvc->dchint = NULL;	/* invalidate hints */
  	    tvc->states &= ~(CStatd);
  	    tvc->callsort.prev = tvc->callsort.next = NULL;
+ 	    if (!(tvc->states & CVInit) &&
+                 ((tvc->fid.Fid.Vnode & 1) || (vType(tvc) == VDIR)))
+ 		osi_dnlc_purgedp(tvc);
  	}
  
      afs_InitCBQueue(0);
***************
*** 338,344 ****
  		tvc->callback = 0;
  		tvc->dchint = NULL;	/* invalidate hints */
  		tvc->states &= ~(CStatd);
! 		if ((tvc->fid.Fid.Vnode & 1) || (vType(tvc) == VDIR)) {
  		    osi_dnlc_purgedp(tvc);
  		}
  		afs_DequeueCallback(tvc);
--- 341,348 ----
  		tvc->callback = 0;
  		tvc->dchint = NULL;	/* invalidate hints */
  		tvc->states &= ~(CStatd);
! 		if (!(tvc->states & CVInit) &&
!                     ((tvc->fid.Fid.Vnode & 1) || (vType(tvc) == VDIR))) {
  		    osi_dnlc_purgedp(tvc);
  		}
  		afs_DequeueCallback(tvc);
Index: openafs/src/afs/afs_chunk.c
diff -c openafs/src/afs/afs_chunk.c:1.6 openafs/src/afs/afs_chunk.c:1.6.2.1
*** openafs/src/afs/afs_chunk.c:1.6	Tue Jul 15 19:14:11 2003
--- openafs/src/afs/afs_chunk.c	Thu Oct 13 14:46:04 2005
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_chunk.c,v 1.6 2003/07/15 23:14:11 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_chunk.c,v 1.6.2.1 2005/10/13 18:46:04 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
***************
*** 22,113 ****
   * Chunk module.
   */
  
! afs_int32 afs_FirstCSize = AFS_DEFAULTCSIZE;
! afs_int32 afs_OtherCSize = AFS_DEFAULTCSIZE;
! afs_int32 afs_LogChunk = AFS_DEFAULTLSIZE;
! 
! #ifdef notdef
! int
! afs_ChunkOffset(offset)
!      afs_int32 offset;
! {
! 
!     AFS_STATCNT(afs_ChunkOffset);
!     if (offset < afs_FirstCSize)
! 	return offset;
!     else
! 	return ((offset - afs_FirstCSize) & (afs_OtherCSize - 1));
! }
! 
! 
! int
! afs_Chunk(offset)
!      afs_int32 offset;
! {
!     AFS_STATCNT(afs_Chunk);
!     if (offset < afs_FirstCSize)
! 	return 0;
!     else
! 	return (((offset - afs_FirstCSize) >> afs_LogChunk) + 1);
! }
! 
! 
! int
! afs_ChunkBase(offset)
!      int offset;
! {
!     AFS_STATCNT(afs_ChunkBase);
!     if (offset < afs_FirstCSize)
! 	return 0;
!     else
! 	return (((offset - afs_FirstCSize) & ~(afs_OtherCSize - 1)) +
! 		afs_FirstCSize);
! }
! 
! 
! int
! afs_ChunkSize(offset)
!      afs_int32 offset;
! {
!     AFS_STATCNT(afs_ChunkSize);
!     if (offset < afs_FirstCSize)
! 	return afs_FirstCSize;
!     else
! 	return afs_OtherCSize;
! }
! 
! 
! int
! afs_ChunkToBase(chunk)
!      afs_int32 chunk;
! {
!     AFS_STATCNT(afs_ChunkToBase);
!     if (chunk == 0)
! 	return 0;
!     else
! 	return (afs_FirstCSize + ((chunk - 1) << afs_LogChunk));
! }
! 
! 
! int
! afs_ChunkToSize(chunk)
!      afs_int32 chunk;
! {
!     AFS_STATCNT(afs_ChunkToSize);
!     if (chunk == 0)
! 	return afs_FirstCSize;
!     else
! 	return afs_OtherCSize;
! }
! 
! /* sizes are a power of two */
! int
! afs_SetChunkSize(chunk)
!      afs_int32 chunk;
! {
!     AFS_STATCNT(afs_SetChunkSize);
!     afs_LogChunk = chunk;
!     afs_FirstCSize = afs_OtherCSize = (1 << chunk);
! }
! 
! #endif /* notdef */
--- 22,29 ----
   * Chunk module.
   */
  
! /* Place the defaults in afsd instead of all around the code, so
!  * AFS_SETCHUNKSIZE() needs to be called before doing anything */
! afs_int32 afs_FirstCSize = 0;
! afs_int32 afs_OtherCSize = 0;
! afs_int32 afs_LogChunk = 0;
Index: openafs/src/afs/afs_chunkops.h
diff -c openafs/src/afs/afs_chunkops.h:1.6 openafs/src/afs/afs_chunkops.h:1.6.2.1
*** openafs/src/afs/afs_chunkops.h:1.6	Tue Jul 15 19:14:11 2003
--- openafs/src/afs/afs_chunkops.h	Thu Oct 13 14:46:04 2005
***************
*** 18,30 ****
        Chunks are 0 based and go up by exactly 1, covering the file.
        The other fields are internal and shouldn't be used */
  /* basic parameters */
- #ifdef AFS_NOCHUNKING
- 
- #define	AFS_OTHERCSIZE	0x10000
- #define	AFS_LOGCHUNK	16
- #define	AFS_FIRSTCSIZE	0x40000000
- 
- #else /* AFS_NOCHUNKING */
  
  #define AFS_OTHERCSIZE  (afs_OtherCSize)
  #define AFS_LOGCHUNK    (afs_LogChunk)
--- 18,23 ----
***************
*** 33,43 ****
  #define AFS_DEFAULTCSIZE 0x10000
  #define AFS_DEFAULTLSIZE 16
  
- #endif /* AFS_NOCHUNKING */
- 
- #define AFS_MINCHUNK 13		/* 8k is minimum */
- #define AFS_MAXCHUNK 18		/* 256K is maximum */
- 
  #define AFS_CHUNKOFFSET(offset) ((offset < afs_FirstCSize) ? offset : \
  			 ((offset - afs_FirstCSize) & (afs_OtherCSize - 1)))
  
--- 26,31 ----
Index: openafs/src/afs/afs_daemons.c
diff -c openafs/src/afs/afs_daemons.c:1.28.2.7 openafs/src/afs/afs_daemons.c:1.28.2.9
*** openafs/src/afs/afs_daemons.c:1.28.2.7	Wed Sep  7 13:43:25 2005
--- openafs/src/afs/afs_daemons.c	Sat Oct 15 10:24:24 2005
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_daemons.c,v 1.28.2.7 2005/09/07 17:43:25 shadow Exp $");
  
  #ifdef AFS_AIX51_ENV
  #define __FULL_PROTO
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_daemons.c,v 1.28.2.9 2005/10/15 14:24:24 shadow Exp $");
  
  #ifdef AFS_AIX51_ENV
  #define __FULL_PROTO
***************
*** 103,109 ****
      }
      afs_CheckServerDaemonStarted = 0;
  }
! 
  void
  afs_Daemon(void)
  {
--- 103,114 ----
      }
      afs_CheckServerDaemonStarted = 0;
  }
! #define RECURSIVE_VFS_CONTEXT 1
! #if RECURSIVE_VFS_CONTEXT
! extern int vfs_context_ref;
! #else
! #define vfs_context_ref 1
! #endif
  void
  afs_Daemon(void)
  {
***************
*** 123,128 ****
--- 128,145 ----
      while (afs_initState < 101)
  	afs_osi_Sleep(&afs_initState);
  
+ #ifdef AFS_DARWIN80_ENV
+     if (afs_osi_ctxtp_initialized)
+         osi_Panic("vfs context already initialized");
+     while (afs_osi_ctxtp && vfs_context_ref)
+         afs_osi_Sleep(&afs_osi_ctxtp);
+ #if RECURSIVE_VFS_CONTEXT
+     if (afs_osi_ctxtp && !vfs_context_ref)
+        vfs_context_rele(afs_osi_ctxtp);
+ #endif
+     afs_osi_ctxtp = vfs_context_create(NULL);
+     afs_osi_ctxtp_initialized = 1;
+ #endif
      now = osi_Time();
      lastCBSlotBump = now;
  
***************
*** 302,307 ****
--- 319,325 ----
  	    afs_rootFid.Cell = localcell;
  	    if (afs_rootFid.Fid.Volume && afs_rootFid.Fid.Volume != volid
  		&& afs_globalVp) {
+ 		struct vcache *tvc = afs_globalVp;
  		/* If we had a root fid before and it changed location we reset
  		 * the afs_globalVp so that it will be reevaluated.
  		 * Just decrement the reference count. This only occurs during
***************
*** 355,361 ****
--- 373,383 ----
  		    crfree(credp);
  		}
  #else
+ #ifdef AFS_DARWIN80_ENV
+ 		afs_PutVCache(afs_globalVp);
+ #else
  		AFS_FAST_RELE(afs_globalVp);
+ #endif
  		afs_globalVp = 0;
  #endif
  	    }
***************
*** 595,601 ****
      }
  }
  
- #ifdef	AFS_AIX32_ENV
  #ifdef AFS_AIX41_ENV
  /* AIX 4.1 has a much different sleep/wakeup mechanism available for use. 
   * The modifications here will work for either a UP or MP machine.
--- 617,622 ----
***************
*** 619,627 ****
   * This function obtains, and returns, a pointer to a buffer for
   * processing by a daemon.  It sleeps until such a buffer is available.
   * The source of buffers for it is the list afs_asyncbuf (see also 
!  * naix_vm_strategy).  This function may be invoked concurrently by
   * several processes, that is, several instances of the same daemon.
!  * naix_vm_strategy, which adds buffers to the list, runs at interrupt
   * level, while get_bioreq runs at process level.
   *
   * Since AIX 4.1 can wake just one process at a time, the separate sleep
--- 640,648 ----
   * This function obtains, and returns, a pointer to a buffer for
   * processing by a daemon.  It sleeps until such a buffer is available.
   * The source of buffers for it is the list afs_asyncbuf (see also 
!  * afs_gn_strategy).  This function may be invoked concurrently by
   * several processes, that is, several instances of the same daemon.
!  * afs_gn_strategy, which adds buffers to the list, runs at interrupt
   * level, while get_bioreq runs at process level.
   *
   * Since AIX 4.1 can wake just one process at a time, the separate sleep
***************
*** 631,637 ****
   * process and interrupts.
   */
  Simple_lock afs_asyncbuf_lock;
! /*static*/ struct buf *
  afs_get_bioreq()
  {
      struct buf *bp = NULL;
--- 652,658 ----
   * process and interrupts.
   */
  Simple_lock afs_asyncbuf_lock;
! struct buf *
  afs_get_bioreq()
  {
      struct buf *bp = NULL;
***************
*** 847,853 ****
  
  	/*
  	 * buffer may be linked with other buffers via the b_work field.
! 	 * See also naix_vm_strategy.  For each buffer in the chain (including
  	 * bp) notify all users of the buffer that the daemon is finished
  	 * using it by calling iodone.  
  	 * assumes iodone can modify the b_work field.
--- 868,874 ----
  
  	/*
  	 * buffer may be linked with other buffers via the b_work field.
! 	 * See also afs_gn_strategy.  For each buffer in the chain (including
  	 * bp) notify all users of the buffer that the daemon is finished
  	 * using it by calling iodone.  
  	 * assumes iodone can modify the b_work field.
***************
*** 869,1223 ****
      }				/* infinite loop (unless we're interrupted) */
  }				/* end of afs_BioDaemon() */
  
- #else /* AFS_AIX41_ENV */
- 
- 
- #define	squeue afs_q
- struct afs_bioqueue {
-     struct squeue lruq;
-     int sleeper;
-     int cnt;
- };
- struct afs_bioqueue afs_bioqueue;
- struct buf *afs_busyq = NULL;
- struct buf *afs_asyncbuf;
- afs_int32 afs_biodcnt = 0;
- 
- /* in implementing this, I assumed that all external linked lists were
-  * null-terminated.  
-  *
-  * Several places in this code traverse a linked list.  The algorithm
-  * used here is probably unfamiliar to most people.  Careful examination
-  * will show that it eliminates an assignment inside the loop, as compared
-  * to the standard algorithm, at the cost of occasionally using an extra
-  * variable.
-  */
- 
- /* get_bioreq()
-  *
-  * This function obtains, and returns, a pointer to a buffer for
-  * processing by a daemon.  It sleeps until such a buffer is available.
-  * The source of buffers for it is the list afs_asyncbuf (see also 
-  * naix_vm_strategy).  This function may be invoked concurrently by
-  * several processes, that is, several instances of the same daemon.
-  * naix_vm_strategy, which adds buffers to the list, runs at interrupt
-  * level, while get_bioreq runs at process level.
-  *
-  * The common kernel paradigm of sleeping and waking up, in which all the
-  * competing processes sleep waiting for wakeups on one address, is not
-  * followed here.  Instead, the following paradigm is used:  when a daemon
-  * goes to sleep, it checks for other sleeping daemons.  If there aren't any,
-  * it sleeps on the address of variable afs_asyncbuf.  But if there is
-  * already a daemon sleeping on that address, it threads its own unique
-  * address onto a list, and sleeps on that address.  This way, every 
-  * sleeper is sleeping on a different address, and every wakeup wakes up
-  * exactly one daemon.  This prevents a whole bunch of daemons from waking
-  * up and then immediately having to go back to sleep.  This provides a
-  * performance gain and makes the I/O scheduling a bit more deterministic.
-  * The list of sleepers is variable afs_bioqueue.  The unique address
-  * on which to sleep is passed to get_bioreq as its parameter.
-  */
- /*static*/ struct buf *
- afs_get_bioreq(self)
-      struct afs_bioqueue *self;	/* address on which to sleep */
- 
- {
-     struct buf *bp = NULL;
-     struct buf *bestbp;
-     struct buf **bestlbpP, **lbpP;
-     int bestage, stop;
-     struct buf *t1P, *t2P;	/* temp pointers for list manipulation */
-     int oldPriority;
-     afs_uint32 wait_ret;
-     struct afs_bioqueue *s;
- 
-     /* ??? Does the forward pointer of the returned buffer need to be NULL?
-      */
- 
-     /* Disable interrupts from the strategy function, and save the 
-      * prior priority level
-      */
-     oldPriority = i_disable(INTMAX);
- 
-     /* Each iteration of following loop either pulls
-      * a buffer off afs_asyncbuf, or sleeps.  
-      */
-     while (1) {			/* inner loop */
- 	if (afs_asyncbuf) {
- 	    /* look for oldest buffer */
- 	    bp = bestbp = afs_asyncbuf;
- 	    bestage = (int)bestbp->av_back;
- 	    bestlbpP = &afs_asyncbuf;
- 	    while (1) {
- 		lbpP = &bp->av_forw;
- 		bp = *lbpP;
- 		if (!bp)
- 		    break;
- 		if ((int)bp->av_back - bestage < 0) {
- 		    bestbp = bp;
- 		    bestlbpP = lbpP;
- 		    bestage = (int)bp->av_back;
- 		}
- 	    }
- 	    bp = bestbp;
- 	    *bestlbpP = bp->av_forw;
- 	    break;
- 	} else {
- 	    int interrupted;
- 
- 	    /* If afs_asyncbuf is null, it is necessary to go to sleep.
- 	     * There are two possibilities:  either there is already a
- 	     * daemon that is sleeping on the address of afs_asyncbuf,
- 	     * or there isn't. 
- 	     */
- 	    if (afs_bioqueue.sleeper) {
- 		/* enqueue */
- 		QAdd(&(afs_bioqueue.lruq), &(self->lruq));
- 		interrupted = sleep((caddr_t) self, PCATCH | (PZERO + 1));
- 		if (self->lruq.next != &self->lruq) {	/* XXX ##3 XXX */
- 		    QRemove(&(self->lruq));	/* dequeue */
- 		}
- 		self->cnt++;
- 		afs_bioqueue.sleeper = FALSE;
- 		if (interrupted) {
- 		    /* re-enable interrupts from strategy */
- 		    i_enable(oldPriority);
- 		    return (NULL);
- 		}
- 		continue;
- 	    } else {
- 		afs_bioqueue.sleeper = TRUE;
- 		interrupted =
- 		    sleep((caddr_t) & afs_asyncbuf, PCATCH | (PZERO + 1));
- 		afs_bioqueue.sleeper = FALSE;
- 		if (interrupted) {
- 		    /*
- 		     * We need to wakeup another daemon if present
- 		     * since we were waiting on afs_asyncbuf.
- 		     */
- #ifdef	notdef			/* The following doesn't work as advertised */
- 		    if (afs_bioqueue.lruq.next != &afs_bioqueue.lruq) {
- 			struct squeue *bq = afs_bioqueue.lruq.next;
- 			QRemove(bq);
- 			wakeup(bq);
- 		    }
- #endif
- 		    /* re-enable interrupts from strategy */
- 		    i_enable(oldPriority);
- 		    return (NULL);
- 		}
- 		continue;
- 	    }
- 
- 	}			/* end of "else asyncbuf is empty" */
-     }				/* end of "inner loop" */
- 
-     /*assert (bp); */
- 
-     i_enable(oldPriority);	/* re-enable interrupts from strategy */
- 
-     /* For the convenience of other code, replace the gnodes in
-      * the b_vp field of bp and the other buffers on the b_work
-      * chain with the corresponding vnodes.   
-      *
-      * ??? what happens to the gnodes?  They're not just cut loose,
-      * are they?
-      */
-     for (t1P = bp;;) {
- 	t2P = (struct buf *)t1P->b_work;
- 	t1P->b_vp = ((struct gnode *)t1P->b_vp)->gn_vnode;
- 	if (!t2P)
- 	    break;
- 
- 	t1P = (struct buf *)t2P->b_work;
- 	t2P->b_vp = ((struct gnode *)t2P->b_vp)->gn_vnode;
- 	if (!t1P)
- 	    break;
-     }
- 
-     /* If the buffer does not specify I/O, it may immediately
-      * be returned to the caller.  This condition is detected
-      * by examining the buffer's flags (the b_flags field).  If
-      * the B_PFPROT bit is set, the buffer represents a protection
-      * violation, rather than a request for I/O.  The remainder
-      * of the outer loop handles the case where the B_PFPROT bit is clear.
-      */
-     if (bp->b_flags & B_PFPROT) {
- 	return (bp);
-     }
- 
-     /* wake up another process to handle the next buffer, and return
-      * bp to the caller.
-      */
-     oldPriority = i_disable(INTMAX);
- 
-     /* determine where to find the sleeping process. 
-      * There are two cases: either it is sleeping on
-      * afs_asyncbuf, or it is sleeping on its own unique
-      * address.  These cases are distinguished by examining
-      * the sleeper field of afs_bioqueue.
-      */
-     if (afs_bioqueue.sleeper) {
- 	wakeup(&afs_asyncbuf);
-     } else {
- 	if (afs_bioqueue.lruq.next == &afs_bioqueue.lruq) {
- 	    /* queue is empty, what now? ??? */
- 	    /* Should this be impossible, or does    */
- 	    /* it just mean that nobody is sleeping? */ ;
- 	} else {
- 	    struct squeue *bq = afs_bioqueue.lruq.next;
- 	    QRemove(bq);
- 	    QInit(bq);
- 	    wakeup(bq);
- 	    afs_bioqueue.sleeper = TRUE;
- 	}
-     }
-     i_enable(oldPriority);	/* re-enable interrupts from strategy */
-     return (bp);
- 
- }				/* end of function get_bioreq() */
- 
- 
- /* afs_BioDaemon
-  *
-  * This function is the daemon.  It is called from the syscall
-  * interface.  Ordinarily, a script or an administrator will run a
-  * daemon startup utility, specifying the number of I/O daemons to
-  * run.  The utility will fork off that number of processes,
-  * each making the appropriate syscall, which will cause this
-  * function to be invoked.
-  */
- static int afs_initbiod = 0;	/* this is self-initializing code */
- int DOvmlock = 0;
- afs_BioDaemon(nbiods)
-      afs_int32 nbiods;
- {
-     struct afs_bioqueue *self;
-     afs_int32 code, s, pflg = 0;
-     label_t jmpbuf;
-     struct buf *bp, *bp1, *tbp1, *tbp2;	/* temp pointers only */
-     caddr_t tmpaddr;
-     struct vnode *vp;
-     struct vcache *vcp;
-     char tmperr;
-     if (!afs_initbiod) {
- 	/* XXX ###1 XXX */
- 	afs_initbiod = 1;
- 	/* Initialize the queue of waiting processes, afs_bioqueue.  */
- 	QInit(&(afs_bioqueue.lruq));
-     }
- 
-     /* establish ourself as a kernel process so shutdown won't kill us */
- /*    u.u_procp->p_flag |= SKPROC;*/
- 
-     /* Initialize a token (self) to use in the queue of sleeping processes.   */
-     self = (struct afs_bioqueue *)afs_osi_Alloc(sizeof(struct afs_bioqueue));
-     pin(self, sizeof(struct afs_bioqueue));	/* fix in memory */
-     memset(self, 0, sizeof(*self));
-     QInit(&(self->lruq));	/* initialize queue entry pointers */
- 
- 
-     /* Ignore HUP signals... */
-     SIGDELSET(u.u_procp->p_sig, SIGHUP);
-     SIGADDSET(u.u_procp->p_sigignore, SIGHUP);
-     SIGDELSET(u.u_procp->p_sigcatch, SIGHUP);
-     /* Main body starts here -- this is an intentional infinite loop, and
-      * should NEVER exit 
-      *
-      * Now, the loop will exit if get_bioreq() returns NULL, indicating 
-      * that we've been interrupted.
-      */
-     while (1) {
- 	bp = afs_get_bioreq(self);
- 	if (!bp)
- 	    break;		/* we were interrupted */
- 	if (code = setjmpx(&jmpbuf)) {
- 	    /* This should not have happend, maybe a lack of resources  */
- 	    s = splimp();
- 	    for (bp1 = bp; bp; bp = bp1) {
- 		if (bp1)
- 		    bp1 = bp1->b_work;
- 		bp->b_actf = 0;
- 		bp->b_error = code;
- 		bp->b_flags |= B_ERROR;
- 		iodone(bp);
- 	    }
- 	    splx(s);
- 	    continue;
- 	}
- 	vcp = VTOAFS(bp->b_vp);
- 	if (bp->b_flags & B_PFSTORE) {
- 	    ObtainWriteLock(&vcp->lock, 210);
- 	    if (vcp->v.v_gnode->gn_mwrcnt) {
- 		afs_offs_t newlength =
- 		    (afs_offs_t) dbtob(bp->b_blkno) + bp->b_bcount;
- 		if (vcp->m.Length < newlength) {
- 		    afs_Trace4(afs_iclSetp, CM_TRACE_SETLENGTH,
- 			       ICL_TYPE_STRING, __FILE__, ICL_TYPE_LONG,
- 			       __LINE__, ICL_TYPE_OFFSET,
- 			       ICL_HANDLE_OFFSET(vcp->m.Length),
- 			       ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(newlength));
- 		    vcp->m.Length = newlength;
- 		}
- 	    }
- 	    ReleaseWriteLock(&vcp->lock);
- 	}
- 	/* If the buffer represents a protection violation, rather than
- 	 * an actual request for I/O, no special action need be taken.  
- 	 */
- 	if (bp->b_flags & B_PFPROT) {
- 	    iodone(bp);		/* Notify all users of the buffer that we're done */
- 	    continue;
- 	}
- 	if (DOvmlock)
- 	    ObtainWriteLock(&vcp->pvmlock, 558);
- 	/*
- 	 * First map its data area to a region in the current address space
- 	 * by calling vm_att with the subspace identifier, and a pointer to
- 	 * the data area.  vm_att returns  a new data area pointer, but we
- 	 * also want to hang onto the old one.
- 	 */
- 	tmpaddr = bp->b_baddr;
- 	bp->b_baddr = vm_att(bp->b_xmemd.subspace_id, tmpaddr);
- 	tmperr = afs_ustrategy(bp);	/* temp variable saves offset calculation */
- 	if (tmperr) {		/* in non-error case */
- 	    bp->b_flags |= B_ERROR;	/* should other flags remain set ??? */
- 	    bp->b_error = tmperr;
- 	}
- 
- 	/* Unmap the buffer's data area by calling vm_det.  Reset data area
- 	 * to the value that we saved above.
- 	 */
- 	vm_det(bp->b_un.b_addr);
- 	bp->b_baddr = tmpaddr;
- 
- 	/*
- 	 * buffer may be linked with other buffers via the b_work field.
- 	 * See also naix_vm_strategy.  For each buffer in the chain (including
- 	 * bp) notify all users of the buffer that the daemon is finished
- 	 * using it by calling iodone.  
- 	 * assumes iodone can modify the b_work field.
- 	 */
- 	for (tbp1 = bp;;) {
- 	    tbp2 = (struct buf *)tbp1->b_work;
- 	    iodone(tbp1);
- 	    if (!tbp2)
- 		break;
- 
- 	    tbp1 = (struct buf *)tbp2->b_work;
- 	    iodone(tbp2);
- 	    if (!tbp1)
- 		break;
- 	}
- 	if (DOvmlock)
- 	    ReleaseWriteLock(&vcp->pvmlock);	/* Unlock the vnode.  */
- 	clrjmpx(&jmpbuf);
-     }				/* infinite loop (unless we're interrupted) */
-     unpin(self, sizeof(struct afs_bioqueue));
-     afs_osi_Free(self, sizeof(struct afs_bioqueue));
- }				/* end of afs_BioDaemon() */
  #endif /* AFS_AIX41_ENV */
- #endif /* AFS_AIX32_ENV */
  
  
  int afs_nbrs = 0;
--- 890,896 ----
***************
*** 1319,1334 ****
  	memset((char *)afs_brs, 0, sizeof(afs_brs));
  	memset((char *)&afs_xbrs, 0, sizeof(afs_lock_t));
  	afs_brsWaiters = 0;
- #ifdef AFS_AIX32_ENV
  #ifdef AFS_AIX41_ENV
  	lock_free(&afs_asyncbuf_lock);
  	unpin(&afs_asyncbuf, sizeof(struct buf *));
  	unpin(&afs_asyncbuf_cv, sizeof(afs_int32));
- #else /* AFS_AIX41_ENV */
- 	afs_busyq = NULL;
- 	afs_biodcnt = 0;
- 	memset((char *)&afs_bioqueue, 0, sizeof(struct afs_bioqueue));
- #endif
  	afs_initbiod = 0;
  #endif
      }
--- 992,1001 ----
Index: openafs/src/afs/afs_dcache.c
diff -c openafs/src/afs/afs_dcache.c:1.42.2.16 openafs/src/afs/afs_dcache.c:1.42.2.19
*** openafs/src/afs/afs_dcache.c:1.42.2.16	Thu Aug  4 16:45:14 2005
--- openafs/src/afs/afs_dcache.c	Thu Oct 13 14:42:27 2005
***************
*** 14,20 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_dcache.c,v 1.42.2.16 2005/08/04 20:45:14 shadow Exp $");
  
  #include "afs/sysincludes.h"	/*Standard vendor system headers */
  #include "afsincludes.h"	/*AFS-based standard headers */
--- 14,20 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_dcache.c,v 1.42.2.19 2005/10/13 18:42:27 shadow Exp $");
  
  #include "afs/sysincludes.h"	/*Standard vendor system headers */
  #include "afsincludes.h"	/*AFS-based standard headers */
***************
*** 223,238 ****
      u_int counter;
      u_int cb_lowat;
      u_int dc_hiwat =
! 	(100 - CM_DCACHECOUNTFREEPCT +
! 	 CM_DCACHEEXTRAPCT) * afs_cacheFiles / 100;
      afs_min_cache =
  	(((10 * AFS_CHUNKSIZE(0)) + afs_fsfragsize) & ~afs_fsfragsize) >> 10;
  
      osi_GetuTime(&CTD_stats.CTD_afterSleep);
      afs_TruncateDaemonRunning = 1;
      while (1) {
! 	cb_lowat = ((CM_DCACHESPACEFREEPCT - CM_DCACHEEXTRAPCT)
! 		    * afs_cacheBlocks) / 100;
  	MObtainWriteLock(&afs_xdcache, 266);
  	if (afs_CacheTooFull) {
  	    int space_needed, slots_needed;
--- 223,236 ----
      u_int counter;
      u_int cb_lowat;
      u_int dc_hiwat =
! 	PERCENT((100 - CM_DCACHECOUNTFREEPCT + CM_DCACHEEXTRAPCT), afs_cacheFiles);
      afs_min_cache =
  	(((10 * AFS_CHUNKSIZE(0)) + afs_fsfragsize) & ~afs_fsfragsize) >> 10;
  
      osi_GetuTime(&CTD_stats.CTD_afterSleep);
      afs_TruncateDaemonRunning = 1;
      while (1) {
! 	cb_lowat = PERCENT((CM_DCACHESPACEFREEPCT - CM_DCACHEEXTRAPCT), afs_cacheBlocks);
  	MObtainWriteLock(&afs_xdcache, 266);
  	if (afs_CacheTooFull) {
  	    int space_needed, slots_needed;
***************
*** 583,589 ****
  			MReleaseWriteLock(&afs_xdcache);
  		    }
  
! 		    AFS_FAST_RELE(tvc);
  		    MObtainWriteLock(&afs_xdcache, 528);
  		    if (afs_indexFlags[tdc->index] &
  			(IFDataMod | IFDirtyPages | IFAnyPages))
--- 581,587 ----
  			MReleaseWriteLock(&afs_xdcache);
  		    }
  
! 		    afs_PutVCache(tvc); /*XXX was AFS_FAST_RELE?*/
  		    MObtainWriteLock(&afs_xdcache, 528);
  		    if (afs_indexFlags[tdc->index] &
  			(IFDataMod | IFDirtyPages | IFAnyPages))
***************
*** 777,783 ****
  
      if (afs_WaitForCacheDrain) {
  	if (afs_blocksUsed <=
! 	    (CM_CACHESIZEDRAINEDPCT * afs_cacheBlocks) / 100) {
  	    afs_WaitForCacheDrain = 0;
  	    afs_osi_Wakeup(&afs_WaitForCacheDrain);
  	}
--- 775,781 ----
  
      if (afs_WaitForCacheDrain) {
  	if (afs_blocksUsed <=
! 	    PERCENT(CM_CACHESIZEDRAINEDPCT, afs_cacheBlocks)) {
  	    afs_WaitForCacheDrain = 0;
  	    afs_osi_Wakeup(&afs_WaitForCacheDrain);
  	}
***************
*** 810,816 ****
  
      if (afs_WaitForCacheDrain) {
  	if ((afs_blocksUsed - afs_blocksDiscarded) <=
! 	    (CM_CACHESIZEDRAINEDPCT * afs_cacheBlocks) / 100) {
  	    afs_WaitForCacheDrain = 0;
  	    afs_osi_Wakeup(&afs_WaitForCacheDrain);
  	}
--- 808,814 ----
  
      if (afs_WaitForCacheDrain) {
  	if ((afs_blocksUsed - afs_blocksDiscarded) <=
! 	    PERCENT(CM_CACHESIZEDRAINEDPCT, afs_cacheBlocks)) {
  	    afs_WaitForCacheDrain = 0;
  	    afs_osi_Wakeup(&afs_WaitForCacheDrain);
  	}
***************
*** 860,866 ****
  
      if (afs_WaitForCacheDrain) {
  	if ((afs_blocksUsed - afs_blocksDiscarded) <=
! 	    (CM_CACHESIZEDRAINEDPCT * afs_cacheBlocks) / 100) {
  	    afs_WaitForCacheDrain = 0;
  	    afs_osi_Wakeup(&afs_WaitForCacheDrain);
  	}
--- 858,864 ----
  
      if (afs_WaitForCacheDrain) {
  	if ((afs_blocksUsed - afs_blocksDiscarded) <=
! 	    PERCENT(CM_CACHESIZEDRAINEDPCT, afs_cacheBlocks)) {
  	    afs_WaitForCacheDrain = 0;
  	    afs_osi_Wakeup(&afs_WaitForCacheDrain);
  	}
***************
*** 943,949 ****
  
      while (afs_blocksDiscarded
  	   && (afs_blocksUsed >
! 	       (CM_WAITFORDRAINPCT * afs_cacheBlocks) / 100)) {
  	afs_FreeDiscardedDCache();
      }
      return 0;
--- 941,947 ----
  
      while (afs_blocksDiscarded
  	   && (afs_blocksUsed >
! 	       PERCENT(CM_WAITFORDRAINPCT, afs_cacheBlocks))) {
  	afs_FreeDiscardedDCache();
      }
      return 0;
***************
*** 1967,1973 ****
  	/* Sleep here when cache needs to be drained. */
  	if (setLocks && !slowPass
  	    && (afs_blocksUsed >
! 		(CM_WAITFORDRAINPCT * afs_cacheBlocks) / 100)) {
  	    /* Make sure truncate daemon is running */
  	    afs_MaybeWakeupTruncateDaemon();
  	    ObtainWriteLock(&tdc->tlock, 614);
--- 1965,1971 ----
  	/* Sleep here when cache needs to be drained. */
  	if (setLocks && !slowPass
  	    && (afs_blocksUsed >
! 		PERCENT(CM_WAITFORDRAINPCT, afs_cacheBlocks))) {
  	    /* Make sure truncate daemon is running */
  	    afs_MaybeWakeupTruncateDaemon();
  	    ObtainWriteLock(&tdc->tlock, 614);
***************
*** 1976,1982 ****
  	    ReleaseWriteLock(&tdc->lock);
  	    ReleaseReadLock(&avc->lock);
  	    while ((afs_blocksUsed - afs_blocksDiscarded) >
! 		   (CM_WAITFORDRAINPCT * afs_cacheBlocks) / 100) {
  		afs_WaitForCacheDrain = 1;
  		afs_osi_Sleep(&afs_WaitForCacheDrain);
  	    }
--- 1974,1980 ----
  	    ReleaseWriteLock(&tdc->lock);
  	    ReleaseReadLock(&avc->lock);
  	    while ((afs_blocksUsed - afs_blocksDiscarded) >
! 		   PERCENT(CM_WAITFORDRAINPCT, afs_cacheBlocks)) {
  		afs_WaitForCacheDrain = 1;
  		afs_osi_Sleep(&afs_WaitForCacheDrain);
  	    }
Index: openafs/src/afs/afs_init.c
diff -c openafs/src/afs/afs_init.c:1.28.2.4 openafs/src/afs/afs_init.c:1.28.2.5
*** openafs/src/afs/afs_init.c:1.28.2.4	Sun Apr  3 14:18:54 2005
--- openafs/src/afs/afs_init.c	Wed Oct  5 01:58:27 2005
***************
*** 17,23 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_init.c,v 1.28.2.4 2005/04/03 18:18:54 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
--- 17,23 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_init.c,v 1.28.2.5 2005/10/05 05:58:27 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
***************
*** 352,357 ****
--- 352,359 ----
  	struct statvfs st;
  #elif defined(AFS_DUX40_ENV)
  	struct nstatfs st;
+ #elif defined(AFS_DARWIN80_ENV)
+ 	struct vfsstatfs st;
  #else
  	struct statfs st;
  #endif /* SUN56 */
***************
*** 381,386 ****
--- 383,391 ----
  	    VFS_STATFS(filevp->v_vfsp, &st);
  	    TO_KERNEL_SPACE();
  	}
+ #elif defined(AFS_DARWIN80_ENV)
+         afs_cacheVfsp = vnode_mount(filevp);
+ 	if (afs_cacheVfsp && ((st = *(vfs_statfs(afs_cacheVfsp))),1))
  #elif defined(AFS_DARWIN_ENV)
  	if (!VFS_STATFS(filevp->v_mount, &st, current_proc()))
  #elif defined(AFS_FBSD50_ENV)
***************
*** 413,419 ****
--- 418,426 ----
  #endif
      cacheInode = afs_vnodeToInumber(filevp);
      cacheDev.dev = afs_vnodeToDev(filevp);
+ #ifndef AFS_DARWIN80_ENV
      afs_cacheVfsp = filevp->v_vfsp;
+ #endif
  #endif /* AFS_LINUX20_ENV */
      AFS_RELE(filevp);
  #endif /* AFS_LINUX22_ENV */
Index: openafs/src/afs/afs_memcache.c
diff -c openafs/src/afs/afs_memcache.c:1.15.2.4 openafs/src/afs/afs_memcache.c:1.15.2.5
*** openafs/src/afs/afs_memcache.c:1.15.2.4	Mon May 30 00:36:58 2005
--- openafs/src/afs/afs_memcache.c	Wed Oct  5 01:58:27 2005
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_memcache.c,v 1.15.2.4 2005/05/30 04:36:58 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #ifndef AFS_LINUX22_ENV
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_memcache.c,v 1.15.2.5 2005/10/05 05:58:27 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #ifndef AFS_LINUX22_ENV
***************
*** 180,192 ****
  {
      register struct memCacheEntry *mceP =
  	(struct memCacheEntry *)afs_MemCacheOpen(blkno);
!     int length = mceP->size - uioP->uio_offset;
      afs_int32 code;
  
      AFS_STATCNT(afs_MemReadUIO);
      MObtainReadLock(&mceP->afs_memLock);
!     length = (length < uioP->uio_resid) ? length : uioP->uio_resid;
!     AFS_UIOMOVE(mceP->data + uioP->uio_offset, length, UIO_READ, uioP, code);
      MReleaseReadLock(&mceP->afs_memLock);
      return code;
  }
--- 180,192 ----
  {
      register struct memCacheEntry *mceP =
  	(struct memCacheEntry *)afs_MemCacheOpen(blkno);
!     int length = mceP->size - AFS_UIO_OFFSET(uioP);
      afs_int32 code;
  
      AFS_STATCNT(afs_MemReadUIO);
      MObtainReadLock(&mceP->afs_memLock);
!     length = (length < AFS_UIO_RESID(uioP)) ? length : AFS_UIO_RESID(uioP);
!     AFS_UIOMOVE(mceP->data + AFS_UIO_OFFSET(uioP), length, UIO_READ, uioP, code);
      MReleaseReadLock(&mceP->afs_memLock);
      return code;
  }
***************
*** 281,305 ****
  
      AFS_STATCNT(afs_MemWriteUIO);
      MObtainWriteLock(&mceP->afs_memLock, 312);
!     if (uioP->uio_resid + uioP->uio_offset > mceP->dataSize) {
  	char *oldData = mceP->data;
  
! 	mceP->data = afs_osi_Alloc(uioP->uio_resid + uioP->uio_offset);
  
  	AFS_GUNLOCK();
  	memcpy(mceP->data, oldData, mceP->size);
  	AFS_GLOCK();
  
  	afs_osi_Free(oldData, mceP->dataSize);
! 	mceP->dataSize = uioP->uio_resid + uioP->uio_offset;
      }
!     if (mceP->size < uioP->uio_offset)
  	memset(mceP->data + mceP->size, 0,
! 	       (int)(uioP->uio_offset - mceP->size));
!     AFS_UIOMOVE(mceP->data + uioP->uio_offset, uioP->uio_resid, UIO_WRITE,
  		uioP, code);
!     if (uioP->uio_offset > mceP->size)
! 	mceP->size = uioP->uio_offset;
  
      MReleaseWriteLock(&mceP->afs_memLock);
      return code;
--- 281,305 ----
  
      AFS_STATCNT(afs_MemWriteUIO);
      MObtainWriteLock(&mceP->afs_memLock, 312);
!     if (AFS_UIO_RESID(uioP) + AFS_UIO_OFFSET(uioP) > mceP->dataSize) {
  	char *oldData = mceP->data;
  
! 	mceP->data = afs_osi_Alloc(AFS_UIO_RESID(uioP) + AFS_UIO_OFFSET(uioP));
  
  	AFS_GUNLOCK();
  	memcpy(mceP->data, oldData, mceP->size);
  	AFS_GLOCK();
  
  	afs_osi_Free(oldData, mceP->dataSize);
! 	mceP->dataSize = AFS_UIO_RESID(uioP) + AFS_UIO_OFFSET(uioP);
      }
!     if (mceP->size < AFS_UIO_OFFSET(uioP))
  	memset(mceP->data + mceP->size, 0,
! 	       (int)(AFS_UIO_OFFSET(uioP) - mceP->size));
!     AFS_UIOMOVE(mceP->data + AFS_UIO_OFFSET(uioP), AFS_UIO_RESID(uioP), UIO_WRITE,
  		uioP, code);
!     if (AFS_UIO_OFFSET(uioP) > mceP->size)
! 	mceP->size = AFS_UIO_OFFSET(uioP);
  
      MReleaseWriteLock(&mceP->afs_memLock);
      return code;
Index: openafs/src/afs/afs_nfsdisp.c
diff -c openafs/src/afs/afs_nfsdisp.c:1.18.2.1.4.2 openafs/src/afs/afs_nfsdisp.c:1.18.2.3
*** openafs/src/afs/afs_nfsdisp.c:1.18.2.1.4.2	Thu Oct 13 14:27:32 2005
--- openafs/src/afs/afs_nfsdisp.c	Thu Oct 13 14:26:06 2005
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_nfsdisp.c,v 1.18.2.1.4.2 2005/10/13 18:27:32 shadow Exp $");
  
  /* Ugly Ugly Ugly  but precludes conflicting XDR macros; We want kernel xdr */
  #define __XDR_INCLUDE__
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_nfsdisp.c,v 1.18.2.3 2005/10/13 18:26:06 shadow Exp $");
  
  /* Ugly Ugly Ugly  but precludes conflicting XDR macros; We want kernel xdr */
  #define __XDR_INCLUDE__
Index: openafs/src/afs/afs_osi.c
diff -c openafs/src/afs/afs_osi.c:1.48.2.4 openafs/src/afs/afs_osi.c:1.48.2.5
*** openafs/src/afs/afs_osi.c:1.48.2.4	Sun Apr  3 14:15:36 2005
--- openafs/src/afs/afs_osi.c	Wed Oct  5 01:58:27 2005
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_osi.c,v 1.48.2.4 2005/04/03 18:15:36 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_osi.c,v 1.48.2.5 2005/10/05 05:58:27 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 60,66 ****
--- 60,68 ----
  #elif defined(AFS_FBSD50_ENV)
      mtx_init(&afs_global_mtx, "AFS global lock", NULL, MTX_DEF);
  #elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+ #if !defined(AFS_DARWIN80_ENV)
      lockinit(&afs_global_lock, PLOCK, "afs global lock", 0, 0);
+ #endif
      afs_global_owner = 0;
  #elif defined(AFS_AIX41_ENV)
      lock_alloc((void *)&afs_global_lock, LOCK_ALLOC_PIN, 1, 1);
***************
*** 74,79 ****
--- 76,86 ----
  #endif /* AFS_HPUX_ENV */
  
      if (!afs_osicred_initialized) {
+ #if defined(AFS_DARWIN80_ENV)
+         afs_osi_ctxtp_initialized = 0;
+         afs_osi_ctxtp = NULL; /* initialized in afs_Daemon since it has
+                                   a proc reference that cannot be changed */
+ #endif
  #if defined(AFS_XBSD_ENV)
  	/* Can't just invent one, must use crget() because of mutex */
  	afs_osi_credp = crdup(osi_curcred());
***************
*** 82,88 ****
--- 89,100 ----
  #if defined(AFS_LINUX26_ENV)
          afs_osi_cred.cr_group_info = groups_alloc(0);
  #endif
+ #if defined(AFS_DARWIN80_ENV)
+         afs_osi_cred.cr_ref = 1; /* kauth_cred_get_ref needs 1 existing ref */
+ #else
  	crhold(&afs_osi_cred);	/* don't let it evaporate */
+ #endif
+ 
  	afs_osi_credp = &afs_osi_cred;
  #endif
  	afs_osicred_initialized = 1;
***************
*** 284,289 ****
--- 296,302 ----
      curproc->p_flag |= SSYS;
  #elif defined(AFS_HPUX101_ENV) && !defined(AFS_HPUX1123_ENV)
      set_system_proc(u.u_procp);
+ #elif defined(AFS_DARWIN80_ENV)
  #elif defined(AFS_DARWIN_ENV)
      /* maybe call init_process instead? */
      current_proc()->p_flag |= P_SYSTEM;
***************
*** 333,341 ****
--- 346,356 ----
      stime(&sta);
      AFS_GLOCK();
  #elif defined(AFS_DARWIN_ENV)
+ #ifndef AFS_DARWIN80_ENV
      AFS_GUNLOCK();
      setthetime(atv);
      AFS_GLOCK();
+ #endif
  #else
      /* stolen from kern_time.c */
  #ifndef	AFS_AUX_ENV
***************
*** 560,565 ****
--- 575,587 ----
  shutdown_osi(void)
  {
      AFS_STATCNT(shutdown_osi);
+ #ifdef AFS_DARWIN80_ENV
+     if (afs_osi_ctxtp_initialized && afs_osi_ctxtp) {
+        vfs_context_rele(afs_osi_ctxtp);
+        afs_osi_ctxtp = NULL;
+        afs_osi_ctxtp_initialized = 0;
+     }
+ #endif
      if (afs_cold_shutdown) {
  	LOCK_INIT(&afs_ftf, "afs_ftf");
      }
***************
*** 765,771 ****
  }
  #endif
  
! #if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
  void
  afs_osi_TraverseProcTable(void)
  {
--- 787,793 ----
  }
  #endif
  
! #if (defined(AFS_DARWIN_ENV) && !defined(AFS_DARWIN80_ENV)) || defined(AFS_FBSD_ENV)
  void
  afs_osi_TraverseProcTable(void)
  {
***************
*** 989,994 ****
--- 1011,1035 ----
  
      return rv;
  }
+ #elif defined(AFS_DARWIN80_ENV) 
+ const struct AFS_UCRED *
+ afs_osi_proc2cred(AFS_PROC * pr)
+ {
+     struct AFS_UCRED *rv = NULL;
+     static struct AFS_UCRED cr;
+     struct ucred *pcred;
+ 
+     if (pr == NULL) {
+ 	return NULL;
+     }
+     pcred = proc_ucred(pr);
+     cr.cr_ref = 1;
+     cr.cr_uid = pcred->cr_uid;
+     cr.cr_ngroups = pcred->cr_ngroups;
+     memcpy(cr.cr_groups, pcred->cr_groups,
+            NGROUPS * sizeof(gid_t));
+     return &cr;
+ }
  #elif defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
  const struct AFS_UCRED *
  afs_osi_proc2cred(AFS_PROC * pr)
Index: openafs/src/afs/afs_osi.h
diff -c openafs/src/afs/afs_osi.h:1.22.2.10 openafs/src/afs/afs_osi.h:1.22.2.13
*** openafs/src/afs/afs_osi.h:1.22.2.10	Mon Jul 11 15:29:55 2005
--- openafs/src/afs/afs_osi.h	Thu Oct  6 19:38:14 2005
***************
*** 123,128 ****
--- 123,136 ----
  /*
   * Vnode related macros
   */
+ #if defined(AFS_DARWIN80_ENV)
+ #define vType(vc)               vnode_vtype(AFSTOV(vc))
+ #define vSetVfsp(vc, vfsp)      
+ #define vSetType(vc, type)      (vc)->m.Type = (type)
+ extern int afs_vfs_typenum;
+ #define SetAfsVnode(vn)         /* nothing; done in getnewvnode() */
+ #define IsAfsVnode(v) (vfs_typenum(vnode_mount((v))) == afs_vfs_typenum)
+ #else
  #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) || defined(AFS_LINUX22_ENV)
  #define vSetVfsp(vc, vfsp)      AFSTOV(vc)->v_mount = (vfsp)
  #define vSetType(vc, type)      AFSTOV(vc)->v_type = (type)
***************
*** 132,138 ****
  #define	vSetType(vc,type)   (vc)->v.v_type = (type)
  #define	vSetVfsp(vc,vfsp)   (vc)->v.v_vfsp = (vfsp)
  #endif
- 
  #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
  extern int (**afs_vnodeop_p) ();
  #define IsAfsVnode(v)      ((v)->v_op == afs_vnodeop_p)
--- 140,145 ----
***************
*** 142,147 ****
--- 149,155 ----
  #define	IsAfsVnode(v)	    ((v)->v_op == afs_ops)
  #define	SetAfsVnode(v)	    (v)->v_op = afs_ops
  #endif
+ #endif
  
  #ifdef AFS_SGI65_ENV
  #define	gop_lookupname(fnamep,segflg,followlink,compvpp) \
***************
*** 192,197 ****
--- 200,207 ----
  
  #define osi_getpid() 		getpid()
  
+ #define osi_getpid() 		getpid()
+ 
  /*
   * osi_ThreadUnique() should yield a value that can be found in ps
   * output in order to draw correspondences between ICL traces and what
***************
*** 272,277 ****
--- 282,292 ----
   * and kernel space. Call these to avoid taking page faults while
   * holding the global lock.
   */
+ #ifdef CAST_USER_ADDR_T
+ #define __U(X) CAST_USER_ADDR_T((X))
+ #else
+ #define __U(X) (X)
+ #endif
  #ifdef AFS_GLOBAL_SUNLOCK
  
  #define AFS_COPYIN(SRC,DST,LEN,CODE)				\
***************
*** 279,285 ****
  	    int haveGlock = ISAFS_GLOCK();			\
  	    if (haveGlock)					\
  		AFS_GUNLOCK();					\
! 	    CODE = copyin((SRC),(DST),(LEN));			\
  	    if (haveGlock)					\
  		AFS_GLOCK();					\
  	} while(0)
--- 294,300 ----
  	    int haveGlock = ISAFS_GLOCK();			\
  	    if (haveGlock)					\
  		AFS_GUNLOCK();					\
! 	    CODE = copyin(__U((SRC)),(DST),(LEN));			\
  	    if (haveGlock)					\
  		AFS_GLOCK();					\
  	} while(0)
***************
*** 289,295 ****
  	    int haveGlock = ISAFS_GLOCK();			\
  	    if (haveGlock)					\
  		AFS_GUNLOCK();					\
! 	    CODE = copyinstr((SRC),(DST),(LEN),(CNT));		\
  	    if (haveGlock)					\
  		AFS_GLOCK();					\
  	} while(0)
--- 304,310 ----
  	    int haveGlock = ISAFS_GLOCK();			\
  	    if (haveGlock)					\
  		AFS_GUNLOCK();					\
! 	    CODE = copyinstr(__U((SRC)),(DST),(LEN),(CNT));		\
  	    if (haveGlock)					\
  		AFS_GLOCK();					\
  	} while(0)
***************
*** 299,309 ****
  	    int haveGlock = ISAFS_GLOCK();			\
  	    if (haveGlock)					\
  		AFS_GUNLOCK();					\
! 	    CODE = copyout((SRC),(DST),(LEN));			\
  	    if (haveGlock)					\
  		AFS_GLOCK();					\
  	} while(0)
  
  #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
  #define AFS_UIOMOVE(SRC,LEN,RW,UIO,CODE)			\
  	do {							\
--- 314,336 ----
  	    int haveGlock = ISAFS_GLOCK();			\
  	    if (haveGlock)					\
  		AFS_GUNLOCK();					\
! 	    CODE = copyout((SRC),__U((DST)),(LEN));			\
  	    if (haveGlock)					\
  		AFS_GLOCK();					\
  	} while(0)
  
+ #if defined(AFS_DARWIN80_ENV)
+ #define AFS_UIOMOVE(SRC,LEN,RW,UIO,CODE)			\
+ 	do {							\
+ 	    int haveGlock = ISAFS_GLOCK();			\
+ 	    if (haveGlock)					\
+ 		AFS_GUNLOCK();					\
+ 	    uio_setrw((UIO),(RW));				\
+ 	    CODE = uiomove((SRC),(LEN),(UIO));			\
+ 	    if (haveGlock)					\
+ 		AFS_GLOCK();					\
+ 	} while(0)
+ #else
  #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
  #define AFS_UIOMOVE(SRC,LEN,RW,UIO,CODE)			\
  	do {							\
***************
*** 326,349 ****
  		AFS_GLOCK();					\
  	} while(0)
  #endif
  
  #else /* AFS_GLOBAL_SUNLOCK */
  
  #define AFS_COPYIN(SRC,DST,LEN,CODE)				\
  	do {							\
! 	    CODE = copyin((SRC),(DST),(LEN));			\
  	} while(0)
  
  #define AFS_COPYINSTR(SRC,DST,LEN,CNT,CODE)			\
  	do {							\
! 	    CODE = copyinstr((SRC),(DST),(LEN),(CNT));		\
  	} while(0)
  
  #define AFS_COPYOUT(SRC,DST,LEN,CODE)				\
  	do {							\
! 	    CODE = copyout((SRC),(DST),(LEN));			\
  	} while(0)
  
  #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
  #define AFS_UIOMOVE(SRC,LEN,RW,UIO,CODE)			\
  	do {							\
--- 353,384 ----
  		AFS_GLOCK();					\
  	} while(0)
  #endif
+ #endif /* AFS_DARWIN80_ENV */
  
  #else /* AFS_GLOBAL_SUNLOCK */
  
  #define AFS_COPYIN(SRC,DST,LEN,CODE)				\
  	do {							\
! 	    CODE = copyin(__U((SRC)),(DST),(LEN));			\
  	} while(0)
  
  #define AFS_COPYINSTR(SRC,DST,LEN,CNT,CODE)			\
  	do {							\
! 	    CODE = copyinstr(__U((SRC)),(DST),(LEN),(CNT));		\
  	} while(0)
  
  #define AFS_COPYOUT(SRC,DST,LEN,CODE)				\
  	do {							\
! 	    CODE = copyout((SRC),__U((DST)),(LEN));			\
  	} while(0)
  
+ #if defined(AFS_DARWIN80_ENV)
+ #define AFS_UIOMOVE(SRC,LEN,RW,UIO,CODE)			\
+ 	do {							\
+ 	    uio_setrw((UIO),(RW));				\
+ 	    CODE = uiomove((SRC),(LEN),(UIO));			\
+ 	} while(0)
+ #else /* AFS_OSF_ENV || AFS_FBSD_ENV */
  #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
  #define AFS_UIOMOVE(SRC,LEN,RW,UIO,CODE)			\
  	do {							\
***************
*** 356,364 ****
--- 391,413 ----
  	    CODE = uiomove((SRC),(LEN),(RW),(UIO));		\
  	} while(0)
  #endif /* AFS_OSF_ENV || AFS_FBSD_ENV */
+ #endif /* AFS_DARWIN80_ENV */
  
  #endif /* AFS_GLOBAL_SUNLOCK */
  
+ #ifdef AFS_DARWIN80_ENV
+ #define AFS_UIO_OFFSET(uio) (int)uio_offset(uio)
+ #define AFS_UIO_RESID(uio) (int)uio_resid(uio)
+ #define AFS_UIO_SETOFFSET(uio, off) uio_setoffset(uio, off)
+ #define AFS_UIO_SETRESID(uio, val) uio_setresid(uio, val)
+ #else
+ #define AFS_UIO_OFFSET(uio) (uio)->uio_offset
+ #define AFS_UIO_RESID(uio) (uio)->uio_resid
+ #define AFS_UIO_SETOFFSET(uio, off) (uio)->uio_offset = off
+ #define AFS_UIO_SETRESID(uio, val) (uio)->uio_resid = val
+ #endif
+ 
+ 
  /*
   * encapsulation of kernel data structure accesses
   */
Index: openafs/src/afs/afs_osi_pag.c
diff -c openafs/src/afs/afs_osi_pag.c:1.21.2.4 openafs/src/afs/afs_osi_pag.c:1.21.2.5
*** openafs/src/afs/afs_osi_pag.c:1.21.2.4	Mon May 23 17:09:37 2005
--- openafs/src/afs/afs_osi_pag.c	Wed Oct  5 01:58:27 2005
***************
*** 23,29 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_osi_pag.c,v 1.21.2.4 2005/05/23 21:09:37 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 23,29 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_osi_pag.c,v 1.21.2.5 2005/10/05 05:58:27 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 241,246 ****
--- 241,252 ----
  	code = AddPag(genpag(), &credp);
  	crfree(credp);
      }
+ #elif defined(AFS_DARWIN80_ENV)
+     {
+ 	struct ucred *credp = kauth_cred_proc_ref(p);
+ 	code = AddPag(p, genpag(), &credp);
+ 	kauth_cred_rele(credp);
+     }
  #elif defined(AFS_DARWIN_ENV)
      {
  	struct ucred *credp = crdup(p->p_cred->pc_ucred);
Index: openafs/src/afs/afs_osi_uio.c
diff -c openafs/src/afs/afs_osi_uio.c:1.8 openafs/src/afs/afs_osi_uio.c:1.8.2.2
*** openafs/src/afs/afs_osi_uio.c:1.8	Tue Jul 15 19:14:12 2003
--- openafs/src/afs/afs_osi_uio.c	Wed Oct 12 02:17:25 2005
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_osi_uio.c,v 1.8 2003/07/15 23:14:12 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_osi_uio.c,v 1.8.2.2 2005/10/12 06:17:25 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 25,30 ****
--- 25,31 ----
   * UIO routines
   */
  
+ #ifndef AFS_DARWIN80_ENV
  /* routine to make copy of uio structure in ainuio, using aoutvec for space */
  int
  afsio_copy(struct uio *ainuio, struct uio *aoutuio,
***************
*** 76,81 ****
--- 77,83 ----
      }
      return 0;
  }
+ #endif
  
  /* skip asize bytes in the current uio structure */
  int
***************
*** 85,90 ****
--- 87,95 ----
      register int cnt;
  
      AFS_STATCNT(afsio_skip);
+ #ifdef AFS_DARWIN80_ENV
+     uio_update(auio, asize);
+ #else
      /* It isn't guaranteed that multiple iovecs work ok (hasn't been tested!) */
      while (asize > 0 && auio->afsio_resid) {
  	tv = auio->afsio_iov;
***************
*** 99,106 ****
  	tv->iov_base = (char *)(tv->iov_base) + cnt;
  	tv->iov_len -= cnt;
  	auio->uio_resid -= cnt;
! 	auio->uio_offset += cnt;
  	asize -= cnt;
      }
      return 0;
  }
--- 104,112 ----
  	tv->iov_base = (char *)(tv->iov_base) + cnt;
  	tv->iov_len -= cnt;
  	auio->uio_resid -= cnt;
! 	auio->afsio_offset += cnt;
  	asize -= cnt;
      }
+ #endif
      return 0;
  }
Index: openafs/src/afs/afs_osi_vget.c
diff -c openafs/src/afs/afs_osi_vget.c:1.10 openafs/src/afs/afs_osi_vget.c:1.10.2.1
*** openafs/src/afs/afs_osi_vget.c:1.10	Tue Jul 15 19:14:12 2003
--- openafs/src/afs/afs_osi_vget.c	Wed Oct  5 01:58:27 2005
***************
*** 15,21 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_osi_vget.c,v 1.10 2003/07/15 23:14:12 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 15,21 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_osi_vget.c,v 1.10.2.1 2005/10/05 05:58:27 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 23,29 ****
  
  
  
! #if !defined(AFS_LINUX20_ENV)
  /* This is the common part of the vget VFS call. */
  int
  afs_osi_vget(struct vcache **avcpp, struct fid *afidp, struct vrequest *areqp)
--- 23,29 ----
  
  
  
! #if !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN80_ENV)
  /* This is the common part of the vget VFS call. */
  int
  afs_osi_vget(struct vcache **avcpp, struct fid *afidp, struct vrequest *areqp)
Index: openafs/src/afs/afs_osidnlc.c
diff -c openafs/src/afs/afs_osidnlc.c:1.8 openafs/src/afs/afs_osidnlc.c:1.8.2.1
*** openafs/src/afs/afs_osidnlc.c:1.8	Tue Jul 15 19:14:12 2003
--- openafs/src/afs/afs_osidnlc.c	Wed Oct  5 01:58:27 2005
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_osidnlc.c,v 1.8 2003/07/15 23:14:12 shadow Exp $");
  
  #include "afs/sysincludes.h"	/*Standard vendor system headers */
  #include "afsincludes.h"	/*AFS-based standard headers */
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_osidnlc.c,v 1.8.2.1 2005/10/05 05:58:27 shadow Exp $");
  
  #include "afs/sysincludes.h"	/*Standard vendor system headers */
  #include "afsincludes.h"	/*AFS-based standard headers */
***************
*** 242,247 ****
--- 242,250 ----
  #ifdef	AFS_OSF_ENV
  	VN_HOLD((vnode_t *) tvc);
  #else
+ #ifdef AFS_DARWIN80_ENV
+         vnode_get(tvc->v);
+ #endif
  	osi_vnhold(tvc, 0);
  #endif
  	ReleaseReadLock(&afs_xvcache);
Index: openafs/src/afs/afs_pioctl.c
diff -c openafs/src/afs/afs_pioctl.c:1.81.2.18.2.1 openafs/src/afs/afs_pioctl.c:1.81.2.21
*** openafs/src/afs/afs_pioctl.c:1.81.2.18.2.1	Fri Oct 14 21:44:50 2005
--- openafs/src/afs/afs_pioctl.c	Fri Oct 14 21:43:30 2005
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_pioctl.c,v 1.81.2.18.2.1 2005/10/15 01:44:50 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #ifdef AFS_OBSD_ENV
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_pioctl.c,v 1.81.2.21 2005/10/15 01:43:30 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #ifdef AFS_OBSD_ENV
***************
*** 430,436 ****
     interface call.
     */
  /* AFS_HPUX102 and up uses VNODE ioctl instead */
! #ifndef AFS_HPUX102_ENV
  #if !defined(AFS_SGI_ENV)
  #ifdef	AFS_AIX32_ENV
  #ifdef AFS_AIX51_ENV
--- 430,436 ----
     interface call.
     */
  /* AFS_HPUX102 and up uses VNODE ioctl instead */
! #if !defined(AFS_HPUX102_ENV) && !defined(AFS_DARWIN80_ENV)
  #if !defined(AFS_SGI_ENV)
  #ifdef	AFS_AIX32_ENV
  #ifdef AFS_AIX51_ENV
***************
*** 817,825 ****
--- 817,831 ----
      } *uap = (struct a *)args;
  
      AFS_STATCNT(afs_pioctl);
+ #ifdef AFS_DARWIN80_ENV
+     return (afs_syscall_pioctl
+ 	    (uap->path, uap->cmd, uap->cmarg, uap->follow,
+ 	     kauth_cred_get()));
+ #else
      return (afs_syscall_pioctl
  	    (uap->path, uap->cmd, uap->cmarg, uap->follow,
  	     p->p_cred->pc_ucred));
+ #endif
  }
  
  #endif
***************
*** 1466,1473 ****
--- 1472,1481 ----
  #else
  	struct proc *p = curproc;	/* XXX */
  #endif
+ #ifndef AFS_DARWIN80_ENV
  	uprintf("Process %d (%s) tried to change pags in PSetTokens\n",
  		p->p_pid, p->p_comm);
+ #endif
  	if (!setpag(p, acred, -1, &pag, 1)) {
  #else
  #ifdef	AFS_OSF_ENV
***************
*** 2540,2545 ****
--- 2548,2554 ----
      register struct vcache *tvc;
      register struct volume *tv;
      afs_int32 cell, volume;
+     struct afs_q *tq, *uq;
  
      AFS_STATCNT(PFlushVolumeData);
      if (!avc)
***************
*** 2554,2564 ****
       * Clear stat'd flag from all vnodes from this volume; this will invalidate all
       * the vcaches associated with the volume.
       */
      ObtainReadLock(&afs_xvcache);
      i = VCHashV(&avc->fid);
!     for (tvc = afs_vhashT[i]; tvc; tvc = tvc->vhnext) {
  	    if (tvc->fid.Fid.Volume == volume && tvc->fid.Cell == cell) {
! #if	defined(AFS_SGI_ENV) || defined(AFS_OSF_ENV)  || defined(AFS_SUN5_ENV)  || defined(AFS_HPUX_ENV) || defined(AFS_LINUX20_ENV)
  		VN_HOLD(AFSTOV(tvc));
  #else
  #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
--- 2563,2588 ----
       * Clear stat'd flag from all vnodes from this volume; this will invalidate all
       * the vcaches associated with the volume.
       */
+  loop:
      ObtainReadLock(&afs_xvcache);
      i = VCHashV(&avc->fid);
!     for (tq = afs_vhashTV[i].prev; tq != &afs_vhashTV[i]; tq = uq) {
! 	    uq = QPrev(tq);
! 	    tvc = QTOVH(tq);
  	    if (tvc->fid.Fid.Volume == volume && tvc->fid.Cell == cell) {
!                 if (tvc->states & CVInit) {
!                     ReleaseReadLock(&afs_xvcache);
!                     afs_osi_Sleep(&tvc->states);
!                     goto loop;
!                 }
! #ifdef AFS_DARWIN80_ENV
!                 if (tvc->states & CDeadVnode) {
!                     ReleaseReadLock(&afs_xvcache);
!                     afs_osi_Sleep(&tvc->states);
!                     goto loop;
!                 }
! #endif
! #if	defined(AFS_SGI_ENV) || defined(AFS_OSF_ENV)  || defined(AFS_SUN5_ENV)  || defined(AFS_HPUX_ENV) || defined(AFS_LINUX20_ENV) 
  		VN_HOLD(AFSTOV(tvc));
  #else
  #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
***************
*** 2584,2592 ****
--- 2608,2622 ----
  #ifdef AFS_BOZONLOCK_ENV
  		afs_BozonUnlock(&tvc->pvnLock, tvc);
  #endif
+ #ifdef AFS_DARWIN80_ENV
+ 		/* our tvc ptr is still good until now */
+ 		AFS_FAST_RELE(tvc);
+ 		ObtainReadLock(&afs_xvcache);
+ #else
  		ObtainReadLock(&afs_xvcache);
  		/* our tvc ptr is still good until now */
  		AFS_FAST_RELE(tvc);
+ #endif
  	    }
  	}
      ReleaseReadLock(&afs_xvcache);
Index: openafs/src/afs/afs_prototypes.h
diff -c openafs/src/afs/afs_prototypes.h:1.53.2.11 openafs/src/afs/afs_prototypes.h:1.53.2.12
*** openafs/src/afs/afs_prototypes.h:1.53.2.11	Tue Jul 12 13:49:45 2005
--- openafs/src/afs/afs_prototypes.h	Thu Oct 13 14:08:39 2005
***************
*** 817,823 ****
  extern struct afs_q VLRU;
  extern afs_int32 vcachegen;
  extern unsigned int afs_paniconwarn;
! extern struct vcache *afs_vhashT[VCSIZE];
  extern afs_int32 afs_bulkStatsLost;
  extern int afs_norefpanic;
  
--- 817,823 ----
  extern struct afs_q VLRU;
  extern afs_int32 vcachegen;
  extern unsigned int afs_paniconwarn;
! extern struct afs_q afs_vhashTV[VCSIZE];
  extern afs_int32 afs_bulkStatsLost;
  extern int afs_norefpanic;
  
Index: openafs/src/afs/afs_server.c
diff -c openafs/src/afs/afs_server.c:1.33.2.6 openafs/src/afs/afs_server.c:1.33.2.7
*** openafs/src/afs/afs_server.c:1.33.2.6	Thu Aug  4 16:05:15 2005
--- openafs/src/afs/afs_server.c	Wed Oct  5 01:58:27 2005
***************
*** 33,39 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_server.c,v 1.33.2.6 2005/08/04 20:05:15 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
--- 33,39 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_server.c,v 1.33.2.7 2005/10/05 05:58:27 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
***************
*** 1139,1162 ****
  void
  afsi_SetServerIPRank(sa, ifa)
       struct srvAddr *sa;
       struct ifaddr *ifa;
  {
      struct sockaddr_in *sin;
      int t;
  
      afs_uint32 subnetmask, myAddr, myNet, myDstaddr, mySubnet, netMask;
      afs_uint32 serverAddr;
  
!     if (ifa->ifa_addr->sa_family != AF_INET)
  	return;
!     sin = (struct sockaddr_in *)ifa->ifa_addr;
!     myAddr = ntohl(sin->sin_addr.s_addr);	/* one of my IP addr in host order */
      serverAddr = ntohl(sa->sa_ip);	/* server's IP addr in host order */
!     sin = (struct sockaddr_in *)ifa->ifa_netmask;
!     subnetmask = ntohl(sin->sin_addr.s_addr);	/* subnet mask in host order */
!     sin = (struct sockaddr_in *)ifa->ifa_dstaddr;
!     if (sin)
  	myDstaddr = sin->sin_addr.s_addr;
  
      if (IN_CLASSA(myAddr))
  	netMask = IN_CLASSA_NET;
--- 1139,1181 ----
  void
  afsi_SetServerIPRank(sa, ifa)
       struct srvAddr *sa;
+ #ifdef AFS_DARWIN80_ENV
+      ifaddr_t ifa;
+ #else
       struct ifaddr *ifa;
+ #endif
  {
+     struct sockaddr sout;
      struct sockaddr_in *sin;
      int t;
  
      afs_uint32 subnetmask, myAddr, myNet, myDstaddr, mySubnet, netMask;
      afs_uint32 serverAddr;
  
!     if (ifaddr_address_family(ifa) != AF_INET)
  	return;
!     t = ifaddr_address(ifa, &sout, sizeof(sout));
!     if (t == 0) {
! 	sin = (struct sockaddr_in *)&sout;
! 	myAddr = ntohl(sin->sin_addr.s_addr);	/* one of my IP addr in host order */
!     } else {
! 	myAddr = 0;
!     }
      serverAddr = ntohl(sa->sa_ip);	/* server's IP addr in host order */
!     t = ifaddr_netmask(ifa, &sout, sizeof(sout));
!     if (t == 0) {
! 	sin = (struct sockaddr_in *)&sout;
! 	subnetmask = ntohl(sin->sin_addr.s_addr);	/* subnet mask in host order */
!     } else {
! 	subnetmask = 0;
!     }
!     t = ifaddr_dstaddress(ifa, &sout, sizeof(sout));
!     if (t == 0) {
! 	sin = (struct sockaddr_in *)&sout;
  	myDstaddr = sin->sin_addr.s_addr;
+     } else {
+ 	myDstaddr = 0;
+     }
  
      if (IN_CLASSA(myAddr))
  	netMask = IN_CLASSA_NET;
***************
*** 1175,1194 ****
  	    if (serverAddr == myAddr) {	/* same machine */
  		sa->sa_iprank = afs_min(sa->sa_iprank, TOPR);
  	    } else {		/* same subnet */
! 		sa->sa_iprank = afs_min(sa->sa_iprank, HI + ifa->ifa_metric);
  	    }
  	} else {		/* same net */
! 	    sa->sa_iprank = afs_min(sa->sa_iprank, MED + ifa->ifa_metric);
  	}
      }
  #ifdef  IFF_POINTTOPOINT
      /* check for case #4 -- point-to-point link */
!     if ((ifa->ia_ifp->if_flags & IFF_POINTOPOINT)
  	&& (myDstaddr == serverAddr)) {
! 	if (ifa->ia_ifp->if_metric >= (MAXDEFRANK - MED) / PPWEIGHT)
  	    t = MAXDEFRANK;
  	else
! 	    t = MED + (PPWEIGHT << ifa->->ifa_metric);
  	if (sa->sa_iprank > t)
  	    sa->sa_iprank = t;
  	}
--- 1194,1213 ----
  	    if (serverAddr == myAddr) {	/* same machine */
  		sa->sa_iprank = afs_min(sa->sa_iprank, TOPR);
  	    } else {		/* same subnet */
! 		sa->sa_iprank = afs_min(sa->sa_iprank, HI + ifnet_metric(ifaddr_ifnet(ifa)));
  	    }
  	} else {		/* same net */
! 	    sa->sa_iprank = afs_min(sa->sa_iprank, MED + ifnet_metric(ifaddr_ifnet(ifa)));
  	}
      }
  #ifdef  IFF_POINTTOPOINT
      /* check for case #4 -- point-to-point link */
!     if ((ifnet_flags(ifaddr_ifnet(ifa)) & IFF_POINTOPOINT)
  	&& (myDstaddr == serverAddr)) {
! 	if (ifnet_metric(ifaddr_ifnet(ifa)) >= (MAXDEFRANK - MED) / PPWEIGHT)
  	    t = MAXDEFRANK;
  	else
! 	    t = MED + (PPWEIGHT << ifnet_metric(ifaddr_ifnet(ifa)));
  	if (sa->sa_iprank > t)
  	    sa->sa_iprank = t;
  	}
***************
*** 1361,1366 ****
--- 1380,1399 ----
  #ifdef AFS_SGI62_ENV
      (void)hash_enum(&hashinfo_inaddr, afsi_enum_set_rank, HTF_INET, NULL,
  		    (caddr_t) sa, NULL);
+ #elif defined(AFS_DARWIN80_ENV)
+     {
+ 	errno_t t;
+ 	int cnt=0;
+ 	ifaddr_t *addresses, address;
+ 	t = ifnet_get_address_list_family(NULL, &addresses, AF_INET);
+ 	if (t == 0) {
+ 	    while(addresses[cnt] != NULL) {
+ 		afsi_SetServerIPRank(sa, address);
+ 		cnt++;
+ 	    }
+ 	    ifnet_free_address_list(addresses);
+ 	}
+     }
  #elif defined(AFS_DARWIN60_ENV)
      {
  	struct ifnet *ifn;
Index: openafs/src/afs/afs_util.c
diff -c openafs/src/afs/afs_util.c:1.17.2.1 openafs/src/afs/afs_util.c:1.17.2.2
*** openafs/src/afs/afs_util.c:1.17.2.1	Tue Dec  7 01:12:12 2004
--- openafs/src/afs/afs_util.c	Wed Oct  5 01:58:27 2005
***************
*** 16,22 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_util.c,v 1.17.2.1 2004/12/07 06:12:12 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
--- 16,22 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_util.c,v 1.17.2.2 2005/10/05 05:58:27 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
***************
*** 270,280 ****
--- 270,285 ----
  
  	for (i = 0; i < VCSIZE; i++) {
  	    for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) {
+                 if (tvc->states & CVInit) continue;
  #ifdef	AFS_OSF_ENV
  		if (VREFCOUNT(tvc) > 1)
  #else /* AFS_OSF_ENV */
+ #ifdef AFS_DARWIN80_ENV
+ 		if (vnode_isinuse(AFSTOV(tvc), 0))
+ #else
  		if (VREFCOUNT(tvc))
  #endif
+ #endif
  		    afs_warn("Stat cache entry at %x is held\n", tvc);
  		if (CheckLock(&tvc->lock))
  		    afs_warn("Stat entry at %x is locked\n", tvc);
Index: openafs/src/afs/afs_vcache.c
diff -c openafs/src/afs/afs_vcache.c:1.65.2.21 openafs/src/afs/afs_vcache.c:1.65.2.30
*** openafs/src/afs/afs_vcache.c:1.65.2.21	Mon Jul 11 15:29:55 2005
--- openafs/src/afs/afs_vcache.c	Fri Oct 14 22:33:09 2005
***************
*** 39,45 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_vcache.c,v 1.65.2.21 2005/07/11 19:29:55 shadow Exp $");
  
  #include "afs/sysincludes.h"	/*Standard vendor system headers */
  #include "afsincludes.h"	/*AFS-based standard headers */
--- 39,45 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_vcache.c,v 1.65.2.30 2005/10/15 02:33:09 shadow Exp $");
  
  #include "afs/sysincludes.h"	/*Standard vendor system headers */
  #include "afsincludes.h"	/*AFS-based standard headers */
***************
*** 71,77 ****
  afs_int32 vcachegen = 0;
  unsigned int afs_paniconwarn = 0;
  struct vcache *afs_vhashT[VCSIZE];
! struct vcache *afs_vhashTV[VCSIZE];
  static struct afs_cbr *afs_cbrHashT[CBRSIZE];
  afs_int32 afs_bulkStatsLost;
  int afs_norefpanic = 0;
--- 71,77 ----
  afs_int32 vcachegen = 0;
  unsigned int afs_paniconwarn = 0;
  struct vcache *afs_vhashT[VCSIZE];
! struct afs_q afs_vhashTV[VCSIZE];
  static struct afs_cbr *afs_cbrHashT[CBRSIZE];
  afs_int32 afs_bulkStatsLost;
  int afs_norefpanic = 0;
***************
*** 132,139 ****
  afs_FlushVCache(struct vcache *avc, int *slept)
  {				/*afs_FlushVCache */
  
!     afs_int32 i, code, j;
!     struct vcache **uvc, *wvc, **uvc2, *wvc2;
  
      *slept = 0;
      AFS_STATCNT(afs_FlushVCache);
--- 132,139 ----
  afs_FlushVCache(struct vcache *avc, int *slept)
  {				/*afs_FlushVCache */
  
!     afs_int32 i, code;
!     struct vcache **uvc, *wvc;
  
      *slept = 0;
      AFS_STATCNT(afs_FlushVCache);
***************
*** 181,197 ****
      }
  
      /* remove entry from the volume hash table */
!     j = VCHashV(&avc->fid);
!     uvc2 = &afs_vhashTV[j];
!     for (wvc2 = *uvc2; wvc2; uvc2 = &wvc2->vhnext, wvc2 = *uvc2) {
!         if (avc == wvc2) {
!             *uvc2 = avc->vhnext;
!             avc->vhnext = (struct vcache *)NULL;
!             break;
!         }
!     }
!     if (!wvc || !wvc2)
! 	osi_Panic("flushvcache");	/* not in correct hash bucket */
      if (avc->mvid)
  	osi_FreeSmallSpace(avc->mvid);
      avc->mvid = (struct VenusFid *)0;
--- 181,188 ----
      }
  
      /* remove entry from the volume hash table */
!     QRemove(&avc->vhashq);
! 
      if (avc->mvid)
  	osi_FreeSmallSpace(avc->mvid);
      avc->mvid = (struct VenusFid *)0;
***************
*** 203,210 ****
      /* OK, there are no internal vrefCounts, so there shouldn't
       * be any more refs here. */
      if (avc->v) {
  	avc->v->v_data = NULL;	/* remove from vnode */
! 	avc->v = NULL;		/* also drop the ptr to vnode */
      }
  #endif
      afs_FreeAllAxs(&(avc->Access));
--- 194,206 ----
      /* OK, there are no internal vrefCounts, so there shouldn't
       * be any more refs here. */
      if (avc->v) {
+ #ifdef AFS_DARWIN80_ENV
+ 	vnode_clearfsnode(AFSTOV(avc));
+         vnode_removefsref(AFSTOV(avc));
+ #else
  	avc->v->v_data = NULL;	/* remove from vnode */
! #endif
! 	AFSTOV(avc) = NULL;             /* also drop the ptr to vnode */
      }
  #endif
      afs_FreeAllAxs(&(avc->Access));
***************
*** 247,253 ****
      /* This should put it back on the vnode free list since usecount is 1 */
      afs_vcount--;
      vSetType(avc, VREG);
!     if (VREFCOUNT(avc) > 0) {
  #if defined(AFS_OSF_ENV)
  	VN_UNLOCK(AFSTOV(avc));
  #endif
--- 243,249 ----
      /* This should put it back on the vnode free list since usecount is 1 */
      afs_vcount--;
      vSetType(avc, VREG);
!     if (VREFCOUNT_GT(avc,0)) {
  #if defined(AFS_OSF_ENV)
  	VN_UNLOCK(AFSTOV(avc));
  #endif
***************
*** 621,627 ****
      if (((3 * afs_vcount) > nvnode) || (afs_vcount >= afs_maxvcount))
  #endif
      {
- 	struct afs_q *tq, *uq;
  	int i;
  	char *panicstr;
  
--- 617,622 ----
***************
*** 635,641 ****
  		refpanic("Exceeded pool of AFS vnodes(VLRU cycle?)");
  	    } else if (QNext(uq) != tq) {
  		refpanic("VLRU inconsistent");
! 	    } else if (VREFCOUNT(tvc) < 1) {
  		refpanic("refcnt 0 on VLRU");
  	    }
  
--- 630,636 ----
  		refpanic("Exceeded pool of AFS vnodes(VLRU cycle?)");
  	    } else if (QNext(uq) != tq) {
  		refpanic("VLRU inconsistent");
! 	    } else if (!VREFCOUNT_GT(tvc,0)) {
  		refpanic("refcnt 0 on VLRU");
  	    }
  
***************
*** 683,689 ****
  	    }
  #endif
  
! 	    if (VREFCOUNT(tvc) == 1 && tvc->opens == 0
  		&& (tvc->states & CUnlinkedDel) == 0) {
  		code = afs_FlushVCache(tvc, &fv_slept);
  		if (code == 0) {
--- 678,685 ----
  	    }
  #endif
  
! 	    if (VREFCOUNT_GT(tvc,0) && !VREFCOUNT_GT(tvc,1) &&
! 		tvc->opens == 0
  		&& (tvc->states & CUnlinkedDel) == 0) {
  		code = afs_FlushVCache(tvc, &fv_slept);
  		if (code == 0) {
***************
*** 699,710 ****
  		break;
  	}
  	if (anumber == VCACHE_FREE) {
! 	    printf("NewVCache: warning none freed, using %d of %d\n",
  		   afs_vcount, afs_maxvcount);
  	    if (afs_vcount >= afs_maxvcount) {
! 		osi_Panic("NewVCache - none freed");
! 		/* XXX instead of panicing, should do afs_maxvcount++
! 		 * and magic up another one */
  	    }
  	}
      }
--- 695,705 ----
  		break;
  	}
  	if (anumber == VCACHE_FREE) {
! 	    printf("afs_NewVCache: warning none freed, using %d of %d\n",
  		   afs_vcount, afs_maxvcount);
  	    if (afs_vcount >= afs_maxvcount) {
! 	    	printf("afs_NewVCache - none freed\n");
! 		return NULL;
  	    }
  	}
      }
***************
*** 748,781 ****
  
  	    if (tvc->states & CVFlushed) {
  		refpanic("CVFlushed on VLRU");
- #if 0
  	    } else if (i++ > 2 * afs_cacheStats) {	/* even allowing for a few xallocs... */
  		refpanic("Increase -stat parameter of afsd(VLRU cycle?)");
- #endif
  	    } else if (QNext(uq) != tq) {
  		refpanic("VLRU inconsistent");
! 	    }
  
! 	    if (((VREFCOUNT(tvc) == 0) 
! #if defined(AFS_DARWIN_ENV) && !defined(UKERNEL) 
! 		 || ((VREFCOUNT(tvc) == 1) && 
! 		     (UBCINFOEXISTS(AFSTOV(tvc))))
  #endif
! 		 ) && tvc->opens == 0 && (tvc->states & CUnlinkedDel) == 0) {
  #if defined (AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
! 		/*
! 		 * vgone() reclaims the vnode, which calls afs_FlushVCache(),
! 		 * then it puts the vnode on the free list.
! 		 * If we don't do this we end up with a cleaned vnode that's
! 		 * not on the free list.
! 		 * XXX assume FreeBSD is the same for now.
! 		 */
! 	        AFS_GUNLOCK();
! 		vgone(AFSTOV(tvc));
! 		AFS_GLOCK();
! 		code = fv_slept = 0;
  #else
! 		code = afs_FlushVCache(tvc, &fv_slept);
  #endif
  		if (code == 0) {
  		    anumber--;
--- 743,793 ----
  
  	    if (tvc->states & CVFlushed) {
  		refpanic("CVFlushed on VLRU");
  	    } else if (i++ > 2 * afs_cacheStats) {	/* even allowing for a few xallocs... */
  		refpanic("Increase -stat parameter of afsd(VLRU cycle?)");
  	    } else if (QNext(uq) != tq) {
  		refpanic("VLRU inconsistent");
! 	    } else if (tvc->states & CVInit) {
! 		continue;
!             }
  
!            if (!VREFCOUNT_GT(tvc,0)
! #if defined(AFS_DARWIN_ENV) && !defined(UKERNEL) && !defined(AFS_DARWIN80_ENV)
!                || ((VREFCOUNT(tvc) == 1) && 
!                    (UBCINFOEXISTS(AFSTOV(tvc))))
  #endif
!                && tvc->opens == 0 && (tvc->states & CUnlinkedDel) == 0) {
  #if defined (AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
! #ifdef AFS_DARWIN80_ENV
!                 fv_slept=1;
!                 /* must release lock, since vnode_recycle will immediately
!                    reclaim if there are no other users */
!                 ReleaseWriteLock(&afs_xvcache);
!                 AFS_GUNLOCK();
!                 /* VREFCOUNT_GT only sees usecounts, not iocounts */
!                 /* so this may fail to actually recycle the vnode now */
!                 if (vnode_recycle(AFSTOV(tvc)))
!                    code=0;
!                 else
!                    code=EBUSY;
!                 AFS_GLOCK();
!                 ObtainWriteLock(&afs_xvcache, 336);
  #else
!                 /*
!                  * vgone() reclaims the vnode, which calls afs_FlushVCache(),
!                  * then it puts the vnode on the free list.
!                  * If we don't do this we end up with a cleaned vnode that's
!                  * not on the free list.
!                  * XXX assume FreeBSD is the same for now.
!                  */
!                 AFS_GUNLOCK();
!                 vgone(AFSTOV(tvc));
!                 fv_slept = 0;
!                 code = 0;
!                 AFS_GLOCK();
! #endif
! #else
!                 code = afs_FlushVCache(tvc, &fv_slept);
  #endif
  		if (code == 0) {
  		    anumber--;
***************
*** 793,799 ****
      if (!freeVCList) {
  	/* none free, making one is better than a panic */
  	afs_stats_cmperf.vcacheXAllocs++;	/* count in case we have a leak */
- 	if (afs_cacheStats == afs_stats_cmperf.vcacheXAllocs) printf("would vlru cycle panic\n");
  	tvc = (struct vcache *)afs_osi_Alloc(sizeof(struct vcache));
  #if defined(AFS_DARWIN_ENV) && !defined(UKERNEL)
  	tvc->v = NULL; /* important to clean this, or use memset 0 */
--- 805,810 ----
***************
*** 842,863 ****
--- 853,927 ----
      RWLOCK_INIT(&tvc->vlock, "vcache vlock");
  #endif /* defined(AFS_SUN5_ENV) */
  
+     tvc->parentVnode = 0;
+     tvc->mvid = NULL;
+     tvc->linkData = NULL;
+     tvc->cbExpires = 0;
+     tvc->opens = 0;
+     tvc->execsOrWriters = 0;
+     tvc->flockCount = 0;
+     tvc->anyAccess = 0;
+     tvc->states = CVInit;
+     tvc->last_looker = 0;
+     tvc->fid = *afid;
+     tvc->asynchrony = -1;
+     tvc->vc_error = 0;
+ #ifdef AFS_TEXT_ENV
+     tvc->flushDV.low = tvc->flushDV.high = AFS_MAXDV;
+ #endif
+     hzero(tvc->mapDV);
+     tvc->truncPos = AFS_NOTRUNC;        /* don't truncate until we need to */
+     hzero(tvc->m.DataVersion);  /* in case we copy it into flushDV */
+     tvc->Access = NULL;
+     tvc->callback = serverp;    /* to minimize chance that clear
+ 				 * request is lost */
+ 
+     i = VCHash(afid);
+ 
+     tvc->hnext = afs_vhashT[i];
+     afs_vhashT[i] = tvc;
+     QAdd(&afs_vhashTV[i], &tvc->vhashq);
+     
+     if ((VLRU.next->prev != &VLRU) || (VLRU.prev->next != &VLRU)) {
+         refpanic("NewVCache VLRU inconsistent");
+     }
+     QAdd(&VLRU, &tvc->vlruq);   /* put in lruq */
+     if ((VLRU.next->prev != &VLRU) || (VLRU.prev->next != &VLRU)) {
+         refpanic("NewVCache VLRU inconsistent2");
+     }
+     if (tvc->vlruq.next->prev != &(tvc->vlruq)) {
+         refpanic("NewVCache VLRU inconsistent3");
+     }
+     if (tvc->vlruq.prev->next != &(tvc->vlruq)) {
+         refpanic("NewVCache VLRU inconsistent4");
+     }
+     vcachegen++;
+     /* it should now be safe to drop the xvcache lock */
  #ifdef AFS_OBSD_ENV
+     ReleaseWriteLock(&afs_xvcache);
      AFS_GUNLOCK();
      afs_nbsd_getnewvnode(tvc);	/* includes one refcount */
      AFS_GLOCK();
+     ObtainWriteLock(&afs_xvcache,337);
      lockinit(&tvc->rwlock, PINOD, "vcache", 0, 0);
  #endif
  #ifdef AFS_DARWIN_ENV
+     ReleaseWriteLock(&afs_xvcache);
      AFS_GUNLOCK();
      afs_darwin_getnewvnode(tvc);	/* includes one refcount */
      AFS_GLOCK();
+     ObtainWriteLock(&afs_xvcache,338);
+ #ifdef AFS_DARWIN80_ENV
+     LOCKINIT(tvc->rwlock);
+ #else
      lockinit(&tvc->rwlock, PINOD, "vcache", 0, 0);
  #endif
+ #endif
  #ifdef AFS_FBSD_ENV
      {
  	struct vnode *vp;
  
+ 	ReleaseWriteLock(&afs_xvcache);
  	AFS_GUNLOCK();
  #if defined(AFS_FBSD60_ENV)
  	if (getnewvnode(MOUNT_AFS, afs_globalVFS, &afs_vnodeops, &vp))
***************
*** 868,873 ****
--- 932,938 ----
  #endif
  	    panic("afs getnewvnode");	/* can't happen */
  	AFS_GLOCK();
+ 	ObtainWriteLock(&afs_xvcache,339);
  	if (tvc->v != NULL) {
  	    /* I'd like to know if this ever happens...
  	     * We don't drop global for the rest of this function,
***************
*** 886,910 ****
  	lockinit(&tvc->rwlock, PINOD, "vcache", 0, 0);
      }
  #endif
-     tvc->parentVnode = 0;
-     tvc->mvid = NULL;
-     tvc->linkData = NULL;
-     tvc->cbExpires = 0;
-     tvc->opens = 0;
-     tvc->execsOrWriters = 0;
-     tvc->flockCount = 0;
-     tvc->anyAccess = 0;
-     tvc->states = 0;
-     tvc->last_looker = 0;
-     tvc->fid = *afid;
-     tvc->asynchrony = -1;
-     tvc->vc_error = 0;
- #ifdef AFS_TEXT_ENV
-     tvc->flushDV.low = tvc->flushDV.high = AFS_MAXDV;
- #endif
-     hzero(tvc->mapDV);
-     tvc->truncPos = AFS_NOTRUNC;	/* don't truncate until we need to */
-     hzero(tvc->m.DataVersion);	/* in case we copy it into flushDV */
  
  #if defined(AFS_OSF_ENV) || defined(AFS_LINUX22_ENV)
      /* Hold it for the LRU (should make count 2) */
--- 951,956 ----
***************
*** 941,949 ****
      afs_BozonInit(&tvc->pvnLock, tvc);
  #endif
  
-     tvc->Access = NULL;
-     tvc->callback = serverp;	/* to minimize chance that clear
- 				 * request is lost */
      /* initialize vnode data, note vrefCount is v.v_count */
  #ifdef	AFS_AIX_ENV
      /* Don't forget to free the gnode space */
--- 987,992 ----
***************
*** 1034,1060 ****
      osi_dnlc_purgedp(tvc);	/* this may be overkill */
      memset((char *)&(tvc->callsort), 0, sizeof(struct afs_q));
      tvc->slocks = NULL;
!     i = VCHash(afid);
!     j = VCHashV(afid);
! 
!     tvc->hnext = afs_vhashT[i];
!     tvc->vhnext = afs_vhashTV[j];
!     afs_vhashT[i] = afs_vhashTV[j] = tvc;
! 
!     if ((VLRU.next->prev != &VLRU) || (VLRU.prev->next != &VLRU)) {
! 	refpanic("NewVCache VLRU inconsistent");
!     }
!     QAdd(&VLRU, &tvc->vlruq);	/* put in lruq */
!     if ((VLRU.next->prev != &VLRU) || (VLRU.prev->next != &VLRU)) {
! 	refpanic("NewVCache VLRU inconsistent2");
!     }
!     if (tvc->vlruq.next->prev != &(tvc->vlruq)) {
! 	refpanic("NewVCache VLRU inconsistent3");
!     }
!     if (tvc->vlruq.prev->next != &(tvc->vlruq)) {
! 	refpanic("NewVCache VLRU inconsistent4");
!     }
!     vcachegen++;
  
      return tvc;
  
--- 1077,1084 ----
      osi_dnlc_purgedp(tvc);	/* this may be overkill */
      memset((char *)&(tvc->callsort), 0, sizeof(struct afs_q));
      tvc->slocks = NULL;
!     tvc->states &=~ CVInit;
!     afs_osi_Wakeup(&tvc->states);
  
      return tvc;
  
***************
*** 1087,1092 ****
--- 1111,1122 ----
      ObtainReadLock(&afs_xvcache);
      for (i = 0; i < VCSIZE; i++) {
  	for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) {
+             if (tvc->states & CVInit) continue;
+ #ifdef AFS_DARWIN80_ENV
+             if (tvc->states & CDeadVnode &&
+                 (tvc->states & (CCore|CUnlinkedDel) ||
+                  tvc->flockCount)) panic("Dead vnode has core/unlinkedel/flock");
+ #endif
  	    if (doflocks && tvc->flockCount != 0) {
  		/* if this entry has an flock, send a keep-alive call out */
  		osi_vnhold(tvc, 0);
***************
*** 1113,1120 ****
  			  AFS_STATS_FS_RPCIDX_EXTENDLOCK, SHARED_LOCK, NULL));
  
  		ReleaseWriteLock(&tvc->lock);
! 		ObtainReadLock(&afs_xvcache);
! 		AFS_FAST_RELE(tvc);
  	    }
  	    didCore = 0;
  	    if ((tvc->states & CCore) || (tvc->states & CUnlinkedDel)) {
--- 1143,1155 ----
  			  AFS_STATS_FS_RPCIDX_EXTENDLOCK, SHARED_LOCK, NULL));
  
  		ReleaseWriteLock(&tvc->lock);
! #ifdef AFS_DARWIN80_ENV
!                 AFS_FAST_RELE(tvc);
!                 ObtainReadLock(&afs_xvcache);
! #else
!                 ObtainReadLock(&afs_xvcache);
!                 AFS_FAST_RELE(tvc);
! #endif
  	    }
  	    didCore = 0;
  	    if ((tvc->states & CCore) || (tvc->states & CUnlinkedDel)) {
***************
*** 1132,1138 ****
  		/*
  		 * That's because if we come in via the CUnlinkedDel bit state path we'll be have 0 refcnt
  		 */
! 		osi_Assert(VREFCOUNT(tvc) > 0);
  		AFS_RWLOCK((vnode_t *) tvc, VRWLOCK_WRITE);
  #endif
  		ObtainWriteLock(&tvc->lock, 52);
--- 1167,1173 ----
  		/*
  		 * That's because if we come in via the CUnlinkedDel bit state path we'll be have 0 refcnt
  		 */
! 		osi_Assert(VREFCOUNT_GT(tvc,0));
  		AFS_RWLOCK((vnode_t *) tvc, VRWLOCK_WRITE);
  #endif
  		ObtainWriteLock(&tvc->lock, 52);
***************
*** 1182,1187 ****
--- 1217,1231 ----
  #if defined(AFS_SGI_ENV)
  		AFS_RWUNLOCK((vnode_t *) tvc, VRWLOCK_WRITE);
  #endif
+ #ifdef AFS_DARWIN80_ENV
+ 		AFS_FAST_RELE(tvc);
+ 		if (didCore) {
+ 		    AFS_RELE(AFSTOV(tvc));
+ 		    /* Matches write code setting CCore flag */
+ 		    crfree(cred);
+ 		}
+ 		ObtainReadLock(&afs_xvcache);
+ #else
  		ObtainReadLock(&afs_xvcache);
  		AFS_FAST_RELE(tvc);
  		if (didCore) {
***************
*** 1189,1194 ****
--- 1233,1239 ----
  		    /* Matches write code setting CCore flag */
  		    crfree(cred);
  		}
+ #endif
  	    }
  	}
      }
***************
*** 1196,1201 ****
--- 1241,1247 ----
  }
  
  
+ 
  /*
   * afs_VerifyVCache
   *
***************
*** 1637,1642 ****
--- 1683,1689 ----
      if (tvc) {
  	if (cached)
  	    *cached = 1;
+ 	osi_Assert((tvc->states & CVInit) == 0);
  	if (tvc->states & CStatd) {
  	    ReleaseSharedLock(&afs_xvcache);
  	    return tvc;
***************
*** 1649,1654 ****
--- 1696,1707 ----
  	newvcache = 1;
  
  	ConvertWToSLock(&afs_xvcache);
+ 	if (!tvc)
+ 	{
+ 		ReleaseSharedLock(&afs_xvcache);
+ 		return NULL;
+ 	}
+ 
  	afs_stats_cmperf.vcacheMisses++;
      }
  
***************
*** 1666,1671 ****
--- 1719,1728 ----
  	return tvc;
      }
  #endif /* AFS_OSF_ENV */
+ #ifdef AFS_DARWIN80_ENV
+ /* Darwin 8.0 only has bufs in nfs, so we shouldn't have to worry about them.
+    What about ubc? */
+ #else
  #if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
      /*
       * XXX - I really don't like this.  Should try to understand better.
***************
*** 1727,1732 ****
--- 1784,1790 ----
  #endif
      }
  #endif
+ #endif
  
      ObtainWriteLock(&afs_xcbhash, 464);
      tvc->states &= ~CUnique;
***************
*** 1777,1785 ****
      if (code) {
  	ReleaseWriteLock(&tvc->lock);
  
! 	ObtainReadLock(&afs_xvcache);
! 	AFS_FAST_RELE(tvc);
! 	ReleaseReadLock(&afs_xvcache);
  	return NULL;
      }
  
--- 1835,1841 ----
      if (code) {
  	ReleaseWriteLock(&tvc->lock);
  
! 	afs_PutVCache(tvc);
  	return NULL;
      }
  
***************
*** 1836,1843 ****
  	tvc->states &= ~CUnique;
  
  	ReleaseReadLock(&tvc->lock);
  	ObtainReadLock(&afs_xvcache);
- 	AFS_FAST_RELE(tvc);
      }
      /* if (tvc) */
      ReleaseReadLock(&afs_xvcache);
--- 1892,1899 ----
  	tvc->states &= ~CUnique;
  
  	ReleaseReadLock(&tvc->lock);
+ 	afs_PutVCache(tvc);
  	ObtainReadLock(&afs_xvcache);
      }
      /* if (tvc) */
      ReleaseReadLock(&afs_xvcache);
***************
*** 1870,1875 ****
--- 1926,1936 ----
  	tvc = afs_NewVCache(&nfid, serverp);
  	newvcache = 1;
  	ConvertWToSLock(&afs_xvcache);
+ 	if (!tvc)
+ 	{
+ 		ReleaseSharedLock(&afs_xvcache);
+ 		return NULL;
+ 	}
      }
  
      ReleaseSharedLock(&afs_xvcache);
***************
*** 1909,1917 ****
  	if (tvp)
  	    afs_PutVolume(tvp, READ_LOCK);
  	ReleaseWriteLock(&tvc->lock);
! 	ObtainReadLock(&afs_xvcache);
! 	AFS_FAST_RELE(tvc);
! 	ReleaseReadLock(&afs_xvcache);
  	return NULL;
      }
  
--- 1970,1976 ----
  	if (tvp)
  	    afs_PutVolume(tvp, READ_LOCK);
  	ReleaseWriteLock(&tvc->lock);
! 	afs_PutVCache(tvc);
  	return NULL;
      }
  
***************
*** 1996,2005 ****
--- 2055,2070 ----
  	afid->Fid.Unique = tvolp->rootUnique;
      }
  
+  rootvc_loop:
      ObtainSharedLock(&afs_xvcache, 7);
      i = VCHash(afid);
      for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) {
  	if (!FidCmp(&(tvc->fid), afid)) {
+             if (tvc->states & CVInit) {
+ 		ReleaseSharedLock(&afs_xvcache);
+ 		afs_osi_Sleep(&tvc->states);
+ 		goto rootvc_loop;
+             }
  #ifdef	AFS_OSF_ENV
  	    /* Grab this vnode, possibly reactivating from the free list */
  	    /* for the present (95.05.25) everything on the hash table is
***************
*** 2012,2017 ****
--- 2077,2095 ----
  	    if (vg)
  		continue;
  #endif /* AFS_OSF_ENV */
+ #ifdef AFS_DARWIN80_ENV
+             int vg;
+             if (tvc->states & CDeadVnode) {
+ 		ReleaseSharedLock(&afs_xvcache);
+ 		afs_osi_Sleep(&tvc->states);
+ 		goto rootvc_loop;
+             }
+             AFS_GUNLOCK();
+             vg = vnode_get(AFSTOV(tvc));        /* this bumps ref count */
+             AFS_GLOCK();
+             if (vg)
+                 continue;
+ #endif
  	    break;
  	}
      }
***************
*** 2022,2030 ****
  	if (tvc)
  	    AFS_RELE(AFSTOV(tvc));
  #endif
- 	tvc = NULL;
  	getNewFid = 1;
  	ReleaseSharedLock(&afs_xvcache);
  	goto newmtpt;
      }
  
--- 2100,2112 ----
  	if (tvc)
  	    AFS_RELE(AFSTOV(tvc));
  #endif
  	getNewFid = 1;
  	ReleaseSharedLock(&afs_xvcache);
+ #ifdef AFS_DARWIN80_ENV
+         if (tvc)
+             vnode_put(AFSTOV(tvc));
+ #endif
+         tvc = NULL;
  	goto newmtpt;
      }
  
***************
*** 2032,2037 ****
--- 2114,2124 ----
  	UpgradeSToWLock(&afs_xvcache, 23);
  	/* no cache entry, better grab one */
  	tvc = afs_NewVCache(afid, NULL);
+ 	if (!tvc)
+ 	{
+ 		ReleaseWriteLock(&afs_xvcache);
+ 		return NULL;
+ 	}
  	newvcache = 1;
  	afs_stats_cmperf.vcacheMisses++;
      } else {
***************
*** 2125,2133 ****
  	if ((tvc->states & CForeign) || (tvc->fid.Fid.Vnode & 1))
  	    osi_dnlc_purgedp(tvc);	/* if it (could be) a directory */
  	ReleaseWriteLock(&tvc->lock);
! 	ObtainReadLock(&afs_xvcache);
! 	AFS_FAST_RELE(tvc);
! 	ReleaseReadLock(&afs_xvcache);
  	return NULL;
      }
  
--- 2212,2218 ----
  	if ((tvc->states & CForeign) || (tvc->fid.Fid.Vnode & 1))
  	    osi_dnlc_purgedp(tvc);	/* if it (could be) a directory */
  	ReleaseWriteLock(&tvc->lock);
! 	afs_PutVCache(tvc);
  	return NULL;
      }
  
***************
*** 2304,2309 ****
--- 2389,2399 ----
  	tvc = afs_NewVCache(afid, NULL);
  	newvcache = 1;
  	ConvertWToSLock(&afs_xvcache);
+ 	if (!tvc)
+ 	{
+ 		ReleaseSharedLock(&afs_xvcache);
+ 		return NULL;
+ 	}
      }
  
      ReleaseSharedLock(&afs_xvcache);
***************
*** 2406,2417 ****
--- 2496,2512 ----
  afs_PutVCache(register struct vcache *avc)
  {
      AFS_STATCNT(afs_PutVCache);
+ #ifdef AFS_DARWIN80_ENV
+     vnode_put(AFSTOV(avc));
+     AFS_FAST_RELE(avc);
+ #else
      /*
       * Can we use a read lock here?
       */
      ObtainReadLock(&afs_xvcache);
      AFS_FAST_RELE(avc);
      ReleaseReadLock(&afs_xvcache);
+ #endif
  }				/*afs_PutVCache */
  
  /*
***************
*** 2442,2450 ****
--- 2537,2560 ----
  
      AFS_STATCNT(afs_FindVCache);
  
+  findloop:
      i = VCHash(afid);
      for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) {
  	if (FidMatches(afid, tvc)) {
+             if (tvc->states & CVInit) {
+ 		int lock;
+ 		lock = CheckLock(&afs_xvcache);
+ 		if (lock > 0)
+ 		    ReleaseReadLock(&afs_xvcache);
+ 		else
+ 		    ReleaseSharedLock(&afs_xvcache);
+ 		afs_osi_Sleep(&tvc->states);
+ 		if (lock > 0)
+ 		    ObtainReadLock(&afs_xvcache);
+ 		else
+ 		    ObtainSharedLock(&afs_xvcache, 341);
+ 		goto findloop;
+             }
  #ifdef  AFS_OSF_ENV
  	    /* Grab this vnode, possibly reactivating from the free list */
  	    int vg;
***************
*** 2454,2459 ****
--- 2564,2591 ----
  	    if (vg)
  		continue;
  #endif /* AFS_OSF_ENV */
+ #ifdef  AFS_DARWIN80_ENV
+             int vg;
+             if (tvc->states & CDeadVnode) {
+ 		int lock;
+ 		lock = CheckLock(&afs_xvcache);
+ 		if (lock > 0)
+ 		    ReleaseReadLock(&afs_xvcache);
+ 		else
+ 		    ReleaseSharedLock(&afs_xvcache);
+ 		afs_osi_Sleep(&tvc->states);
+ 		if (lock > 0)
+ 		    ObtainReadLock(&afs_xvcache);
+ 		else
+ 		    ObtainSharedLock(&afs_xvcache, 341);
+ 		goto findloop;
+             }
+             AFS_GUNLOCK();
+             vg = vnode_get(AFSTOV(tvc));
+             AFS_GLOCK();
+             if (vg)
+                 continue;
+ #endif
  	    break;
  	}
      }
***************
*** 2467,2473 ****
  	if (retry && *retry)
  	    return 0;
  #endif
! #ifdef AFS_DARWIN_ENV
  	tvc->states |= CUBCinit;
  	AFS_GUNLOCK();
  	if (UBCINFOMISSING(AFSTOV(tvc)) ||
--- 2599,2605 ----
  	if (retry && *retry)
  	    return 0;
  #endif
! #if defined(AFS_DARWIN_ENV) && !defined(AFS_DARWIN80_ENV)
  	tvc->states |= CUBCinit;
  	AFS_GUNLOCK();
  	if (UBCINFOMISSING(AFSTOV(tvc)) ||
***************
*** 2556,2564 ****
  
      AFS_STATCNT(afs_FindVCache);
  
- #if defined(AFS_SGI_ENV) && !defined(AFS_SGI53_ENV)
    loop:
- #endif
  
      ObtainSharedLock(&afs_xvcache, 331);
  
--- 2688,2694 ----
***************
*** 2569,2574 ****
--- 2699,2710 ----
  	    && (tvc->fid.Fid.Volume == afid->Fid.Volume)
  	    && ((tvc->fid.Fid.Unique & 0xffffff) == afid->Fid.Unique)
  	    && (tvc->fid.Cell == afid->Cell)) {
+ 	    if (tvc->states & CVInit) {
+ 		int lock;
+ 		ReleaseSharedLock(&afs_xvcache);
+ 		afs_osi_Sleep(&tvc->states);
+ 		goto loop;
+             }
  #ifdef  AFS_OSF_ENV
  	    /* Grab this vnode, possibly reactivating from the free list */
  	    int vg;
***************
*** 2580,2585 ****
--- 2716,2736 ----
  		continue;
  	    }
  #endif /* AFS_OSF_ENV */
+ #ifdef  AFS_DARWIN80_ENV
+             int vg;
+             if (tvc->states & CDeadVnode) {
+ 		ReleaseSharedLock(&afs_xvcache);
+ 		afs_osi_Sleep(&tvc->states);
+ 		goto loop;
+             }
+             AFS_GUNLOCK();
+             vg = vnode_get(AFSTOV(tvc));
+             AFS_GLOCK();
+             if (vg) {
+                 /* This vnode no longer exists. */
+                 continue;
+             }
+ #endif /* AFS_DARWIN80_ENV */
  	    count++;
  	    if (found_tvc) {
  		/* Duplicates */
***************
*** 2590,2595 ****
--- 2741,2751 ----
  #endif
  		afs_duplicate_nfs_fids++;
  		ReleaseSharedLock(&afs_xvcache);
+ #ifdef AFS_DARWIN80_ENV
+                 /* Drop our reference counts. */
+                 vnode_put(AFSTOV(tvc));
+                 vnode_put(AFSTOV(found_tvc));
+ #endif
  		return count;
  	    }
  	    found_tvc = tvc;
***************
*** 2724,2733 ****
  #endif /* AFS_SGI62_ENV */
      }
  #endif
- 
      QInit(&VLRU);
! 
! 
  }
  
  /*
--- 2880,2888 ----
  #endif /* AFS_SGI62_ENV */
      }
  #endif
      QInit(&VLRU);
!     for(i = 0; i < VCSIZE; ++i)
! 	QInit(&afs_vhashTV[i]);
  }
  
  /*
***************
*** 2781,2787 ****
  		    vms_delete(tvc->segid);
  		    AFS_GLOCK();
  		    tvc->segid = tvc->vmh = NULL;
! 		    if (VREFCOUNT(tvc))
  			osi_Panic("flushVcache: vm race");
  		}
  		if (tvc->credp) {
--- 2936,2942 ----
  		    vms_delete(tvc->segid);
  		    AFS_GLOCK();
  		    tvc->segid = tvc->vmh = NULL;
! 		    if (VREFCOUNT_GT(tvc,0))
  			osi_Panic("flushVcache: vm race");
  		}
  		if (tvc->credp) {
***************
*** 2803,2809 ****
  
  		afs_FreeAllAxs(&(tvc->Access));
  	    }
! 	    afs_vhashT[i] = afs_vhashTV[i] = 0;
  	}
      }
      /*
--- 2958,2964 ----
  
  		afs_FreeAllAxs(&(tvc->Access));
  	    }
! 	    afs_vhashT[i] = 0;
  	}
      }
      /*
***************
*** 2828,2832 ****
      RWLOCK_INIT(&afs_xvcache, "afs_xvcache");
      LOCK_INIT(&afs_xvcb, "afs_xvcb");
      QInit(&VLRU);
! 
  }
--- 2983,2988 ----
      RWLOCK_INIT(&afs_xvcache, "afs_xvcache");
      LOCK_INIT(&afs_xvcb, "afs_xvcb");
      QInit(&VLRU);
!     for(i = 0; i < VCSIZE; ++i)
! 	QInit(&afs_vhashTV[i]);
  }
Index: openafs/src/afs/afs_volume.c
diff -c openafs/src/afs/afs_volume.c:1.26.2.1 openafs/src/afs/afs_volume.c:1.26.2.2
*** openafs/src/afs/afs_volume.c:1.26.2.1	Tue Dec  7 01:12:12 2004
--- openafs/src/afs/afs_volume.c	Wed Oct  5 01:58:27 2005
***************
*** 19,25 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_volume.c,v 1.26.2.1 2004/12/07 06:12:12 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
--- 19,25 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_volume.c,v 1.26.2.2 2005/10/05 05:58:27 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
***************
*** 284,289 ****
--- 284,290 ----
  
      /* next ensure all mt points are re-evaluated */
      if (nvols || (flags & (AFS_VOLCHECK_FORCE | AFS_VOLCHECK_MTPTS))) {
+ loop:
  	ObtainReadLock(&afs_xvcache);
  	for (i = 0; i < VCSIZE; i++) {
  	    for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) {
***************
*** 306,311 ****
--- 307,324 ----
  		    && (inVolList(&tvc->fid, nvols, volumeID, cellID)
  			|| (flags & AFS_VOLCHECK_FORCE))) {
  
+                     if (tvc->states & CVInit) {
+                         ReleaseReadLock(&afs_xvcache);
+ 			afs_osi_Sleep(&tvc->states);
+                         goto loop;
+                     }
+ #ifdef AFS_DARWIN80_ENV
+                     if (tvc->states & CDeadVnode) {
+                         ReleaseReadLock(&afs_xvcache);
+ 			afs_osi_Sleep(&tvc->states);
+                         goto loop;
+                     }
+ #endif
  		    AFS_FAST_HOLD(tvc);
  		    ReleaseReadLock(&afs_xvcache);
  
***************
*** 317,326 ****
--- 330,345 ----
  		    if (tvc->fid.Fid.Vnode & 1 || (vType(tvc) == VDIR))
  			osi_dnlc_purgedp(tvc);
  
+ #ifdef AFS_DARWIN80_ENV
+ 		    /* our tvc ptr is still good until now */
+ 		    AFS_FAST_RELE(tvc);
+ 		    ObtainReadLock(&afs_xvcache);
+ #else
  		    ObtainReadLock(&afs_xvcache);
  
  		    /* our tvc ptr is still good until now */
  		    AFS_FAST_RELE(tvc);
+ #endif
  		}
  	    }
  	}
Index: openafs/src/afs/lock.h
diff -c openafs/src/afs/lock.h:1.13.2.1 openafs/src/afs/lock.h:1.13.2.2
*** openafs/src/afs/lock.h:1.13.2.1	Wed Apr 13 22:31:32 2005
--- openafs/src/afs/lock.h	Wed Oct  5 01:58:27 2005
***************
*** 107,113 ****
--- 107,117 ----
  #define MyPidxx current->pid
  #else
  #if defined(AFS_DARWIN_ENV)
+ #if defined(AFS_DARWIN80_ENV)
+ #define MyPidxx (proc_selfpid())
+ #else
  #define MyPidxx (current_proc()->p_pid )
+ #endif
  #else
  #if defined(AFS_FBSD_ENV)
  #define MyPidxx (curproc->p_pid )
Index: openafs/src/afs/sysincludes.h
diff -c openafs/src/afs/sysincludes.h:1.28.2.7 openafs/src/afs/sysincludes.h:1.28.2.9
*** openafs/src/afs/sysincludes.h:1.28.2.7	Mon Jul 11 15:13:47 2005
--- openafs/src/afs/sysincludes.h	Thu Oct 13 13:55:33 2005
***************
*** 39,45 ****
--- 39,47 ----
  #include <ufs/ffs/fs.h>
  #include <ufs/ufs/quota.h>
  #include <ufs/ufs/inode.h>
+ #ifndef AFS_OBSD38_ENV
  #include <ufs/ufs/extattr.h>
+ #endif
  #include <ufs/ufs/ufsmount.h>
  #ifndef MLEN
  #include <sys/mbuf.h>
***************
*** 217,223 ****
  #  include "h/dir.h"
  #endif /* SGI || SUN || HPUX */
  
! #if !defined(AFS_SGI64_ENV) && !defined(AFS_FBSD_ENV)
  #include "h/user.h"
  #endif /* AFS_SGI64_ENV */
  #define	MACH_USER_API	1
--- 219,225 ----
  #  include "h/dir.h"
  #endif /* SGI || SUN || HPUX */
  
! #if !defined(AFS_SGI64_ENV) && !defined(AFS_FBSD_ENV) && !defined(AFS_DARWIN80_ENV)
  #include "h/user.h"
  #endif /* AFS_SGI64_ENV */
  #define	MACH_USER_API	1
***************
*** 254,259 ****
--- 256,265 ----
  #  include <sys/uio.h>
  #  include <sys/mount.h>
  #  include <sys/namei.h>
+ #ifdef AFS_DARWIN80_ENV
+ #  include <sys/kauth.h>
+ #include <string.h>
+ #endif
  #  include <sys/vnode.h>
  #  include <sys/queue.h>
  #  include <sys/malloc.h>
***************
*** 274,282 ****
--- 280,290 ----
  #undef timeout_fcn_t
  #define _DIR_H_
  #define doff_t          int32_t
+ #ifndef AFS_DARWIN80_ENV
  #  include <ufs/ufs/quota.h>
  #  include <ufs/ufs/inode.h>
  #  include <ufs/ffs/fs.h>
+ #endif
  #else
  #  include "h/vfs.h"
  #  include "h/vnode.h"
Index: openafs/src/afs/AIX/osi_inode.c
diff -c openafs/src/afs/AIX/osi_inode.c:1.8.2.1 openafs/src/afs/AIX/osi_inode.c:1.8.2.2
*** openafs/src/afs/AIX/osi_inode.c:1.8.2.1	Wed Aug 25 03:16:15 2004
--- openafs/src/afs/AIX/osi_inode.c	Sat Oct 15 10:24:25 2005
***************
*** 17,23 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/AIX/osi_inode.c,v 1.8.2.1 2004/08/25 07:16:15 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 17,23 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/AIX/osi_inode.c,v 1.8.2.2 2005/10/15 14:24:25 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 144,150 ****
  
      a.dev = dev;
      a.ans = NULL;
!     vfs_search(devtovfs_func, &a);
      return a.ans;
  }
  
--- 144,150 ----
  
      a.dev = dev;
      a.ans = NULL;
!     vfs_search(devtovfs_func, (caddr_t) &a);
      return a.ans;
  }
  
Index: openafs/src/afs/AIX/osi_vnodeops.c
diff -c openafs/src/afs/AIX/osi_vnodeops.c:1.15 openafs/src/afs/AIX/osi_vnodeops.c:1.15.2.1
*** openafs/src/afs/AIX/osi_vnodeops.c:1.15	Tue Mar 16 21:29:39 2004
--- openafs/src/afs/AIX/osi_vnodeops.c	Sat Oct 15 10:24:25 2005
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/AIX/osi_vnodeops.c,v 1.15 2004/03/17 02:29:39 shadow Exp $");
  
  #include "h/systm.h"
  #include "h/types.h"
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/AIX/osi_vnodeops.c,v 1.15.2.1 2005/10/15 14:24:25 shadow Exp $");
  
  #include "h/systm.h"
  #include "h/types.h"
***************
*** 55,188 ****
  #include "afsincludes.h"
  
  
- /*
-  * declare all the functions so they can be used to init the table
-  */
- /* creation/naming/deletion */
- int afs_gn_link();
- int afs_gn_mkdir();
- int afs_gn_mknod();
- int afs_gn_remove();
- int afs_gn_rename();
- int afs_gn_rmdir();
- /* lookup, file handle stuff */
- int afs_gn_lookup();
- int afs_gn_fid();
- /* access to files */
- int afs_gn_open();
- int afs_gn_create();
- int afs_gn_hold();
- int afs_gn_rele();
- int afs_gn_close();
- int afs_gn_map();
- int afs_gn_unmap();
- /* manipulate attributes of files */
- int afs_gn_access();
- int afs_gn_getattr();
- int afs_gn_setattr();
- /* data update operations */
- int afs_gn_fclear();
- int afs_gn_fsync();
- int afs_gn_ftrunc();
- int afs_gn_rdwr();
- int afs_gn_lockctl();
- /* extensions */
- int afs_gn_ioctl();
- int afs_gn_readlink();
- int afs_gn_select();
- int afs_gn_symlink();
- int afs_gn_readdir();
- /* buffer ops */
- int afs_gn_strategy();
- /* security things */
- int afs_gn_revoke();
- int afs_gn_getacl();
- int afs_gn_setacl();
- int afs_gn_getpcl();
- int afs_gn_setpcl();
- int afs_gn_enosys();
- 
- 
- /*
-  * declare a struct vnodeops and initialize it with ptrs to all functions
-  */
- struct vnodeops afs_gn_vnodeops = {
-     /* creation/naming/deletion */
-     afs_gn_link,
-     afs_gn_mkdir,
-     afs_gn_mknod,
-     afs_gn_remove,
-     afs_gn_rename,
-     afs_gn_rmdir,
-     /* lookup, file handle stuff */
-     afs_gn_lookup,
-     afs_gn_fid,
-     /* access to files */
-     afs_gn_open,
-     afs_gn_create,
-     afs_gn_hold,
-     afs_gn_rele,
-     afs_gn_close,
-     afs_gn_map,
-     afs_gn_unmap,
-     /* manipulate attributes of files */
-     afs_gn_access,
-     afs_gn_getattr,
-     afs_gn_setattr,
-     /* data update operations */
-     afs_gn_fclear,
-     afs_gn_fsync,
-     afs_gn_ftrunc,
-     afs_gn_rdwr,
-     afs_gn_lockctl,
-     /* extensions */
-     afs_gn_ioctl,
-     afs_gn_readlink,
-     afs_gn_select,
-     afs_gn_symlink,
-     afs_gn_readdir,
-     /* buffer ops */
-     afs_gn_strategy,
-     /* security things */
-     afs_gn_revoke,
-     afs_gn_getacl,
-     afs_gn_setacl,
-     afs_gn_getpcl,
-     afs_gn_setpcl,
-     afs_gn_enosys,		/* vn_seek */
-     afs_gn_enosys,		/* vn_fsync_range */
-     afs_gn_enosys,		/* vn_create_attr */
-     afs_gn_enosys,		/* vn_finfo */
-     afs_gn_enosys,		/* vn_map_lloff */
-     afs_gn_enosys,		/* vn_readdir_eofp */
-     afs_gn_enosys,		/* vn_rdwr_attr */
-     afs_gn_enosys,		/* vn_memcntl */
-     afs_gn_enosys,		/* vn_spare7 */
-     afs_gn_enosys,		/* vn_spare8 */
-     afs_gn_enosys,		/* vn_spare9 */
-     afs_gn_enosys,		/* vn_spareA */
-     afs_gn_enosys,		/* vn_spareB */
-     afs_gn_enosys,		/* vn_spareC */
-     afs_gn_enosys,		/* vn_spareD */
-     afs_gn_enosys,		/* vn_spareE */
-     afs_gn_enosys		/* vn_spareF */
- #ifdef AFS_AIX51_ENV
- 	, afs_gn_enosys,	/* pagerBackRange */
-     afs_gn_enosys,		/* pagerGetFileSize */
-     afs_gn_enosys,		/* pagerReadAhead */
-     afs_gn_enosys,		/* pagerWriteBehind */
-     afs_gn_enosys		/* pagerEndCopy */
- #endif
- };
- struct vnodeops *afs_ops = &afs_gn_vnodeops;
- 
- 
  int
! afs_gn_link(vp, dp, name, cred)
!      struct vnode *vp;
!      struct vnode *dp;
!      char *name;
!      struct ucred *cred;
  {
      int error;
  
--- 55,65 ----
  #include "afsincludes.h"
  
  
  int
! afs_gn_link(struct vnode *vp, 
! 	    struct vnode *dp, 
! 	    char *name, 
! 	    struct ucred *cred)
  {
      int error;
  
***************
*** 195,209 ****
  
  
  int
! afs_gn_mkdir(dp, name, Mode, cred)
!      struct vnode *dp;
!      char *name;
! #ifdef AFS_AIX51_ENV
!      int32long64_t Mode;
! #else
!      int Mode;
! #endif
!      struct ucred *cred;
  {
      struct vattr va;
      struct vnode *vp;
--- 72,81 ----
  
  
  int
! afs_gn_mkdir(struct vnode *dp, 
! 	     char *name, 
! 	     int32long64_t Mode, 
! 	     struct ucred *cred)
  {
      struct vattr va;
      struct vnode *vp;
***************
*** 226,241 ****
  
  
  int
! afs_gn_mknod(dp, name, Mode, dev, cred)
!      struct vnode *dp;
!      char *name;
! #ifdef AFS_AIX51_ENV
!      int Mode;
! #else
!      int Mode;
! #endif
!      dev_t dev;
!      struct ucred *cred;
  {
      struct vattr va;
      struct vnode *vp;
--- 98,108 ----
  
  
  int
! afs_gn_mknod(struct vnode *dp, 
! 	     char *name, 
! 	     int32long64_t Mode, 
! 	     dev_t dev, 
! 	     struct ucred *cred)
  {
      struct vattr va;
      struct vnode *vp;
***************
*** 248,254 ****
      va.va_mode = (mode & 07777) & ~get_umask();
  
  /**** I'm not sure if suser() should stay here since it makes no sense in AFS; however the documentation says that one "should be super-user unless making a FIFO file. Others systems such as SUN do this checking in the early stages of mknod (before the abstraction), so it's equivalently the same! *****/
!     if (va.va_type != VFIFO && !suser(&error))
  	return (EPERM);
      switch (va.va_type) {
      case VDIR:
--- 115,121 ----
      va.va_mode = (mode & 07777) & ~get_umask();
  
  /**** I'm not sure if suser() should stay here since it makes no sense in AFS; however the documentation says that one "should be super-user unless making a FIFO file. Others systems such as SUN do this checking in the early stages of mknod (before the abstraction), so it's equivalently the same! *****/
!     if (va.va_type != VFIFO && !suser((char *)&error))
  	return (EPERM);
      switch (va.va_type) {
      case VDIR:
***************
*** 262,268 ****
      case VBLK:
  	va.va_rdev = dev;
      default:
! 	error = afs_create(dp, name, &va, NONEXCL, mode, &vp, cred);
      }
      if (!error) {
  	AFS_RELE(vp);
--- 129,135 ----
      case VBLK:
  	va.va_rdev = dev;
      default:
! 	error = afs_create(VTOAFS(dp), name, &va, NONEXCL, mode, (struct vcache **)&vp, cred);
      }
      if (!error) {
  	AFS_RELE(vp);
***************
*** 275,285 ****
  
  
  int
! afs_gn_remove(vp, dp, name, cred)
!      struct vnode *vp;		/* Ignored in AFS */
!      struct vnode *dp;
!      char *name;
!      struct ucred *cred;
  {
      int error;
  
--- 142,151 ----
  
  
  int
! afs_gn_remove(struct vnode *vp,		/* Ignored in AFS */
!               struct vnode * dp, 
! 	      char *name, 
! 	      struct ucred *cred)
  {
      int error;
  
***************
*** 292,305 ****
  
  
  int
! afs_gn_rename(vp, dp, name, tp, tdp, tname, cred)
!      struct vnode *dp;
!      char *name;
!      struct vnode *vp;		/* Ignored in AFS */
!      struct vnode *tp;		/* Ignored in AFS */
!      struct vnode *tdp;
!      char *tname;
!      struct ucred *cred;
  {
      int error;
  
--- 158,170 ----
  
  
  int
! afs_gn_rename(struct vnode *vp, 		/* Ignored in AFS */
! 	      struct vnode *dp, 
! 	      char *name, 
! 	      struct vnode *tp, 		/* Ignored in AFS */
! 	      struct vnode *tdp, 
! 	      char *tname, 
! 	      struct ucred *cred)
  {
      int error;
  
***************
*** 313,323 ****
  
  
  int
! afs_gn_rmdir(vp, dp, name, cred)
!      struct vnode *vp;		/* Ignored in AFS */
!      struct vnode *dp;
!      char *name;
!      struct ucred *cred;
  {
      int error;
  
--- 178,187 ----
  
  
  int
! afs_gn_rmdir(struct vnode *vp, 		/* Ignored in AFS */
! 	     struct vnode *dp, 
! 	     char *name, 
! 	     struct ucred *cred)
  {
      int error;
  
***************
*** 334,350 ****
  
  
  int
! afs_gn_lookup(dp, vpp, name, Flags, vattrp, cred)
!      struct vattr *vattrp;
!      struct vnode *dp;
!      struct vnode **vpp;
!      char *name;
! #ifdef AFS_AIX51_ENV
!      int32long64_t Flags;	/* includes FOLLOW... */
! #else
!      afs_uint32 Flags;		/* includes FOLLOW... */
! #endif
!      struct ucred *cred;
  {
      int error;
      int flags = Flags;
--- 198,209 ----
  
  
  int
! afs_gn_lookup(struct vnode *dp, 
! 	      struct vnode **vpp, 
! 	      char *name, 
! 	      int32long64_t Flags, 	/* includes FOLLOW... */
! 	      struct vattr *vattrp, 
! 	      struct ucred *cred)
  {
      int error;
      int flags = Flags;
***************
*** 360,369 ****
  
  
  int
! afs_gn_fid(vp, fidp, cred)
!      struct vnode *vp;
!      struct fid *fidp;
!      struct ucred *cred;
  {
      int error;
  
--- 219,227 ----
  
  
  int
! afs_gn_fid(struct vnode *vp, 
! 	struct fid *fidp, 
! 	struct ucred *cred)
  {
      int error;
  
***************
*** 376,392 ****
  
  
  int
! afs_gn_open(vp, Flags, ext, vinfop, cred)
!      struct vnode *vp;
! #ifdef AFS_AIX51_ENV
!      int32long64_t Flags;
!      ext_t ext;			/* Ignored in AFS */
! #else
!      int Flags;
!      int ext;			/* Ignored in AFS */
! #endif
!      struct ucred **vinfop;	/* return ptr for fp->f_vinfo, used as fp->f_cred */
!      struct ucred *cred;
  {
      int error;
      struct vattr va;
--- 234,244 ----
  
  
  int
! afs_gn_open(struct vnode *vp, 
! 	    int32long64_t Flags, 
! 	    ext_t ext, 
! 	    struct ucred **vinfop, 
! 	    struct ucred *cred)
  {
      int error;
      struct vattr va;
***************
*** 411,427 ****
  	afs_osi_Sleep(&tvp->opens);
      }
  
!     error = afs_access(vp, modes, cred);
      if (error) {
  	goto abort;
      }
  
!     error = afs_open(&vp, flags, cred);
      if (!error) {
  	if (flags & FTRUNC) {
  	    VATTR_NULL(&va);
  	    va.va_size = 0;
! 	    error = afs_setattr(vp, &va, cred);
  	}
  
  	if (flags & FNSHARE)
--- 263,279 ----
  	afs_osi_Sleep(&tvp->opens);
      }
  
!     error = afs_access(VTOAFS(vp), modes, cred);
      if (error) {
  	goto abort;
      }
  
!     error = afs_open((struct vcache **) &vp, flags, cred);
      if (!error) {
  	if (flags & FTRUNC) {
  	    VATTR_NULL(&va);
  	    va.va_size = 0;
! 	    error = afs_setattr(VTOAFS(vp), &va, cred);
  	}
  
  	if (flags & FNSHARE)
***************
*** 447,465 ****
  
  
  int
! afs_gn_create(dp, vpp, Flags, name, Mode, vinfop, cred)
!      struct vnode *dp;
!      struct vnode **vpp;
!      char *name;
! #ifdef AFS_AIX51_ENV
!      int32long64_t Flags;
!      int32long64_t Mode;
! #else
!      int Flags;
!      int Mode;
! #endif
!      struct ucred **vinfop;	/* return ptr for fp->f_vinfo, used as fp->f_cred */
!      struct ucred *cred;
  {
      struct vattr va;
      enum vcexcl exclusive;
--- 299,312 ----
  
  
  int
! afs_gn_create(struct vnode *dp, 
! 	      struct vnode **vpp, 
! 	      int32long64_t Flags, 
! 	      char *name, 
! 	      int32long64_t Mode, 
! 	      struct ucred **vinfop, /* return ptr for fp->f_vinfo, used as fp->f_cred */
! 	      struct ucred *cred)
! 
  {
      struct vattr va;
      enum vcexcl exclusive;
***************
*** 481,487 ****
  	modes |= X_ACC;
      if ((flags & FWRITE) || (flags & FTRUNC))
  	modes |= W_ACC;
!     error = afs_create(dp, name, &va, exclusive, modes, vpp, cred);
      if (error) {
  	return error;
      }
--- 328,334 ----
  	modes |= X_ACC;
      if ((flags & FWRITE) || (flags & FTRUNC))
  	modes |= W_ACC;
!     error = afs_create(VTOAFS(dp), name, &va, exclusive, modes, (struct vcache **)vpp, cred);
      if (error) {
  	return error;
      }
***************
*** 502,508 ****
  	 * execsOrWriters flag (else we'll be treated as the sun's "core"
  	 * case). */
  	*vinfop = cred;		/* save user creds in fp->f_vinfo */
! 	error = afs_open(vpp, flags, cred);
      }
      afs_Trace4(afs_iclSetp, CM_TRACE_GCREATE, ICL_TYPE_POINTER, dp,
  	       ICL_TYPE_STRING, name, ICL_TYPE_LONG, mode, ICL_TYPE_LONG,
--- 349,355 ----
  	 * execsOrWriters flag (else we'll be treated as the sun's "core"
  	 * case). */
  	*vinfop = cred;		/* save user creds in fp->f_vinfo */
! 	error = afs_open((struct vcache **)vpp, flags, cred);
      }
      afs_Trace4(afs_iclSetp, CM_TRACE_GCREATE, ICL_TYPE_POINTER, dp,
  	       ICL_TYPE_STRING, name, ICL_TYPE_LONG, mode, ICL_TYPE_LONG,
***************
*** 512,519 ****
  
  
  int
! afs_gn_hold(vp)
!      struct vnode *vp;
  {
      AFS_STATCNT(afs_gn_hold);
      ++(vp->v_count);
--- 359,365 ----
  
  
  int
! afs_gn_hold(struct vnode *vp)
  {
      AFS_STATCNT(afs_gn_hold);
      ++(vp->v_count);
***************
*** 523,530 ****
  int vmPageHog = 0;
  
  int
! afs_gn_rele(vp)
!      struct vnode *vp;
  {
      struct vcache *vcp = VTOAFS(vp);
      int error = 0;
--- 369,375 ----
  int vmPageHog = 0;
  
  int
! afs_gn_rele(struct vnode *vp)
  {
      struct vcache *vcp = VTOAFS(vp);
      int error = 0;
***************
*** 544,558 ****
  
  
  int
! afs_gn_close(vp, Flags, vinfo, cred)
!      struct vnode *vp;
! #ifdef AFS_AIX51_ENV
!      int32long64_t Flags;
! #else
!      int Flags;
! #endif
!      caddr_t vinfo;		/* Ignored in AFS */
!      struct ucred *cred;
  {
      int error;
      struct vcache *tvp = VTOAFS(vp);
--- 389,398 ----
  
  
  int
! afs_gn_close(struct vnode *vp, 
! 	     int32long64_t Flags, 
! 	     caddr_t vinfo, 		/* Ignored in AFS */
! 	     struct ucred *cred)
  {
      int error;
      struct vcache *tvp = VTOAFS(vp);
***************
*** 573,587 ****
  
  
  int
! afs_gn_map(vp, addr, Len, Off, Flag, cred)
!      struct vnode *vp;
!      caddr_t addr;
! #ifdef AFS_AIX51_ENV
!      uint32long64_t Len, Off, Flag;
! #else
!      u_int Len, Off, Flag;
! #endif
!      struct ucred *cred;
  {
      struct vcache *vcp = VTOAFS(vp);
      struct vrequest treq;
--- 413,424 ----
  
  
  int
! afs_gn_map(struct vnode *vp, 
! 	   caddr_t addr, 
! 	   uint32long64_t Len, 
! 	   uint32long64_t Off, 
! 	   uint32long64_t Flag, 
! 	   struct ucred *cred)
  {
      struct vcache *vcp = VTOAFS(vp);
      struct vrequest treq;
***************
*** 612,618 ****
  #endif
  	/* Consider  V_INTRSEG too for interrupts */
  	if (error =
! 	    vms_create(&vcp->segid, V_CLIENT, vcp->v.v_gnode, tlen, 0, 0)) {
  	    ReleaseWriteLock(&vcp->lock);
  	    return (EOPNOTSUPP);
  	}
--- 449,455 ----
  #endif
  	/* Consider  V_INTRSEG too for interrupts */
  	if (error =
! 	    vms_create(&vcp->segid, V_CLIENT, (dev_t) vcp->v.v_gnode, tlen, 0, 0)) {
  	    ReleaseWriteLock(&vcp->lock);
  	    return (EOPNOTSUPP);
  	}
***************
*** 650,663 ****
  
  
  int
! afs_gn_unmap(vp, flag, cred)
!      struct vnode *vp;
! #ifdef AFS_AIX51_ENV
!      int32long64_t flag;
! #else
!      int flag;
! #endif
!      struct ucred *cred;
  {
      struct vcache *vcp = VTOAFS(vp);
      AFS_STATCNT(afs_gn_unmap);
--- 487,495 ----
  
  
  int
! afs_gn_unmap(struct vnode *vp, 
! 	     int32long64_t flag, 
! 	     struct ucred *cred)
  {
      struct vcache *vcp = VTOAFS(vp);
      AFS_STATCNT(afs_gn_unmap);
***************
*** 679,694 ****
  
  
  int
! afs_gn_access(vp, Mode, Who, cred)
!      struct vnode *vp;
! #ifdef AFS_AIX51_ENV
!      int32long64_t Mode;
!      int32long64_t Who;
! #else
!      int Mode;
!      int Who;
! #endif
!      struct ucred *cred;
  {
      int error;
      struct vattr vattr;
--- 511,520 ----
  
  
  int
! afs_gn_access(struct vnode *vp, 
! 	      int32long64_t Mode, 
! 	      int32long64_t Who, 
! 	      struct ucred *cred)
  {
      int error;
      struct vattr vattr;
***************
*** 701,711 ****
  	goto out;
      }
  
!     error = afs_access(vp, mode, cred);
      if (!error) {
  	/* Additional testing */
  	if (who == ACC_OTHERS || who == ACC_ANY) {
! 	    error = afs_getattr(vp, &vattr, cred);
  	    if (!error) {
  		if (who == ACC_ANY) {
  		    if (((vattr.va_mode >> 6) & mode) == mode) {
--- 527,537 ----
  	goto out;
      }
  
!     error = afs_access(VTOAFS(vp), mode, cred);
      if (!error) {
  	/* Additional testing */
  	if (who == ACC_OTHERS || who == ACC_ANY) {
! 	    error = afs_getattr(VTOAFS(vp), &vattr, cred);
  	    if (!error) {
  		if (who == ACC_ANY) {
  		    if (((vattr.va_mode >> 6) & mode) == mode) {
***************
*** 719,725 ****
  		    error = EACCES;
  	    }
  	} else if (who == ACC_ALL) {
! 	    error = afs_getattr(vp, &vattr, cred);
  	    if (!error) {
  		if ((!((vattr.va_mode >> 6) & mode))
  		    || (!((vattr.va_mode >> 3) & mode))
--- 545,551 ----
  		    error = EACCES;
  	    }
  	} else if (who == ACC_ALL) {
! 	    error = afs_getattr(VTOAFS(vp), &vattr, cred);
  	    if (!error) {
  		if ((!((vattr.va_mode >> 6) & mode))
  		    || (!((vattr.va_mode >> 3) & mode))
***************
*** 739,753 ****
  
  
  int
! afs_gn_getattr(vp, vattrp, cred)
!      struct vnode *vp;
!      struct vattr *vattrp;
!      struct ucred *cred;
  {
      int error;
  
      AFS_STATCNT(afs_gn_getattr);
!     error = afs_getattr(vp, vattrp, cred);
      afs_Trace2(afs_iclSetp, CM_TRACE_GGETATTR, ICL_TYPE_POINTER, vp,
  	       ICL_TYPE_LONG, error);
      return (error);
--- 565,578 ----
  
  
  int
! afs_gn_getattr(struct vnode *vp, 
! 	       struct vattr *vattrp, 
! 	       struct ucred *cred)
  {
      int error;
  
      AFS_STATCNT(afs_gn_getattr);
!     error = afs_getattr(VTOAFS(vp), vattrp, cred);
      afs_Trace2(afs_iclSetp, CM_TRACE_GGETATTR, ICL_TYPE_POINTER, vp,
  	       ICL_TYPE_LONG, error);
      return (error);
***************
*** 755,774 ****
  
  
  int
! afs_gn_setattr(vp, op, arg1, arg2, arg3, cred)
!      struct vnode *vp;
! #ifdef AFS_AIX51_ENV
!      int32long64_t op;
!      int32long64_t arg1;
!      int32long64_t arg2;
!      int32long64_t arg3;
! #else
!      int op;
!      int arg1;
!      int arg2;
!      int arg3;
! #endif
!      struct ucred *cred;
  {
      struct vattr va;
      int error = 0;
--- 580,591 ----
  
  
  int
! afs_gn_setattr(struct vnode *vp, 
! 	       int32long64_t op, 
! 	       int32long64_t arg1, 
! 	       int32long64_t arg2, 
! 	       int32long64_t arg3, 
! 	       struct ucred *cred)
  {
      struct vattr va;
      int error = 0;
***************
*** 805,811 ****
  	goto out;
      }
  
!     error = afs_setattr(vp, &va, cred);
    out:
      afs_Trace2(afs_iclSetp, CM_TRACE_GSETATTR, ICL_TYPE_POINTER, vp,
  	       ICL_TYPE_LONG, error);
--- 622,628 ----
  	goto out;
      }
  
!     error = afs_setattr(VTOAFS(vp), &va, cred);
    out:
      afs_Trace2(afs_iclSetp, CM_TRACE_GSETATTR, ICL_TYPE_POINTER, vp,
  	       ICL_TYPE_LONG, error);
***************
*** 815,837 ****
  
  char zero_buffer[PAGESIZE];
  int
! afs_gn_fclear(vp, flags, offset, length, vinfo, cred)
!      struct vnode *vp;
! #ifdef AFS_AIX51_ENV
!      int32long64_t flags;
! #else
!      int flags;
! #endif
!      offset_t offset;
!      offset_t length;
!      caddr_t vinfo;
!      struct ucred *cred;
  {
      int i, len, error = 0;
      struct iovec iov;
      struct uio uio;
      static int fclear_init = 0;
!     register struct vcache *avc = VTOAFS(vp);
  
      AFS_STATCNT(afs_gn_fclear);
      if (!fclear_init) {
--- 632,649 ----
  
  char zero_buffer[PAGESIZE];
  int
! afs_gn_fclear(struct vnode *vp, 
! 	      int32long64_t flags, 
! 	      offset_t offset, 
! 	      offset_t length, 
! 	      caddr_t vinfo, 
! 	      struct ucred *cred)
  {
      int i, len, error = 0;
      struct iovec iov;
      struct uio uio;
      static int fclear_init = 0;
!     struct vcache *avc = VTOAFS(vp);
  
      AFS_STATCNT(afs_gn_fclear);
      if (!fclear_init) {
***************
*** 860,866 ****
  	uio.afsio_iovcnt = 1;
  	uio.afsio_seg = AFS_UIOSYS;
  	uio.afsio_resid = iov.iov_len;
! 	if (error = afs_rdwr(vp, &uio, UIO_WRITE, 0, cred))
  	    break;
      }
      afs_Trace4(afs_iclSetp, CM_TRACE_GFCLEAR, ICL_TYPE_POINTER, vp,
--- 672,678 ----
  	uio.afsio_iovcnt = 1;
  	uio.afsio_seg = AFS_UIOSYS;
  	uio.afsio_resid = iov.iov_len;
! 	if (error = afs_rdwr(VTOAFS(vp), &uio, UIO_WRITE, 0, cred))
  	    break;
      }
      afs_Trace4(afs_iclSetp, CM_TRACE_GFCLEAR, ICL_TYPE_POINTER, vp,
***************
*** 871,886 ****
  
  
  int
! afs_gn_fsync(vp, flags, vinfo, cred)
!      struct vnode *vp;
! #ifdef AFS_AIX51_ENV
!      int32long64_t flags;	/* Not used by AFS */
!      int32long64_t vinfo;	/* Not used by AFS */
! #else
!      int flags;			/* Not used by AFS */
!      caddr_t vinfo;		/* Not used by AFS */
! #endif
!      struct ucred *cred;
  {
      int error;
  
--- 683,692 ----
  
  
  int
! afs_gn_fsync(struct vnode *vp, 
! 	     int32long64_t flags, 	/* Not used by AFS */
! 	     int32long64_t vinfo, 	/* Not used by AFS */
! 	     struct ucred *cred)
  {
      int error;
  
***************
*** 893,908 ****
  
  
  int
! afs_gn_ftrunc(vp, flags, length, vinfo, cred)
!      struct vnode *vp;
! #ifdef AFS_AIX51_ENV
!      int32long64_t flags;	/* Ignored in AFS */
! #else
!      int flags;			/* Ignored in AFS */
! #endif
!      offset_t length;
!      caddr_t vinfo;		/* Ignored in AFS */
!      struct ucred *cred;
  {
      struct vattr va;
      int error;
--- 699,709 ----
  
  
  int
! afs_gn_ftrunc(struct vnode *vp, 
! 	      int32long64_t flags, 
! 	      offset_t length, 
! 	      caddr_t vinfo, 
! 	      struct ucred *cred)
  {
      struct vattr va;
      int error;
***************
*** 910,916 ****
      AFS_STATCNT(afs_gn_ftrunc);
      VATTR_NULL(&va);
      va.va_size = length;
!     error = afs_setattr(vp, &va, cred);
      afs_Trace4(afs_iclSetp, CM_TRACE_GFTRUNC, ICL_TYPE_POINTER, vp,
  	       ICL_TYPE_LONG, flags, ICL_TYPE_OFFSET,
  	       ICL_HANDLE_OFFSET(length), ICL_TYPE_LONG, error);
--- 711,717 ----
      AFS_STATCNT(afs_gn_ftrunc);
      VATTR_NULL(&va);
      va.va_size = length;
!     error = afs_setattr(VTOAFS(vp), &va, cred);
      afs_Trace4(afs_iclSetp, CM_TRACE_GFTRUNC, ICL_TYPE_POINTER, vp,
  	       ICL_TYPE_LONG, flags, ICL_TYPE_OFFSET,
  	       ICL_HANDLE_OFFSET(length), ICL_TYPE_LONG, error);
***************
*** 921,942 ****
  #define MIN_PAGE_HOG_SIZE 8388608
  
  int
! afs_gn_rdwr(vp, op, Flags, ubuf, ext, vinfo, vattrp, cred)
!      struct vnode *vp;
!      enum uio_rw op;
! #ifdef AFS_AIX51_ENV
!      int32long64_t Flags;
!      ext_t ext;			/* Ignored in AFS */
! #else
!      int Flags;
!      int ext;			/* Ignored in AFS */
! #endif
!      struct uio *ubuf;
!      caddr_t vinfo;		/* Ignored in AFS */
!      struct vattr *vattrp;
!      struct ucred *cred;
  {
!     register struct vcache *vcp = VTOAFS(vp);
      struct vrequest treq;
      int error = 0;
      int free_cred = 0;
--- 722,737 ----
  #define MIN_PAGE_HOG_SIZE 8388608
  
  int
! afs_gn_rdwr(struct vnode *vp, 
! 	    enum uio_rw op, 
! 	    int32long64_t Flags, 
! 	    struct uio *ubuf, 
! 	    ext_t ext, 			/* Ignored in AFS */
! 	    caddr_t vinfo, 		/* Ignored in AFS */
! 	    struct vattr *vattrp, 
! 	    struct ucred *cred)
  {
!     struct vcache *vcp = VTOAFS(vp);
      struct vrequest treq;
      int error = 0;
      int free_cred = 0;
***************
*** 1015,1028 ****
      if (op == UIO_WRITE) {
  #ifdef AFS_64BIT_CLIENT
  	if (ubuf->afsio_offset < afs_vmMappingEnd) {
! #endif /* AFS_64BIT_ENV */
  	    ObtainWriteLock(&vcp->lock, 240);
  	    vcp->states |= CDirty;	/* Set the dirty bit */
  	    afs_FakeOpen(vcp);
  	    ReleaseWriteLock(&vcp->lock);
  #ifdef AFS_64BIT_CLIENT
  	}
! #endif /* AFS_64BIT_ENV */
      }
  
      error = afs_vm_rdwr(vp, ubuf, op, flags, cred);
--- 810,823 ----
      if (op == UIO_WRITE) {
  #ifdef AFS_64BIT_CLIENT
  	if (ubuf->afsio_offset < afs_vmMappingEnd) {
! #endif /* AFS_64BIT_CLIENT */
  	    ObtainWriteLock(&vcp->lock, 240);
  	    vcp->states |= CDirty;	/* Set the dirty bit */
  	    afs_FakeOpen(vcp);
  	    ReleaseWriteLock(&vcp->lock);
  #ifdef AFS_64BIT_CLIENT
  	}
! #endif /* AFS_64BIT_CLIENT */
      }
  
      error = afs_vm_rdwr(vp, ubuf, op, flags, cred);
***************
*** 1030,1042 ****
      if (op == UIO_WRITE) {
  #ifdef AFS_64BIT_CLIENT
  	if (ubuf->afsio_offset < afs_vmMappingEnd) {
! #endif /* AFS_64BIT_ENV */
  	    ObtainWriteLock(&vcp->lock, 241);
  	    afs_FakeClose(vcp, cred);	/* XXXX For nfs trans and cores XXXX */
  	    ReleaseWriteLock(&vcp->lock);
  #ifdef AFS_64BIT_CLIENT
  	}
! #endif /* AFS_64BIT_ENV */
      }
      if (vattrp != NULL && error == 0)
  	afs_gn_getattr(vp, vattrp, cred);
--- 825,837 ----
      if (op == UIO_WRITE) {
  #ifdef AFS_64BIT_CLIENT
  	if (ubuf->afsio_offset < afs_vmMappingEnd) {
! #endif /* AFS_64BIT_CLIENT */
  	    ObtainWriteLock(&vcp->lock, 241);
  	    afs_FakeClose(vcp, cred);	/* XXXX For nfs trans and cores XXXX */
  	    ReleaseWriteLock(&vcp->lock);
  #ifdef AFS_64BIT_CLIENT
  	}
! #endif /* AFS_64BIT_CLIENT */
      }
      if (vattrp != NULL && error == 0)
  	afs_gn_getattr(vp, vattrp, cred);
***************
*** 1050,1064 ****
  }
  
  #define AFS_MAX_VM_CHUNKS 10
! afs_vm_rdwr(vp, uiop, rw, ioflag, credp)
!      register struct vnode *vp;
!      struct uio *uiop;
!      enum uio_rw rw;
!      int ioflag;
!      struct ucred *credp;
  {
!     register afs_int32 code = 0;
!     register int i;
      afs_int32 blockSize;
      afs_size_t fileSize, xfrOffset, offset, old_offset, xfrSize;
      vmsize_t txfrSize;
--- 845,859 ----
  }
  
  #define AFS_MAX_VM_CHUNKS 10
! static int
! afs_vm_rdwr(struct vnode *vp, 
! 	    struct uio *uiop, 
! 	    enum uio_rw rw, 
! 	    int ioflag, 
! 	    struct ucred *credp)
  {
!     afs_int32 code = 0;
!     int i;
      afs_int32 blockSize;
      afs_size_t fileSize, xfrOffset, offset, old_offset, xfrSize;
      vmsize_t txfrSize;
***************
*** 1068,1074 ****
      int mixed = 0;
      afs_size_t add2resid = 0;
  #endif /* AFS_64BIT_CLIENT */
!     register struct vcache *vcp = VTOAFS(vp);
      struct dcache *tdc;
      afs_size_t start_offset;
      afs_int32 save_resid = uiop->afsio_resid;
--- 863,869 ----
      int mixed = 0;
      afs_size_t add2resid = 0;
  #endif /* AFS_64BIT_CLIENT */
!     struct vcache *vcp = VTOAFS(vp);
      struct dcache *tdc;
      afs_size_t start_offset;
      afs_int32 save_resid = uiop->afsio_resid;
***************
*** 1160,1166 ****
  #endif
  	/* Consider  V_INTRSEG too for interrupts */
  	if (code =
! 	    vms_create(&vcp->segid, V_CLIENT, vcp->v.v_gnode, tlen, 0, 0)) {
  	    goto fail;
  	}
  #ifdef AFS_64BIT_KERNEL
--- 955,961 ----
  #endif
  	/* Consider  V_INTRSEG too for interrupts */
  	if (code =
! 	    vms_create(&vcp->segid, V_CLIENT, (dev_t) vcp->v.v_gnode, tlen, 0, 0)) {
  	    goto fail;
  	}
  #ifdef AFS_64BIT_KERNEL
***************
*** 1376,1389 ****
  }
  
  
! afs_direct_rdwr(vp, uiop, rw, ioflag, credp)
!      register struct vnode *vp;
!      struct uio *uiop;
!      enum uio_rw rw;
!      int ioflag;
!      struct ucred *credp;
  {
!     register afs_int32 code = 0;
      afs_size_t fileSize, xfrOffset, offset, old_offset, xfrSize;
      struct vcache *vcp = VTOAFS(vp);
      afs_int32 save_resid = uiop->afsio_resid;
--- 1171,1184 ----
  }
  
  
! static int
! afs_direct_rdwr(struct vnode *vp, 
! 	        struct uio *uiop, 
! 		enum uio_rw rw, 
! 		int ioflag, 
! 		struct ucred *credp)
  {
!     afs_int32 code = 0;
      afs_size_t fileSize, xfrOffset, offset, old_offset, xfrSize;
      struct vcache *vcp = VTOAFS(vp);
      afs_int32 save_resid = uiop->afsio_resid;
***************
*** 1429,1435 ****
      afs_Trace3(afs_iclSetp, CM_TRACE_DIRECTRDWR, ICL_TYPE_POINTER, vp,
  	       ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(uiop->afsio_offset),
  	       ICL_TYPE_LONG, uiop->afsio_resid);
!     code = afs_rdwr(vp, uiop, rw, ioflag, credp);
      if (code != 0) {
  	uiop->afsio_resid = save_resid;
      } else {
--- 1224,1230 ----
      afs_Trace3(afs_iclSetp, CM_TRACE_DIRECTRDWR, ICL_TYPE_POINTER, vp,
  	       ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(uiop->afsio_offset),
  	       ICL_TYPE_LONG, uiop->afsio_resid);
!     code = afs_rdwr(VTOAFS(vp), uiop, rw, ioflag, credp);
      if (code != 0) {
  	uiop->afsio_resid = save_resid;
      } else {
***************
*** 1456,1466 ****
  
  
  static int
! lock_normalize(vp, lckdat, offset, cred)
!      struct vnode *vp;
!      struct eflock *lckdat;
!      offset_t offset;
!      struct ucred *cred;
  {
      struct vattr vattr;
      int code;
--- 1251,1260 ----
  
  
  static int
! lock_normalize(struct vnode *vp, 
! 	       struct flock *lckdat, 
! 	       offset_t offset, 
! 	       struct ucred *cred)
  {
      struct vattr vattr;
      int code;
***************
*** 1472,1478 ****
  	lckdat->l_start += (off_t) offset;
  	break;
      case 2:
! 	code = afs_getattr(vp, &vattr, cred);
  	if (code != 0)
  	    return code;
  	lckdat->l_start += (off_t) vattr.va_size;
--- 1266,1272 ----
  	lckdat->l_start += (off_t) offset;
  	break;
      case 2:
! 	code = afs_getattr(VTOAFS(vp), &vattr, cred);
  	if (code != 0)
  	    return code;
  	lckdat->l_start += (off_t) vattr.va_size;
***************
*** 1486,1503 ****
  
  
  
! afs_gn_lockctl(vp, offset, lckdat, cmd, ignored_fcn, ignored_id, cred)
!      void (*ignored_fcn) ();
!      void *ignored_id;
!      struct vnode *vp;
!      offset_t offset;
!      struct eflock *lckdat;
!      struct ucred *cred;
! #ifdef AFS_AIX51_ENV
!      int32long64_t cmd;
! #else
!      int cmd;
! #endif
  {
      int error, ncmd = 0;
      struct flock flkd;
--- 1280,1293 ----
  
  
  
! int
! afs_gn_lockctl(struct vnode *vp, 
! 	       offset_t offset, 
! 	       struct eflock *lckdat, 
! 	       int32long64_t cmd, 
! 	       int (*ignored_fcn) (),
! 	       ulong * ignored_id, 
! 	       struct ucred *cred)
  {
      int error, ncmd = 0;
      struct flock flkd;
***************
*** 1538,1554 ****
  
  /* NOTE: In the nfs glue routine (nfs_gn2sun.c) the order was wrong (vp, flags, cmd, arg, ext); was that another typo? */
  int
! afs_gn_ioctl(vp, Cmd, arg, flags, channel, ext)
!      struct vnode *vp;
! #ifdef AFS_AIX51_ENV
!      int32long64_t Cmd;
! #else
!      int Cmd;
! #endif
!      int arg;
!      int flags;			/* Ignored in AFS */
!      int channel;		/* Ignored in AFS */
!      int ext;			/* Ignored in AFS */
  {
      int error;
      int cmd = Cmd;
--- 1328,1339 ----
  
  /* NOTE: In the nfs glue routine (nfs_gn2sun.c) the order was wrong (vp, flags, cmd, arg, ext); was that another typo? */
  int
! afs_gn_ioctl(struct vnode *vp, 
! 	     int32long64_t Cmd, 
! 	     caddr_t arg, 
! 	     size_t flags, 		/* Ignored in AFS */
! 	     ext_t ext, 		/* Ignored in AFS */
! 	     struct ucred *crp)		/* Ignored in AFS */
  {
      int error;
      int cmd = Cmd;
***************
*** 1563,1572 ****
  
  
  int
! afs_gn_readlink(vp, uiop, cred)
!      struct vnode *vp;
!      struct uio *uiop;
!      struct ucred *cred;
  {
      int error;
  
--- 1348,1356 ----
  
  
  int
! afs_gn_readlink(struct vnode *vp, 
! 	        struct uio *uiop, 
! 		struct ucred *cred)
  {
      int error;
  
***************
*** 1579,1589 ****
  
  
  int
! afs_gn_select(vp, which, vinfo, mpx)
!      struct vnode *vp;
!      int which;
!      caddr_t *vinfo;
!      caddr_t *mpx;
  {
      AFS_STATCNT(afs_gn_select);
      /* NO SUPPORT for this in afs YET! */
--- 1363,1375 ----
  
  
  int
! afs_gn_select(struct vnode *vp, 
! 	      int32long64_t correl,
! 	      ushort e,
! 	      ushort *re,
! 	      void (* notify)(),
! 	      caddr_t vinfo,
! 	      struct ucred *crp)
  {
      AFS_STATCNT(afs_gn_select);
      /* NO SUPPORT for this in afs YET! */
***************
*** 1592,1602 ****
  
  
  int
! afs_gn_symlink(vp, link, target, cred)
!      struct vnode *vp;
!      char *target;
!      char *link;
!      struct ucred *cred;
  {
      struct vattr va;
      int error;
--- 1378,1387 ----
  
  
  int
! afs_gn_symlink(struct vnode *vp, 
! 	       char *link, 
! 	       char *target, 
! 	       struct ucred *cred)
  {
      struct vattr va;
      int error;
***************
*** 1613,1622 ****
  
  
  int
! afs_gn_readdir(vp, uiop, cred)
!      struct vnode *vp;
!      struct uio *uiop;
!      struct ucred *cred;
  {
      int error;
  
--- 1398,1406 ----
  
  
  int
! afs_gn_readdir(struct vnode *vp, 
! 	       struct uio *uiop, 
! 	       struct ucred *cred)
  {
      int error;
  
***************
*** 1629,1644 ****
  
  
  extern Simple_lock afs_asyncbuf_lock;
  /*
   * Buffers are ranked by age.  A buffer's age is the value of afs_biotime
!  * when the buffer is processed by naix_vmstrategy.  afs_biotime is
   * incremented for each buffer.  A buffer's age is kept in its av_back field.
   * The age ranking is used by the daemons, which favor older buffers.
   */
  afs_int32 afs_biotime = 0;
  
- extern struct buf *afs_asyncbuf;
- extern int afs_asyncbuf_cv;
  /* This function is called with a list of buffers, threaded through
   * the av_forw field.  Our goal is to copy the list of buffers into the
   * afs_asyncbuf list, sorting buffers into sublists linked by the b_work field.
--- 1413,1429 ----
  
  
  extern Simple_lock afs_asyncbuf_lock;
+ extern struct buf *afs_asyncbuf;
+ extern int afs_asyncbuf_cv;
+ 
  /*
   * Buffers are ranked by age.  A buffer's age is the value of afs_biotime
!  * when the buffer is processed by afs_gn_strategy.  afs_biotime is
   * incremented for each buffer.  A buffer's age is kept in its av_back field.
   * The age ranking is used by the daemons, which favor older buffers.
   */
  afs_int32 afs_biotime = 0;
  
  /* This function is called with a list of buffers, threaded through
   * the av_forw field.  Our goal is to copy the list of buffers into the
   * afs_asyncbuf list, sorting buffers into sublists linked by the b_work field.
***************
*** 1647,1662 ****
   * be increased to cover all of the buffers in the b_work queue.
   */
  #define	AIX_VM_BLKSIZE	8192
! afs_gn_strategy(abp, cred)
!      struct ucred *cred;
!      register struct buf *abp;
  {
!     register struct buf **lbp, *tbp;
! #ifdef AFS_64BIT_KERNEL
!     afs_int64 *lwbp;		/* last quy in work chain */
! #else
!     int *lwbp;			/* last guy in work chain */
! #endif
      struct buf *nbp, *qbp, *qnbp, *firstComparable;
      int doMerge;
      int oldPriority;
--- 1432,1449 ----
   * be increased to cover all of the buffers in the b_work queue.
   */
  #define	AIX_VM_BLKSIZE	8192
! /* Note: This function seems to be called as ddstrategy entry point, ie
!  * has one argument. However, it also needs to be present as
!  * vn_strategy entry point which has three arguments, but it seems to never
!  * be called in that capacity (it would fail horribly due to the argument
!  * mismatch). I'm confused, but it obviously has to be this way, maybe
!  * some IBM people can shed som light on this 
!  */
! int
! afs_gn_strategy(struct buf *abp)
  {
!     struct buf **lbp, *tbp;
!     struct buf **lwbp;
      struct buf *nbp, *qbp, *qnbp, *firstComparable;
      int doMerge;
      int oldPriority;
***************
*** 1710,1715 ****
--- 1497,1503 ----
  	     */
  	    continue;
  	}
+ 
  	/* we may have actually added the "new" firstComparable */
  	if (tbp->av_forw == firstComparable)
  	    firstComparable = tbp;
***************
*** 1766,1797 ****
  		    doMerge = 1;	/* both integral #s of blocks */
  		}
  		if (doMerge) {
! 		    register struct buf *xbp;
  
  		    /* merge both of these blocks together */
  		    /* first set age to the older of the two */
! #ifdef AFS_64BIT_KERNEL
! 		    if ((afs_int64) qnbp->av_back - (afs_int64) qbp->av_back <
! 			0)
! #else
! 		    if ((int)qnbp->av_back - (int)qbp->av_back < 0)
! #endif
  			qbp->av_back = qnbp->av_back;
! 		    lwbp = &qbp->b_work;
  		    /* find end of qbp's work queue */
! 		    for (xbp = (struct buf *)(*lwbp); xbp;
! 			 lwbp = &xbp->b_work, xbp = (struct buf *)(*lwbp));
  		    /*
  		     * now setting *lwbp will change the last ptr in the qbp's
  		     * work chain
  		     */
  		    qbp->av_forw = qnbp->av_forw;	/* splice out qnbp */
  		    qbp->b_bcount += qnbp->b_bcount;	/* fix count */
! #ifdef AFS_64BIT_KERNEL
! 		    *lwbp = (afs_int64) qnbp;	/* append qnbp to end */
! #else
! 		    *lwbp = (int)qnbp;	/* append qnbp to end */
! #endif
  		    /*
  		     * note that qnbp is bogus, but it doesn't matter because
  		     * we're going to restart the for loop now.
--- 1554,1578 ----
  		    doMerge = 1;	/* both integral #s of blocks */
  		}
  		if (doMerge) {
! 		    struct buf *xbp;
  
  		    /* merge both of these blocks together */
  		    /* first set age to the older of the two */
! 		    if ((int32long64_t) qnbp->av_back - 
! 			    (int32long64_t) qbp->av_back < 0) {
  			qbp->av_back = qnbp->av_back;
! 		    }
! 		    lwbp = (struct buf **) &qbp->b_work;
  		    /* find end of qbp's work queue */
! 		    for (xbp = *lwbp; xbp;
! 			 lwbp = (struct buf **) &xbp->b_work, xbp = *lwbp);
  		    /*
  		     * now setting *lwbp will change the last ptr in the qbp's
  		     * work chain
  		     */
  		    qbp->av_forw = qnbp->av_forw;	/* splice out qnbp */
  		    qbp->b_bcount += qnbp->b_bcount;	/* fix count */
! 		    *lwbp = qnbp;	/* append qnbp to end */
  		    /*
  		     * note that qnbp is bogus, but it doesn't matter because
  		     * we're going to restart the for loop now.
***************
*** 1808,1823 ****
  }
  
  
! afs_inactive(avc, acred)
!      register struct vcache *avc;
!      struct AFS_UCRED *acred;
  {
      afs_InactiveVCache(avc, acred);
  }
  
  int
! afs_gn_revoke(vp)
!      struct vnode *vp;
  {
      AFS_STATCNT(afs_gn_revoke);
      /* NO SUPPORT for this in afs YET! */
--- 1589,1607 ----
  }
  
  
! int
! afs_inactive(struct vcache *avc, 
! 	     struct AFS_UCRED *acred)
  {
      afs_InactiveVCache(avc, acred);
  }
  
  int
! afs_gn_revoke(struct vnode *vp,
!               int32long64_t cmd,
! 	      int32long64_t flag,
! 	      struct vattr *vinfop,
! 	      struct ucred *crp)
  {
      AFS_STATCNT(afs_gn_revoke);
      /* NO SUPPORT for this in afs YET! */
***************
*** 1825,1875 ****
  }
  
  int
! afs_gn_getacl(vp, uiop, cred)
!      struct vnode *vp;
!      struct uio *uiop;
!      struct ucred *cred;
  {
      return ENOSYS;
  };
  
  
  int
! afs_gn_setacl(vp, uiop, cred)
!      struct vnode *vp;
!      struct uio *uiop;
!      struct ucred *cred;
  {
      return ENOSYS;
  };
  
  
  int
! afs_gn_getpcl(vp, uiop, cred)
!      struct vnode *vp;
!      struct uio *uiop;
!      struct ucred *cred;
  {
      return ENOSYS;
  };
  
  
  int
! afs_gn_setpcl(vp, uiop, cred)
!      struct vnode *vp;
!      struct uio *uiop;
!      struct ucred *cred;
  {
      return ENOSYS;
  };
  int
  afs_gn_enosys()
  {
      return ENOSYS;
  }
  
  extern struct vfsops Afs_vfsops;
- extern struct vnodeops afs_gn_vnodeops;
  extern int Afs_init();
  
  #define	AFS_CALLOUT_TBL_SIZE	256
--- 1609,1767 ----
  }
  
  int
! afs_gn_getacl(struct vnode *vp, 
! 	      struct uio *uiop, 
! 	      struct ucred *cred)
  {
      return ENOSYS;
  };
  
  
  int
! afs_gn_setacl(struct vnode *vp, 
! 	      struct uio *uiop, 
! 	      struct ucred *cred)
  {
      return ENOSYS;
  };
  
  
  int
! afs_gn_getpcl(struct vnode *vp, 
! 	      struct uio *uiop, 
! 	      struct ucred *cred)
  {
      return ENOSYS;
  };
  
  
  int
! afs_gn_setpcl(struct vnode *vp, 
! 	      struct uio *uiop, 
! 	      struct ucred *cred)
  {
      return ENOSYS;
  };
+ 
+ 
+ int
+ afs_gn_seek(struct vnode* vp, offset_t * offp, struct ucred * crp)
+ {
+ /*
+  * File systems which do not wish to do offset validation can simply
+  * return 0.  File systems which do not provide the vn_seek entry point
+  * will have a maximum offset of OFF_MAX (2 gigabytes minus 1) enforced
+  * by the logical file system.
+  */
+     return 0;
+ }
+ 
+ 
  int
  afs_gn_enosys()
  {
      return ENOSYS;
  }
  
+ /*
+  * declare a struct vnodeops and initialize it with ptrs to all functions
+  */
+ struct vnodeops afs_gn_vnodeops = {
+     /* creation/naming/deletion */
+     afs_gn_link,
+     afs_gn_mkdir,
+     afs_gn_mknod,
+     afs_gn_remove,
+     afs_gn_rename,
+     afs_gn_rmdir,
+     /* lookup, file handle stuff */
+     afs_gn_lookup,
+     (int(*)(struct vnode*,struct fileid*,struct ucred*))
+ 	afs_gn_fid,
+     /* access to files */
+     (int(*)(struct vnode *, int32long64_t, ext_t, caddr_t *,struct ucred *))
+ 	afs_gn_open,
+     (int(*)(struct vnode *, struct vnode **, int32long64_t,caddr_t, int32long64_t, caddr_t *, struct ucred *))
+ 	afs_gn_create,
+     afs_gn_hold,
+     afs_gn_rele,
+     afs_gn_close,
+     afs_gn_map,
+     afs_gn_unmap,
+     /* manipulate attributes of files */
+     afs_gn_access,
+     afs_gn_getattr,
+     afs_gn_setattr,
+     /* data update operations */
+     afs_gn_fclear,
+     afs_gn_fsync,
+     afs_gn_ftrunc,
+     afs_gn_rdwr,
+     afs_gn_lockctl,
+     /* extensions */
+     afs_gn_ioctl,
+     afs_gn_readlink,
+     afs_gn_select,
+     afs_gn_symlink,
+     afs_gn_readdir,
+     /* buffer ops */
+     (int(*)(struct vnode*,struct buf*,struct ucred*))
+ 	afs_gn_strategy,
+     /* security things */
+     afs_gn_revoke,
+     afs_gn_getacl,
+     afs_gn_setacl,
+     afs_gn_getpcl,
+     afs_gn_setpcl,
+     afs_gn_seek,
+     (int(*)(struct vnode *, int32long64_t, int32long64_t, offset_t, offset_t, struct ucred *))
+ 	afs_gn_enosys,		/* vn_fsync_range */
+     (int(*)(struct vnode *, struct vnode **, int32long64_t, char *, struct vattr *, int32long64_t, caddr_t *, struct ucred *))
+ 	afs_gn_enosys,		/* vn_create_attr */
+     (int(*)(struct vnode *, int32long64_t, void *, size_t, struct ucred *))
+ 	afs_gn_enosys,		/* vn_finfo */
+     (int(*)(struct vnode *, caddr_t, offset_t, offset_t, uint32long64_t, uint32long64_t, struct ucred *))
+ 	afs_gn_enosys,		/* vn_map_lloff */
+     (int(*)(struct vnode*,struct uio*,int*,struct ucred*))
+ 	afs_gn_enosys,		/* vn_readdir_eofp */
+     (int(*)(struct vnode *, enum uio_rw, int32long64_t, struct uio *, ext_t , caddr_t, struct vattr *, struct vattr *, struct ucred *))
+ 	afs_gn_enosys,		/* vn_rdwr_attr */
+     (int(*)(struct vnode*,int,void*,struct ucred*))
+ 	afs_gn_enosys,		/* vn_memcntl */
+     (int(*)(struct vnode*,const char*,struct uio*,struct ucred*))
+ 	afs_gn_enosys,		/* vn_getea */
+     (int(*)(struct vnode*,const char*,struct uio*,int,struct ucred*))
+ 	afs_gn_enosys,		/* vn_setea */
+     (int(*)(struct vnode *, struct uio *, struct ucred *))
+ 	afs_gn_enosys,		/* vn_listea */
+     (int(*)(struct vnode *, const char *, struct ucred *))
+ 	afs_gn_enosys,		/* vn_removeea */
+     (int(*)(struct vnode *, const char *, struct vattr *, struct ucred *))
+ 	afs_gn_enosys,		/* vn_statea */
+     (int(*)(struct vnode *, uint64_t, acl_type_t *, struct uio *, size_t *, mode_t *, struct ucred *))
+ 	afs_gn_enosys,		/* vn_getxacl */
+     (int(*)(struct vnode *, uint64_t, acl_type_t, struct uio *, mode_t,  struct ucred *))
+ 	afs_gn_enosys,		/* vn_setxacl */
+     afs_gn_enosys,		/* vn_spareE */
+     afs_gn_enosys		/* vn_spareF */
+ #ifdef AFS_AIX51_ENV
+     ,(int(*)(struct gnode*,long long,char*,unsigned long*, unsigned long*,unsigned int*))
+ 	afs_gn_enosys,		/* pagerBackRange */
+     (int64_t(*)(struct gnode*))
+ 	afs_gn_enosys,		/* pagerGetFileSize */
+     (void(*)(struct gnode *, vpn_t, vpn_t *, vpn_t *, vpn_t *, boolean_t))
+ 	afs_gn_enosys,		/* pagerReadAhead */
+     (void(*)(struct gnode *, int64_t, int64_t, uint))
+ 	afs_gn_enosys,		/* pagerReadWriteBehind */
+     (void(*)(struct gnode*,long long,unsigned long,unsigned long,unsigned int))
+ 	afs_gn_enosys		/* pagerEndCopy */
+ #endif
+ };
+ struct vnodeops *afs_ops = &afs_gn_vnodeops;
+ 
+ 
+ 
  extern struct vfsops Afs_vfsops;
  extern int Afs_init();
  
  #define	AFS_CALLOUT_TBL_SIZE	256
***************
*** 1883,1889 ****
  static
  vfs_mount(struct vfs *a, struct ucred *b)
  {
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 1775,1781 ----
  static
  vfs_mount(struct vfs *a, struct ucred *b)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 1898,1904 ****
  static
  vfs_unmount(struct vfs *a, int b, struct ucred *c)
  {
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 1790,1796 ----
  static
  vfs_unmount(struct vfs *a, int b, struct ucred *c)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 1913,1919 ****
  static
  vfs_root(struct vfs *a, struct vnode **b, struct ucred *c)
  {
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 1805,1811 ----
  static
  vfs_root(struct vfs *a, struct vnode **b, struct ucred *c)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 1928,1934 ****
  static
  vfs_statfs(struct vfs *a, struct statfs *b, struct ucred *c)
  {
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 1820,1826 ----
  static
  vfs_statfs(struct vfs *a, struct statfs *b, struct ucred *c)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 1943,1949 ****
  static
  vfs_sync(struct gfs *a)
  {
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 1835,1841 ----
  static
  vfs_sync(struct gfs *a)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 1957,1963 ****
  static
  vfs_vget(struct vfs *a, struct vnode **b, struct fileid *c, struct ucred *d)
  {
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 1849,1855 ----
  static
  vfs_vget(struct vfs *a, struct vnode **b, struct fileid *c, struct ucred *d)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 1972,1978 ****
  static
  vfs_cntl(struct vfs *a, int b, caddr_t c, size_t d, struct ucred *e)
  {
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 1864,1870 ----
  static
  vfs_cntl(struct vfs *a, int b, caddr_t c, size_t d, struct ucred *e)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 1987,1993 ****
  static
  vfs_quotactl(struct vfs *a, int b, uid_t c, caddr_t d, struct ucred *e)
  {
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 1879,1885 ----
  static
  vfs_quotactl(struct vfs *a, int b, uid_t c, caddr_t d, struct ucred *e)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2003,2009 ****
  static
  vfs_syncvfs(struct gfs *a, struct vfs *b, int c, struct ucred *d)
  {
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 1895,1901 ----
  static
  vfs_syncvfs(struct gfs *a, struct vfs *b, int c, struct ucred *d)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2034,2040 ****
  static
  vn_link(struct vnode *a, struct vnode *b, char *c, struct ucred *d)
  {
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 1926,1932 ----
  static
  vn_link(struct vnode *a, struct vnode *b, char *c, struct ucred *d)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2047,2060 ****
  }
  
  static
- #ifdef AFS_AIX51_ENV
  vn_mkdir(struct vnode *a, char *b, int32long64_t c, struct ucred *d)
  {
! #else
! vn_mkdir(struct vnode *a, char *b, int c, struct ucred *d)
! {
! #endif
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 1939,1947 ----
  }
  
  static
  vn_mkdir(struct vnode *a, char *b, int32long64_t c, struct ucred *d)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2067,2081 ****
  }
  
  static
- #ifdef AFS_AIX51_ENV
  vn_mknod(struct vnode *a, caddr_t b, int32long64_t c, dev_t d,
  	 struct ucred *e)
  {
! #else
! vn_mknod(struct vnode *a, caddr_t b, int c, dev_t d, struct ucred *e)
! {
! #endif
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 1954,1963 ----
  }
  
  static
  vn_mknod(struct vnode *a, caddr_t b, int32long64_t c, dev_t d,
  	 struct ucred *e)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2090,2096 ****
  static
  vn_remove(struct vnode *a, struct vnode *b, char *c, struct ucred *d)
  {
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 1972,1978 ----
  static
  vn_remove(struct vnode *a, struct vnode *b, char *c, struct ucred *d)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2106,2112 ****
  vn_rename(struct vnode *a, struct vnode *b, caddr_t c, struct vnode *d,
  	  struct vnode *e, caddr_t f, struct ucred *g)
  {
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 1988,1994 ----
  vn_rename(struct vnode *a, struct vnode *b, caddr_t c, struct vnode *d,
  	  struct vnode *e, caddr_t f, struct ucred *g)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2121,2127 ****
  static
  vn_rmdir(struct vnode *a, struct vnode *b, char *c, struct ucred *d)
  {
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 2003,2009 ----
  static
  vn_rmdir(struct vnode *a, struct vnode *b, char *c, struct ucred *d)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2134,2147 ****
  }
  
  static
! #ifdef AFS_AIX51_ENV
!   vn_lookup(struct vnode *a, struct vnode **b, char *c, int32long64_t d,
! #else
! vn_lookup(struct vnode *a, struct vnode **b, char *c, int d,
! #endif
  	  struct vattr *v, struct ucred *e)
  {
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 2016,2025 ----
  }
  
  static
! vn_lookup(struct vnode *a, struct vnode **b, char *c, int32long64_t d,
  	  struct vattr *v, struct ucred *e)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2156,2162 ****
  static
  vn_fid(struct vnode *a, struct fileid *b, struct ucred *c)
  {
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 2034,2040 ----
  static
  vn_fid(struct vnode *a, struct fileid *b, struct ucred *c)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2169,2183 ****
  }
  
  static
! #ifdef AFS_AIX51_ENV
! vn_open(struct vnode *a, int b, int c, caddr_t * d, struct ucred *e)
! {
! #else
! vn_open(struct vnode *a, int32long64_t b, ext_t c, caddr_t * d,
  	struct ucred *e)
  {
! #endif
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 2047,2059 ----
  }
  
  static
! vn_open(struct vnode *a, 
! 	int32long64_t b, 
! 	ext_t c, 
! 	caddr_t * d, 
  	struct ucred *e)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2190,2205 ****
  }
  
  static
- #ifdef AFS_AIX51_ENV
  vn_create(struct vnode *a, struct vnode **b, int32long64_t c, caddr_t d,
  	  int32long64_t e, caddr_t * f, struct ucred *g)
  {
! #else
! vn_create(struct vnode *a, struct vnode **b, int c, caddr_t d, int e,
! 	  caddr_t * f, struct ucred *g)
! {
! #endif
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 2066,2075 ----
  }
  
  static
  vn_create(struct vnode *a, struct vnode **b, int32long64_t c, caddr_t d,
  	  int32long64_t e, caddr_t * f, struct ucred *g)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2214,2220 ****
  static
  vn_hold(struct vnode *a)
  {
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 2084,2090 ----
  static
  vn_hold(struct vnode *a)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2229,2235 ****
  static
  vn_rele(struct vnode *a)
  {
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 2099,2105 ----
  static
  vn_rele(struct vnode *a)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2242,2255 ****
  }
  
  static
- #ifdef AFS_AIX51_ENV
  vn_close(struct vnode *a, int32long64_t b, caddr_t c, struct ucred *d)
  {
! #else
! vn_close(struct vnode *a, int b, caddr_t c, struct ucred *d)
! {
! #endif
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 2112,2120 ----
  }
  
  static
  vn_close(struct vnode *a, int32long64_t b, caddr_t c, struct ucred *d)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2262,2276 ****
  }
  
  static
- #ifdef AFS_AIX51_ENV
  vn_map(struct vnode *a, caddr_t b, uint32long64_t c, uint32long64_t d,
         uint32long64_t e, struct ucred *f)
  {
! #else
! vn_map(struct vnode *a, caddr_t b, uint c, uint d, uint e, struct ucred *f)
! {
! #endif
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 2127,2136 ----
  }
  
  static
  vn_map(struct vnode *a, caddr_t b, uint32long64_t c, uint32long64_t d,
         uint32long64_t e, struct ucred *f)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2283,2296 ****
  }
  
  static
- #ifdef AFS_AIX51_ENV
  vn_unmap(struct vnode *a, int32long64_t b, struct ucred *c)
  {
! #else
! vn_unmap(struct vnode *a, int b, struct ucred *c)
! {
! #endif
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 2143,2151 ----
  }
  
  static
  vn_unmap(struct vnode *a, int32long64_t b, struct ucred *c)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2303,2316 ****
  }
  
  static
- #ifdef AFS_AIX51_ENV
  vn_access(struct vnode *a, int32long64_t b, int32long64_t c, struct ucred *d)
  {
! #else
! vn_access(struct vnode *a, int b, int c, struct ucred *d)
! {
! #endif
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 2158,2166 ----
  }
  
  static
  vn_access(struct vnode *a, int32long64_t b, int32long64_t c, struct ucred *d)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2325,2331 ****
  static
  vn_getattr(struct vnode *a, struct vattr *b, struct ucred *c)
  {
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 2175,2181 ----
  static
  vn_getattr(struct vnode *a, struct vattr *b, struct ucred *c)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2338,2352 ****
  }
  
  static
- #ifdef AFS_AIX51_ENV
  vn_setattr(struct vnode *a, int32long64_t b, int32long64_t c, int32long64_t d,
  	   int32long64_t e, struct ucred *f)
  {
! #else
! vn_setattr(struct vnode *a, int b, int c, int d, int e, struct ucred *f)
! {
! #endif
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 2188,2197 ----
  }
  
  static
  vn_setattr(struct vnode *a, int32long64_t b, int32long64_t c, int32long64_t d,
  	   int32long64_t e, struct ucred *f)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2359,2372 ****
  }
  
  static
! #ifdef AFS_AIX51_ENV
!   vn_fclear(struct vnode *a, int32long64_t b, offset_t c, offset_t d
! #else
! vn_fclear(struct vnode *a, int b, offset_t c, offset_t d
! #endif
  	  , caddr_t e, struct ucred *f)
  {
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 2204,2213 ----
  }
  
  static
! vn_fclear(struct vnode *a, int32long64_t b, offset_t c, offset_t d
  	  , caddr_t e, struct ucred *f)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2379,2392 ****
  }
  
  static
- #ifdef AFS_AIX51_ENV
  vn_fsync(struct vnode *a, int32long64_t b, int32long64_t c, struct ucred *d)
  {
! #else
! vn_fsync(struct vnode *a, int b, int c, struct ucred *d)
! {
! #endif
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 2220,2228 ----
  }
  
  static
  vn_fsync(struct vnode *a, int32long64_t b, int32long64_t c, struct ucred *d)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2399,2413 ****
  }
  
  static
- #ifdef AFS_AIX51_ENV
  vn_ftrunc(struct vnode *a, int32long64_t b, offset_t c, caddr_t d,
  	  struct ucred *e)
  {
! #else
! vn_ftrunc(struct vnode *a, int b, offset_t c, caddr_t d, struct ucred *e)
! {
! #endif
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 2235,2244 ----
  }
  
  static
  vn_ftrunc(struct vnode *a, int32long64_t b, offset_t c, caddr_t d,
  	  struct ucred *e)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2420,2435 ****
  }
  
  static
- #ifdef AFS_AIX51_ENV
  vn_rdwr(struct vnode *a, enum uio_rw b, int32long64_t c, struct uio *d,
  	ext_t e, caddr_t f, struct vattr *v, struct ucred *g)
  {
! #else
! vn_rdwr(struct vnode *a, enum uio_rw b, int c, struct uio *d, int e,
! 	caddr_t f, struct vattr *v, struct ucred *g)
! {
! #endif
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 2251,2260 ----
  }
  
  static
  vn_rdwr(struct vnode *a, enum uio_rw b, int32long64_t c, struct uio *d,
  	ext_t e, caddr_t f, struct vattr *v, struct ucred *g)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2442,2457 ****
  }
  
  static
- #ifdef AFS_AIX51_ENV
  vn_lockctl(struct vnode *a, offset_t b, struct eflock *c, int32long64_t d,
! 	   int (*e) (), ulong32int64_t * f, struct ucred *g)
! {
! #else
! vn_lockctl(struct vnode *a, offset_t b, struct eflock *c, int d, int (*e) (),
! 	   ulong * f, struct ucred *g)
  {
! #endif
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 2267,2276 ----
  }
  
  static
  vn_lockctl(struct vnode *a, offset_t b, struct eflock *c, int32long64_t d,
! 	   int (*e) (), ulong * f, struct ucred *g)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2464,2478 ****
  }
  
  static
- #ifdef AFS_AIX51_ENV
  vn_ioctl(struct vnode *a, int32long64_t b, caddr_t c, size_t d, ext_t e,
  	 struct ucred *f)
  {
! #else
! vn_ioctl(struct vnode *a, int b, caddr_t c, size_t d, int e, struct ucred *f)
! {
! #endif
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 2283,2292 ----
  }
  
  static
  vn_ioctl(struct vnode *a, int32long64_t b, caddr_t c, size_t d, ext_t e,
  	 struct ucred *f)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2487,2493 ****
  static
  vn_readlink(struct vnode *a, struct uio *b, struct ucred *c)
  {
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 2301,2307 ----
  static
  vn_readlink(struct vnode *a, struct uio *b, struct ucred *c)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2500,2514 ****
  }
  
  static
! #ifdef AFS_AIX51_ENV
!   vn_select(struct vnode *a, int32long64_t b, ushort c, ushort * d,
! 	    void (*e) ()
! #else
! vn_select(struct vnode *a, int b, ushort c, ushort * d, void (*e) ()
! #endif
! 	  , caddr_t f, struct ucred *g)
  {
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 2314,2323 ----
  }
  
  static
! vn_select(struct vnode *a, int32long64_t b, ushort c, ushort * d,
! 	  void (*e) (), caddr_t f, struct ucred *g)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2523,2529 ****
  static
  vn_symlink(struct vnode *a, char *b, char *c, struct ucred *d)
  {
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 2332,2338 ----
  static
  vn_symlink(struct vnode *a, char *b, char *c, struct ucred *d)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2538,2544 ****
  static
  vn_readdir(struct vnode *a, struct uio *b, struct ucred *c)
  {
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 2347,2353 ----
  static
  vn_readdir(struct vnode *a, struct uio *b, struct ucred *c)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2551,2565 ****
  }
  
  static
- #ifdef AFS_AIX51_ENV
  vn_revoke(struct vnode *a, int32long64_t b, int32long64_t c, struct vattr *d,
  	  struct ucred *e)
  {
! #else
! vn_revoke(struct vnode *a, int b, int c, struct vattr *d, struct ucred *e)
! {
! #endif
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 2360,2369 ----
  }
  
  static
  vn_revoke(struct vnode *a, int32long64_t b, int32long64_t c, struct vattr *d,
  	  struct ucred *e)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2574,2580 ****
  static
  vn_getacl(struct vnode *a, struct uio *b, struct ucred *c)
  {
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 2378,2384 ----
  static
  vn_getacl(struct vnode *a, struct uio *b, struct ucred *c)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2589,2595 ****
  static
  vn_setacl(struct vnode *a, struct uio *b, struct ucred *c)
  {
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 2393,2399 ----
  static
  vn_setacl(struct vnode *a, struct uio *b, struct ucred *c)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2604,2610 ****
  static
  vn_getpcl(struct vnode *a, struct uio *b, struct ucred *c)
  {
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 2408,2414 ----
  static
  vn_getpcl(struct vnode *a, struct uio *b, struct ucred *c)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2619,2625 ****
  static
  vn_setpcl(struct vnode *a, struct uio *b, struct ucred *c)
  {
!     register glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
--- 2423,2429 ----
  static
  vn_setpcl(struct vnode *a, struct uio *b, struct ucred *c)
  {
!     int glockOwner, ret;
  
      glockOwner = ISAFS_GLOCK();
      if (!glockOwner)
***************
*** 2631,2637 ****
      return ret;
  }
  
- extern int afs_gn_strategy();
  
  struct vnodeops locked_afs_gn_vnodeops = {
      vn_link,
--- 2435,2440 ----
***************
*** 2662,2696 ****
      vn_select,
      vn_symlink,
      vn_readdir,
!     afs_gn_strategy,		/* no locking!!! (discovered the hard way) */
      vn_revoke,
      vn_getacl,
      vn_setacl,
      vn_getpcl,
      vn_setpcl,
!     afs_gn_enosys,		/* vn_seek */
!     afs_gn_enosys,		/* vn_fsync_range */
!     afs_gn_enosys,		/* vn_create_attr */
!     afs_gn_enosys,		/* vn_finfo */
!     afs_gn_enosys,		/* vn_map_lloff */
!     afs_gn_enosys,		/* vn_readdir_eofp */
!     afs_gn_enosys,		/* vn_rdwr_attr */
!     afs_gn_enosys,		/* vn_memcntl */
!     afs_gn_enosys,		/* vn_spare7 */
!     afs_gn_enosys,		/* vn_spare8 */
!     afs_gn_enosys,		/* vn_spare9 */
!     afs_gn_enosys,		/* vn_spareA */
!     afs_gn_enosys,		/* vn_spareB */
!     afs_gn_enosys,		/* vn_spareC */
!     afs_gn_enosys,		/* vn_spareD */
      afs_gn_enosys,		/* vn_spareE */
      afs_gn_enosys		/* vn_spareF */
  #ifdef AFS_AIX51_ENV
! 	, afs_gn_enosys,	/* pagerBackRange */
!     afs_gn_enosys,		/* pagerGetFileSize */
!     afs_gn_enosys,		/* pagerReadAhead */
!     afs_gn_enosys,		/* pagerWriteBehind */
!     afs_gn_enosys		/* pagerEndCopy */
  #endif
  };
  
--- 2465,2519 ----
      vn_select,
      vn_symlink,
      vn_readdir,
!     (int(*)(struct vnode*,struct buf*,struct ucred*))
! 	afs_gn_strategy,	/* no locking!!! (discovered the hard way) */
      vn_revoke,
      vn_getacl,
      vn_setacl,
      vn_getpcl,
      vn_setpcl,
!     afs_gn_seek,
!     (int(*)(struct vnode *, int32long64_t, int32long64_t, offset_t, offset_t, struct ucred *))
! 	afs_gn_enosys,		/* vn_fsync_range */
!     (int(*)(struct vnode *, struct vnode **, int32long64_t, char *, struct vattr *, int32long64_t, caddr_t *, struct ucred *))
! 	afs_gn_enosys,		/* vn_create_attr */
!     (int(*)(struct vnode *, int32long64_t, void *, size_t, struct ucred *))
! 	afs_gn_enosys,		/* vn_finfo */
!     (int(*)(struct vnode *, caddr_t, offset_t, offset_t, uint32long64_t, uint32long64_t, struct ucred *))
! 	afs_gn_enosys,		/* vn_map_lloff */
!     (int(*)(struct vnode*,struct uio*,int*,struct ucred*))
! 	afs_gn_enosys,		/* vn_readdir_eofp */
!     (int(*)(struct vnode *, enum uio_rw, int32long64_t, struct uio *, ext_t , caddr_t, struct vattr *, struct vattr *, struct ucred *))
! 	afs_gn_enosys,		/* vn_rdwr_attr */
!     (int(*)(struct vnode*,int,void*,struct ucred*))
! 	afs_gn_enosys,		/* vn_memcntl */
!     (int(*)(struct vnode*,const char*,struct uio*,struct ucred*))
! 	afs_gn_enosys,		/* vn_getea */
!     (int(*)(struct vnode*,const char*,struct uio*,int,struct ucred*))
! 	afs_gn_enosys,		/* vn_setea */
!     (int(*)(struct vnode *, struct uio *, struct ucred *))
! 	afs_gn_enosys,		/* vn_listea */
!     (int(*)(struct vnode *, const char *, struct ucred *))
! 	afs_gn_enosys,		/* vn_removeea */
!     (int(*)(struct vnode *, const char *, struct vattr *, struct ucred *))
! 	afs_gn_enosys,		/* vn_statea */
!     (int(*)(struct vnode *, uint64_t, acl_type_t *, struct uio *, size_t *, mode_t *, struct ucred *))
! 	afs_gn_enosys,		/* vn_getxacl */
!     (int(*)(struct vnode *, uint64_t, acl_type_t, struct uio *, mode_t,  struct ucred *))
! 	afs_gn_enosys,		/* vn_setxacl */
      afs_gn_enosys,		/* vn_spareE */
      afs_gn_enosys		/* vn_spareF */
  #ifdef AFS_AIX51_ENV
!     ,(int(*)(struct gnode*,long long,char*,unsigned long*, unsigned long*,unsigned int*))
! 	afs_gn_enosys,		/* pagerBackRange */
!     (int64_t(*)(struct gnode*))
! 	afs_gn_enosys,		/* pagerGetFileSize */
!     (void(*)(struct gnode *, vpn_t, vpn_t *, vpn_t *, vpn_t *, boolean_t))
! 	afs_gn_enosys,		/* pagerReadAhead */
!     (void(*)(struct gnode *, int64_t, int64_t, uint))
! 	afs_gn_enosys,		/* pagerReadWriteBehind */
!     (void(*)(struct gnode*,long long,unsigned long,unsigned long,unsigned int))
! 	afs_gn_enosys		/* pagerEndCopy */
  #endif
  };
  
***************
*** 2700,2705 ****
      AFS_MOUNT_AFS,
      "afs",
      Afs_init,
!     GFS_VERSION4 | GFS_REMOTE,
      NULL
  };
--- 2523,2528 ----
      AFS_MOUNT_AFS,
      "afs",
      Afs_init,
!     GFS_VERSION4 | GFS_VERSION42 | GFS_REMOTE,
      NULL
  };
Index: openafs/src/afs/DARWIN/osi_file.c
diff -c openafs/src/afs/DARWIN/osi_file.c:1.8 openafs/src/afs/DARWIN/osi_file.c:1.8.2.1
*** openafs/src/afs/DARWIN/osi_file.c:1.8	Tue Jul 15 19:14:17 2003
--- openafs/src/afs/DARWIN/osi_file.c	Wed Oct  5 01:58:29 2005
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/DARWIN/osi_file.c,v 1.8 2003/07/15 23:14:17 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/DARWIN/osi_file.c,v 1.8.2.1 2005/10/05 05:58:29 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 32,37 ****
--- 32,40 ----
  {
      int code;
      static int inited = 0;
+ #ifdef AFS_DARWIN80_ENV
+     char *buffer = (char*)_MALLOC(MFSNAMELEN, M_TEMP, M_WAITOK);
+ #endif
  
      if (inited)
  	return;
***************
*** 39,62 ****
  
      if (vp == NULL)
  	return;
      if (strncmp("hfs", vp->v_mount->mnt_vfc->vfc_name, 3) == 0)
  	afs_CacheFSType = AFS_APPL_HFS_CACHE;
      else if (strncmp("ufs", vp->v_mount->mnt_vfc->vfc_name, 3) == 0)
  	afs_CacheFSType = AFS_APPL_UFS_CACHE;
      else
  	osi_Panic("Unknown cache vnode type\n");
  }
  
  ino_t
  VnodeToIno(vnode_t * avp)
  {
      unsigned long ret;
  
      if (afs_CacheFSType == AFS_APPL_UFS_CACHE) {
  	struct inode *ip = VTOI(avp);
  	ret = ip->i_number;
      } else if (afs_CacheFSType == AFS_APPL_HFS_CACHE) {
! #ifndef VTOH
  	struct vattr va;
  	if (VOP_GETATTR(avp, &va, &afs_osi_cred, current_proc()))
  	    osi_Panic("VOP_GETATTR failed in VnodeToIno\n");
--- 42,92 ----
  
      if (vp == NULL)
  	return;
+ #ifdef AFS_DARWIN80_ENV
+     vfs_name(vnode_mount(vp), buffer);
+     if (strncmp("hfs", buffer, 3) == 0)
+ #else
      if (strncmp("hfs", vp->v_mount->mnt_vfc->vfc_name, 3) == 0)
+ #endif
  	afs_CacheFSType = AFS_APPL_HFS_CACHE;
+ #ifdef AFS_DARWIN80_ENV
+     else if (strncmp("ufs", buffer, 3) == 0)
+ #else
      else if (strncmp("ufs", vp->v_mount->mnt_vfc->vfc_name, 3) == 0)
+ #endif
  	afs_CacheFSType = AFS_APPL_UFS_CACHE;
      else
  	osi_Panic("Unknown cache vnode type\n");
+ #ifdef AFS_DARWIN80_ENV
+     _FREE(buffer, M_TEMP);
+ #endif
  }
  
  ino_t
+ #ifdef AFS_DARWIN80_ENV
+ VnodeToIno(vnode_t avp)
+ #else
  VnodeToIno(vnode_t * avp)
+ #endif
  {
      unsigned long ret;
  
+ #ifndef AFS_DARWIN80_ENV
      if (afs_CacheFSType == AFS_APPL_UFS_CACHE) {
  	struct inode *ip = VTOI(avp);
  	ret = ip->i_number;
      } else if (afs_CacheFSType == AFS_APPL_HFS_CACHE) {
! #endif
! #if defined(AFS_DARWIN80_ENV) 
! 	struct vattr va;
! 	VATTR_INIT(&va);
!         VATTR_WANTED(&va, va_fileid);
! 	if (vnode_getattr(avp, &va, afs_osi_ctxtp))
! 	    osi_Panic("VOP_GETATTR failed in VnodeToIno\n");
!         if (!VATTR_ALL_SUPPORTED(&va))
! 	    osi_Panic("VOP_GETATTR unsupported fileid in VnodeToIno\n");
! 	ret = va.va_fileid;
! #elif !defined(VTOH)
  	struct vattr va;
  	if (VOP_GETATTR(avp, &va, &afs_osi_cred, current_proc()))
  	    osi_Panic("VOP_GETATTR failed in VnodeToIno\n");
***************
*** 65,86 ****
  	struct hfsnode *hp = VTOH(avp);
  	ret = H_FILEID(hp);
  #endif
      } else
  	osi_Panic("VnodeToIno called before cacheops initialized\n");
      return ret;
  }
  
  
  dev_t
  VnodeToDev(vnode_t * avp)
  {
! 
! 
      if (afs_CacheFSType == AFS_APPL_UFS_CACHE) {
  	struct inode *ip = VTOI(avp);
  	return ip->i_dev;
      } else if (afs_CacheFSType == AFS_APPL_HFS_CACHE) {
! #ifndef VTOH			/* slow, but works */
  	struct vattr va;
  	if (VOP_GETATTR(avp, &va, &afs_osi_cred, current_proc()))
  	    osi_Panic("VOP_GETATTR failed in VnodeToDev\n");
--- 95,131 ----
  	struct hfsnode *hp = VTOH(avp);
  	ret = H_FILEID(hp);
  #endif
+ #ifndef AFS_DARWIN80_ENV
      } else
  	osi_Panic("VnodeToIno called before cacheops initialized\n");
+ #endif
      return ret;
  }
  
  
  dev_t
+ #ifdef AFS_DARWIN80_ENV
+ VnodeToDev(vnode_t avp)
+ #else
  VnodeToDev(vnode_t * avp)
+ #endif
  {
! #ifndef AFS_DARWIN80_ENV
      if (afs_CacheFSType == AFS_APPL_UFS_CACHE) {
  	struct inode *ip = VTOI(avp);
  	return ip->i_dev;
      } else if (afs_CacheFSType == AFS_APPL_HFS_CACHE) {
! #endif
! #if defined(AFS_DARWIN80_ENV) || !defined(VTOH)
! 	struct vattr va;
!         VATTR_INIT(&va);
!         VATTR_WANTED(&va, va_fsid);
! 	if (vnode_getattr(avp, &va, afs_osi_ctxtp))
! 	    osi_Panic("VOP_GETATTR failed in VnodeToDev\n");
!         if (!VATTR_ALL_SUPPORTED(&va))
! 	    osi_Panic("VOP_GETATTR unsupported fsid in VnodeToIno\n");
! 	return va.va_fsid;	/* XXX they say it's the dev.... */
! #elif !defined(VTOH)
  	struct vattr va;
  	if (VOP_GETATTR(avp, &va, &afs_osi_cred, current_proc()))
  	    osi_Panic("VOP_GETATTR failed in VnodeToDev\n");
***************
*** 89,96 ****
--- 134,143 ----
  	struct hfsnode *hp = VTOH(avp);
  	return H_DEV(hp);
  #endif
+ #ifndef AFS_DARWIN80_ENV
      } else
  	osi_Panic("VnodeToDev called before cacheops initialized\n");
+ #endif
  }
  
  void *
***************
*** 115,128 ****
--- 162,179 ----
      }
      afile = (struct osi_file *)osi_AllocSmallSpace(sizeof(struct osi_file));
      AFS_GUNLOCK();
+ #ifndef AFS_DARWIN80_ENV
      if (afs_CacheFSType == AFS_APPL_HFS_CACHE)
  	code = igetinode(afs_cacheVfsp, (dev_t) cacheDev.dev, &ainode, &vp, &va, &dummy);	/* XXX hfs is broken */
      else if (afs_CacheFSType == AFS_APPL_UFS_CACHE)
+ #endif
  	code =
  	    igetinode(afs_cacheVfsp, (dev_t) cacheDev.dev, (ino_t) ainode,
  		      &vp, &va, &dummy);
+ #ifndef AFS_DARWIN80_ENV
      else
  	panic("osi_UFSOpen called before cacheops initialized\n");
+ #endif
      AFS_GLOCK();
      if (code) {
  	osi_FreeSmallSpace(afile);
***************
*** 144,150 ****
--- 195,212 ----
      AFS_STATCNT(osi_Stat);
      MObtainWriteLock(&afs_xosi, 320);
      AFS_GUNLOCK();
+ #ifdef AFS_DARWIN80_ENV
+     VATTR_INIT(&tvattr);
+     VATTR_WANTED(&tvattr, va_size);
+     VATTR_WANTED(&tvattr, va_blocksize);
+     VATTR_WANTED(&tvattr, va_mtime);
+     VATTR_WANTED(&tvattr, va_atime);
+     code = vnode_getattr(afile->vnode, &tvattr, afs_osi_ctxtp);
+     if (code == 0 && !VATTR_ALL_SUPPORTED(&tvattr))
+        code = EINVAL;
+ #else
      code = VOP_GETATTR(afile->vnode, &tvattr, &afs_osi_cred, current_proc());
+ #endif
      AFS_GLOCK();
      if (code == 0) {
  	astat->size = tvattr.va_size;
***************
*** 161,167 ****
--- 223,233 ----
  {
      AFS_STATCNT(osi_Close);
      if (afile->vnode) {
+ #ifdef AFS_DARWIN80_ENV
+         vnode_close(afile->vnode, O_RDWR, afs_osi_ctxtp);
+ #else
  	AFS_RELE(afile->vnode);
+ #endif
      }
  
      osi_FreeSmallSpace(afile);
***************
*** 185,204 ****
      if (code || tstat.size <= asize)
  	return code;
      MObtainWriteLock(&afs_xosi, 321);
      VATTR_NULL(&tvattr);
      tvattr.va_size = asize;
-     AFS_GUNLOCK();
      code = VOP_SETATTR(afile->vnode, &tvattr, &afs_osi_cred, current_proc());
      AFS_GLOCK();
      MReleaseWriteLock(&afs_xosi);
      return code;
  }
  
  void
  osi_DisableAtimes(struct vnode *avp)
  {
  
! 
      if (afs_CacheFSType == AFS_APPL_UFS_CACHE) {
  	struct inode *ip = VTOI(avp);
  	ip->i_flag &= ~IN_ACCESS;
--- 251,285 ----
      if (code || tstat.size <= asize)
  	return code;
      MObtainWriteLock(&afs_xosi, 321);
+     AFS_GUNLOCK();
+ #ifdef AFS_DARWIN80_ENV
+     VATTR_INIT(&tvattr);
+     VATTR_SET(&tvattr, va_size, asize);
+     code = vnode_getattr(afile->vnode, &tvattr, afs_osi_ctxtp);
+ #else
      VATTR_NULL(&tvattr);
      tvattr.va_size = asize;
      code = VOP_SETATTR(afile->vnode, &tvattr, &afs_osi_cred, current_proc());
+ #endif
      AFS_GLOCK();
      MReleaseWriteLock(&afs_xosi);
      return code;
  }
  
  void
+ #ifdef AFS_DARWIN80_ENV
+ osi_DisableAtimes(vnode_t avp)
+ #else
  osi_DisableAtimes(struct vnode *avp)
+ #endif
  {
+ #ifdef AFS_DARWIN80_ENV
+     struct vnode_attr vap;
  
!     VATTR_INIT(&vap);
!     VATTR_CLEAR_SUPPORTED(&vap, va_access_time);
!     vnode_setattr(avp, &vap, afs_osi_ctxtp);
! #else
      if (afs_CacheFSType == AFS_APPL_UFS_CACHE) {
  	struct inode *ip = VTOI(avp);
  	ip->i_flag &= ~IN_ACCESS;
***************
*** 209,214 ****
--- 290,296 ----
  	hp->h_nodeflags &= ~IN_ACCESS;
      }
  #endif
+ #endif
  }
  
  
***************
*** 220,225 ****
--- 302,310 ----
      struct AFS_UCRED *oldCred;
      unsigned int resid;
      register afs_int32 code;
+ #ifdef AFS_DARWIN80_ENV
+     uio_t uio;
+ #endif
      AFS_STATCNT(osi_Read);
  
      /**
***************
*** 236,244 ****
--- 321,337 ----
      if (offset != -1)
  	afile->offset = offset;
      AFS_GUNLOCK();
+ #ifdef AFS_DARWIN80_ENV
+     uio=uio_create(1, afile->offset, AFS_UIOSYS, UIO_READ);
+     uio_addiov(uio, CAST_USER_ADDR_T(aptr), asize);
+     code = VNOP_READ(afile->vnode, uio, IO_UNIT, afs_osi_ctxtp);
+     resid = AFS_UIO_RESID(uio);
+     uio_free(uio);
+ #else
      code =
  	gop_rdwr(UIO_READ, afile->vnode, (caddr_t) aptr, asize, afile->offset,
  		 AFS_UIOSYS, IO_UNIT, &afs_osi_cred, &resid);
+ #endif
      AFS_GLOCK();
      if (code == 0) {
  	code = asize - resid;
***************
*** 260,265 ****
--- 353,361 ----
      struct AFS_UCRED *oldCred;
      unsigned int resid;
      register afs_int32 code;
+ #ifdef AFS_DARWIN80_ENV
+     uio_t uio;
+ #endif
      AFS_STATCNT(osi_Write);
      if (!afile)
  	osi_Panic("afs_osi_Write called with null param");
***************
*** 267,276 ****
--- 363,380 ----
  	afile->offset = offset;
      {
  	AFS_GUNLOCK();
+ #ifdef AFS_DARWIN80_ENV
+         uio=uio_create(1, afile->offset, AFS_UIOSYS, UIO_WRITE);
+         uio_addiov(uio, CAST_USER_ADDR_T(aptr), asize);
+         code = VNOP_WRITE(afile->vnode, uio, IO_UNIT, afs_osi_ctxtp);
+         resid = AFS_UIO_RESID(uio);
+         uio_free(uio);
+ #else
  	code =
  	    gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize,
  		     afile->offset, AFS_UIOSYS, IO_UNIT, &afs_osi_cred,
  		     &resid);
+ #endif
  	AFS_GLOCK();
      }
      if (code == 0) {
Index: openafs/src/afs/DARWIN/osi_groups.c
diff -c openafs/src/afs/DARWIN/osi_groups.c:1.5 openafs/src/afs/DARWIN/osi_groups.c:1.5.2.1
*** openafs/src/afs/DARWIN/osi_groups.c:1.5	Tue Jul 15 19:14:17 2003
--- openafs/src/afs/DARWIN/osi_groups.c	Wed Oct  5 01:58:29 2005
***************
*** 18,25 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/DARWIN/osi_groups.c,v 1.5 2003/07/15 23:14:17 shadow Exp $");
! 
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
  #include "afs/afs_stats.h"	/* statistics */
--- 18,37 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/DARWIN/osi_groups.c,v 1.5.2.1 2005/10/05 05:58:29 shadow Exp $");
! /* We should be doing something better anyway */
! #ifdef AFS_DARWIN80_ENV
! int
! setpag(proc, cred, pagvalue, newpag, change_parent)
!      struct proc *proc;
!      struct ucred **cred;
!      afs_uint32 pagvalue;
!      afs_uint32 *newpag;
!      afs_uint32 change_parent;
! { 
!   return -1;
! }
! #else
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
  #include "afs/afs_stats.h"	/* statistics */
***************
*** 75,88 ****
  }
  
  
- int
- setpag(proc, cred, pagvalue, newpag, change_parent)
-      struct proc *proc;
-      struct ucred **cred;
-      afs_uint32 pagvalue;
-      afs_uint32 *newpag;
-      afs_uint32 change_parent;
- {
      gid_t gidset[NGROUPS];
      int ngroups, code;
      int j;
--- 87,92 ----
***************
*** 159,161 ****
--- 163,166 ----
      crfree(oldcr);
      return (0);
  }
+ #endif
Index: openafs/src/afs/DARWIN/osi_inode.c
diff -c openafs/src/afs/DARWIN/osi_inode.c:1.7 openafs/src/afs/DARWIN/osi_inode.c:1.7.2.1
*** openafs/src/afs/DARWIN/osi_inode.c:1.7	Wed Jul 28 23:13:44 2004
--- openafs/src/afs/DARWIN/osi_inode.c	Wed Oct  5 01:58:29 2005
***************
*** 16,30 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/DARWIN/osi_inode.c,v 1.7 2004/07/29 03:13:44 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
  #include "afs/osi_inode.h"
  #include "afs/afs_stats.h"	/* statistics stuff */
  #include <ufs/ufs/ufsmount.h>
  extern struct ucred afs_osi_cred;
  
  getinode(fs, dev, inode, vpp, perror)
       struct mount *fs;
       struct vnode **vpp;
--- 16,110 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/DARWIN/osi_inode.c,v 1.7.2.1 2005/10/05 05:58:29 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
  #include "afs/osi_inode.h"
  #include "afs/afs_stats.h"	/* statistics stuff */
+ #ifndef AFS_DARWIN80_ENV
  #include <ufs/ufs/ufsmount.h>
+ #endif
  extern struct ucred afs_osi_cred;
+ extern int afs_CacheFSType;
  
+ #ifdef AFS_DARWIN80_ENV
+ getinode(fs, dev, inode, vpp, perror)
+     mount_t fs;
+     vnode_t *vpp;
+     dev_t dev;
+     ino_t inode;
+     int *perror;
+ {
+     struct vnode *vp;
+     int code;
+     vfs_context_t ctx;
+     char volfspath[64];
+     
+     *vpp = 0;
+     *perror = 0;
+     sprintf(volfspath, "/.vol/%d/%d", dev, inode);
+     code = vnode_open(volfspath, O_RDWR, 0, 0, &vp, afs_osi_ctxtp);
+     if (code) {
+ 	*perror = BAD_IGET;
+ 	return code;
+     } else {
+ 	*vpp = vp;
+ 	return (0);
+     }
+ }    
+     
+   
+ igetinode(vfsp, dev, inode, vpp, va, perror)
+     vnode_t *vpp;
+     mount_t vfsp;
+     dev_t dev;
+     ino_t inode;
+     struct vattr *va;
+     int *perror;
+ {
+     vnode_t pvp, vp;
+     extern struct osi_dev cacheDev;
+     register int code = 0;
+     
+     *perror = 0;
+     
+     AFS_STATCNT(igetinode);
+     if ((code = getinode(vfsp, dev, inode, &vp, perror)) != 0) {
+ 	return (code);
+     }
+     if (vnode_vtype(vp) != VREG && vnode_vtype(vp) != VDIR && vnode_vtype(vp) != VLNK) {
+ 	vnode_close(vp, O_RDWR, afs_osi_ctxtp);
+ 	printf("igetinode: bad type %d\n", vnode_vtype(vp));
+ 	return (ENOENT);
+     }
+     VATTR_INIT(va);
+     VATTR_WANTED(va, va_mode);
+     VATTR_WANTED(va, va_nlink);
+     VATTR_WANTED(va, va_size);
+     code = vnode_getattr(vp, va, afs_osi_ctxtp);
+     if (code) {
+ 	vnode_close(vp, O_RDWR, afs_osi_ctxtp);
+         return code;
+     }
+     if (!VATTR_ALL_SUPPORTED(va)) {
+ 	vnode_close(vp, O_RDWR, afs_osi_ctxtp);
+         return ENOENT;
+     }
+     if (va->va_mode == 0) {
+ 	vnode_close(vp, O_RDWR, afs_osi_ctxtp);
+ 	/* Not an allocated inode */
+ 	return (ENOENT);
+     }
+     if (va->va_nlink == 0) {
+ 	vnode_close(vp, O_RDWR, afs_osi_ctxtp);
+ 	return (ENOENT);
+     }
+     
+     *vpp = vp;
+     return (0);
+ }
+ #else
  getinode(fs, dev, inode, vpp, perror)
       struct mount *fs;
       struct vnode **vpp;
***************
*** 85,91 ****
  	return (0);
      }
  }
! extern int afs_CacheFSType;
  igetinode(vfsp, dev, inode, vpp, va, perror)
       struct vnode **vpp;
       struct mount *vfsp;
--- 165,171 ----
  	return (0);
      }
  }
! 
  igetinode(vfsp, dev, inode, vpp, va, perror)
       struct vnode **vpp;
       struct mount *vfsp;
***************
*** 151,306 ****
  	vput(vp);
      }
  }
  
- #if 0
- /*
-  * icreate system call -- create an inode
-  */
- afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, retval)
-      long *retval;
-      long dev, near_inode, param1, param2, param3, param4;
- {
-     int dummy, err = 0;
-     struct inode *ip, *newip;
-     register int code;
-     struct vnode *vp;
- 
-     AFS_STATCNT(afs_syscall_icreate);
- 
-     if (!afs_suser(NULL))
- 	return (EPERM);
- 
-     code = getinode(0, (dev_t) dev, 2, &ip, &dummy);
-     if (code) {
- 	return (ENOENT);
-     }
-     code = ialloc(ip, (ino_t) near_inode, 0, &newip);
-     iput(ip);
-     if (code) {
- 	return (code);
-     }
-     IN_LOCK(newip);
-     newip->i_flag |= IACC | IUPD | ICHG;
- 
-     newip->i_nlink = 1;
- 
-     newip->i_mode = IFREG;
- 
-     IN_UNLOCK(newip);
-     vp = ITOV(newip);
-     VN_LOCK(vp);
-     vp->v_type = VREG;
-     VN_UNLOCK(vp);
- 
-     if (!vp->v_object) {
- 	extern struct vfs_ubcops ufs_ubcops;
- 	extern struct vm_ubc_object *ubc_object_allocate();
- 	struct vm_ubc_object *vop;
- 	vop = ubc_object_allocate(&vp, &ufs_ubcops, vp->v_mount->m_funnel);
- 	VN_LOCK(vp);
- 	vp->v_object = vop;
- 	VN_UNLOCK(vp);
-     }
- 
- 
-     IN_LOCK(newip);
-     newip->i_flags |= IC_XUID | IC_XGID;
-     newip->i_flags &= ~IC_PROPLIST;
-     newip->i_vicep1 = param1;
-     if (param2 == 0x1fffffff /*INODESPECIAL*/) {
- 	newip->i_vicep2 = ((0x1fffffff << 3) + (param4 & 0x3));
- 	newip->i_vicep3a = (u_short) (param3 >> 16);
- 	newip->i_vicep3b = (u_short) param3;
-     } else {
- 	newip->i_vicep2 =
- 	    (((param2 >> 16) & 0x1f) << 27) +
- 	    (((param4 >> 16) & 0x1f) << 22) + (param3 & 0x3fffff);
- 	newip->i_vicep3a = (u_short) param4;
- 	newip->i_vicep3b = (u_short) param2;
-     }
-     newip->i_vicemagic = VICEMAGIC;
- 
-     *retval = newip->i_number;
-     IN_UNLOCK(newip);
-     iput(newip);
-     return (code);
- }
- 
- 
- afs_syscall_iopen(dev, inode, usrmod, retval)
-      long *retval;
-      int dev, inode, usrmod;
- {
-     struct file *fp;
-     struct inode *ip;
-     struct vnode *vp = NULL;
-     int dummy;
-     int fd;
-     extern struct fileops vnops;
-     register int code;
- 
-     AFS_STATCNT(afs_syscall_iopen);
- 
-     if (!afs_suser(NULL))
- 	return (EPERM);
- 
-     code = igetinode(0, (dev_t) dev, (ino_t) inode, &ip, &dummy);
-     if (code) {
- 	return (code);
-     }
-     if ((code = falloc(&fp, &fd)) != 0) {
- 	iput(ip);
- 	return (code);
-     }
-     IN_UNLOCK(ip);
- 
-     FP_LOCK(fp);
-     fp->f_flag = (usrmod - FOPEN) & FMASK;
-     fp->f_type = DTYPE_VNODE;
-     fp->f_ops = &vnops;
-     fp->f_data = (caddr_t) ITOV(ip);
- 
-     FP_UNLOCK(fp);
-     U_FD_SET(fd, fp, &u.u_file_state);
-     *retval = fd;
-     return (0);
- }
- 
- 
- /*
-  * Support for iinc() and idec() system calls--increment or decrement
-  * count on inode.
-  * Restricted to super user.
-  * Only VICEMAGIC type inodes.
-  */
- afs_syscall_iincdec(dev, inode, inode_p1, amount)
-      int dev, inode, inode_p1, amount;
- {
-     int dummy;
-     struct inode *ip;
-     register int code;
- 
-     if (!afs_suser(NULL))
- 	return (EPERM);
- 
-     code = igetinode(0, (dev_t) dev, (ino_t) inode, &ip, &dummy);
-     if (code) {
- 	return (code);
-     }
-     if (!IS_VICEMAGIC(ip)) {
- 	return (EPERM);
-     } else if (ip->i_vicep1 != inode_p1) {
- 	return (ENXIO);
-     }
-     ip->i_nlink += amount;
-     if (ip->i_nlink == 0) {
- 	CLEAR_VICEMAGIC(ip);
-     }
-     ip->i_flag |= ICHG;
-     iput(ip);
-     return (0);
- }
- #else
  afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, retval)
       long *retval;
       long dev, near_inode, param1, param2, param3, param4;
--- 231,238 ----
  	vput(vp);
      }
  }
+ #endif
  
  afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, retval)
       long *retval;
       long dev, near_inode, param1, param2, param3, param4;
***************
*** 320,323 ****
  {
      return EOPNOTSUPP;
  }
- #endif
--- 252,254 ----
Index: openafs/src/afs/DARWIN/osi_machdep.h
diff -c openafs/src/afs/DARWIN/osi_machdep.h:1.3.2.3 openafs/src/afs/DARWIN/osi_machdep.h:1.3.2.4
*** openafs/src/afs/DARWIN/osi_machdep.h:1.3.2.3	Wed Apr 13 22:31:35 2005
--- openafs/src/afs/DARWIN/osi_machdep.h	Wed Oct  5 01:58:29 2005
***************
*** 25,36 ****
  #endif
  #endif
  
  #include <sys/lock.h>
- #include <kern/thread.h>
  #include <sys/user.h>
  
  #define getpid()                current_proc()->p_pid
  #define getppid()               current_proc()->p_pptr->p_pid
  #undef gop_lookupname
  #define gop_lookupname osi_lookupname
  
--- 25,60 ----
  #endif
  #endif
  
+ #ifdef AFS_DARWIN80_ENV
+ #include <kern/locks.h>
+ #include <sys/mount.h>
+ #include <h/vnode.h>
+ #else
  #include <sys/lock.h>
  #include <sys/user.h>
+ #include <sys/vnode.h>
+ #endif
+ #include <kern/thread.h>
  
+ #ifdef AFS_DARWIN80_ENV
+ #define vop_proc vfs_context_proc(ap->a_context)
+ #define vop_cred vfs_context_ucred(ap->a_context)
+ #define cn_proc(cnp) vfs_context_proc(ap->a_context)
+ #define cn_cred(cnp) vfs_context_ucred(ap->a_context)
+ #define vop_cn_proc vfs_context_proc(ap->a_context)
+ #define vop_cn_cred vfs_context_ucred(ap->a_context)
+ #define getpid()                proc_selfpid()
+ #define getppid()               proc_selfppid()
+ #else
+ #define vop_proc ap->a_p
+ #define vop_cred ap->a_cred
+ #define cn_proc(cnp) (cnp)->cn_proc
+ #define cn_cred(cnp) (cnp)->cn_cred
+ #define vop_cn_proc cn_proc(ap->a_cnp)
+ #define vop_cn_cred cn_cred(ap->a_cnp)
  #define getpid()                current_proc()->p_pid
  #define getppid()               current_proc()->p_pptr->p_pid
+ #endif
  #undef gop_lookupname
  #define gop_lookupname osi_lookupname
  
***************
*** 39,52 ****
--- 63,132 ----
  /* vcexcl - used only by afs_create */
  enum vcexcl { EXCL, NONEXCL };
  
+ #ifndef AFS_DARWIN80_ENV
+ #define vnode_clearfsnode(x) ((x)->v_data = 0)
+ #define vnode_fsnode(x) (x)->v_data
+ #define vnode_lock(x) vn_lock(x, LK_EXCLUSIVE | LK_RETRY, current_proc());
+ #define vnode_isvroot(x) (((x)->v_flag & VROOT)?1:0)
+ #define vnode_vtype(x) (x)->v_type
+ #define vnode_isdir(x) ((x)->v_type == VDIR)
+ 
+ #define vfs_flags(x) (x)->v_flags
+ #define vfs_setflags(x, y) (x)->mnt_flag |= (y)
+ #define vfs_clearflags(x, y) (x)->mnt_flag &= (~(y))
+ #define vfs_isupdate(x) ((x)->mnt_flag & MNT_UPDATE)
+ #define vfs_fsprivate(x) (x)->mnt_data
+ #define vfs_setfsprivate(x,y) (x)->mnt_data = (y)
+ #define vfs_typenum(x) (x)->mnt_vfc->vfc_typenum
+ #endif
+ 
+ #ifdef AFS_DARWIN80_ENV
+ #define vrele vnode_rele
+ #define vput vnode_rele
+ #define vref vnode_ref
+ #define vattr vnode_attr
+ #if 0
+ #define vn_lock(v, unused1, unused2) vnode_get((v))
+ #define VOP_LOCK(v, unused1, unused2) vnode_get((v))
+ #define VOP_UNLOCK(v, unused1, unused2) vnode_put((v))
+ #endif
+ 
+ #define va_size va_data_size
+ #define va_atime va_access_time
+ #define va_mtime va_modify_time
+ #define va_ctime va_change_time
+ #define va_bytes va_total_alloc 
+ #define va_blocksize va_iosize
+ #define va_nodeid va_fileid
+ 
+ #define crref kauth_cred_get_with_ref
+ #define crhold kauth_cred_ref
+ #define crfree kauth_cred_rele
+ #define crdup kauth_cred_dup
+ 
+ extern vfs_context_t afs_osi_ctxtp;
+ extern int afs_osi_ctxtp_initialized;
+ #endif
+ 
  /* 
   * Time related macros
   */
  #ifndef AFS_DARWIN60_ENV
  extern struct timeval time;
  #endif
+ #ifdef AFS_DARWIN80_ENV
+ static inline time_t osi_Time(void) {
+     struct timeval _now;
+     microtime(&_now);
+     return _now.tv_sec;
+ }
+ #else
  #define osi_Time() (time.tv_sec)
+ #endif
  #define afs_hz      hz
+ #ifdef AFS_DARWIN80_ENV
+ extern int hz;
+ #endif
  
  #define PAGESIZE 8192
  
***************
*** 58,63 ****
--- 138,147 ----
  #define VN_HOLD(vp) darwin_vn_hold(vp)
  #define VN_RELE(vp) vrele(vp);
  
+ void darwin_vn_hold(struct vnode *vp);
+ #ifdef AFS_DARWIN80_ENV
+ void darwin_vn_rele(struct vnode *vp);
+ #endif
  
  #define gop_rdwr(rw,gp,base,len,offset,segflg,unit,cred,aresid) \
    vn_rdwr((rw),(gp),(base),(len),(offset),(segflg),(unit),(cred),(aresid),current_proc())
***************
*** 67,72 ****
--- 151,173 ----
  #ifdef KERNEL
  extern thread_t afs_global_owner;
  /* simple locks cannot be used since sleep can happen at any time */
+ #ifdef AFS_DARWIN80_ENV
+ /* mach locks still don't have an exported try, but we are forced to use them */
+ extern lck_mtx_t  *afs_global_lock;
+ #define AFS_GLOCK() \
+     do { \
+ 	osi_Assert(afs_global_owner != current_thread()); \
+ 	lck_mtx_lock(afs_global_lock); \
+ 	osi_Assert(afs_global_owner == 0); \
+ 	afs_global_owner = current_thread(); \
+     } while (0)
+ #define AFS_GUNLOCK() \
+     do { \
+ 	osi_Assert(afs_global_owner == current_thread()); \
+ 	afs_global_owner = 0; \
+         lck_mtx_unlock(afs_global_lock); \
+     } while(0)
+ #else
  /* Should probably use mach locks rather than bsd locks, since we use the
     mach thread control api's elsewhere (mach locks not used for consistency
     with rx, since rx needs lock_write_try() in order to use mach locks
***************
*** 84,89 ****
--- 185,191 ----
  	afs_global_owner = 0; \
          lockmgr(&afs_global_lock, LK_RELEASE, 0, current_proc()); \
      } while(0)
+ #endif
  #define ISAFS_GLOCK() (afs_global_owner == current_thread())
  
  #define SPLVAR
***************
*** 101,114 ****
  #define AFS_APPL_UFS_CACHE 1
  #define AFS_APPL_HFS_CACHE 2
  
! extern ino_t VnodeToIno(vnode_t * vp);
! extern dev_t VnodeToDev(vnode_t * vp);
  
  #define osi_curproc() current_proc()
  
  /* FIXME */
  #define osi_curcred() &afs_osi_cred 
  
  #endif /* KERNEL */
  
  #endif /* _OSI_MACHDEP_H_ */
--- 203,224 ----
  #define AFS_APPL_UFS_CACHE 1
  #define AFS_APPL_HFS_CACHE 2
  
! extern ino_t VnodeToIno(struct vnode * vp);
! extern dev_t VnodeToDev(struct vnode * vp);
! extern int igetinode(mount_t vfsp, dev_t dev , ino_t inode, vnode_t *vpp,
!               struct vattr *va, int *perror);
  
  #define osi_curproc() current_proc()
  
  /* FIXME */
  #define osi_curcred() &afs_osi_cred 
  
+ #ifdef AFS_DARWIN80_ENV
+ uio_t afsio_darwin_partialcopy(uio_t auio, int size);
+ 
+ #define uprintf printf
+ #endif
+ 
  #endif /* KERNEL */
  
  #endif /* _OSI_MACHDEP_H_ */
Index: openafs/src/afs/DARWIN/osi_misc.c
diff -c openafs/src/afs/DARWIN/osi_misc.c:1.6.2.1 openafs/src/afs/DARWIN/osi_misc.c:1.6.2.2
*** openafs/src/afs/DARWIN/osi_misc.c:1.6.2.1	Fri Mar 11 01:50:35 2005
--- openafs/src/afs/DARWIN/osi_misc.c	Wed Oct  5 01:58:29 2005
***************
*** 11,22 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/DARWIN/osi_misc.c,v 1.6.2.1 2005/03/11 06:50:35 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
  #include <sys/namei.h>
  
  int
  osi_lookupname(char *aname, enum uio_seg seg, int followlink,
  	       struct vnode **vpp)
--- 11,54 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/DARWIN/osi_misc.c,v 1.6.2.2 2005/10/05 05:58:29 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
  #include <sys/namei.h>
  
+ #ifndef PATHBUFLEN
+ #define PATHBUFLEN 256
+ #endif
+ 
+ #ifdef AFS_DARWIN80_ENV
+ int
+ osi_lookupname(char *aname, enum uio_seg seg, int followlink,
+ 	       struct vnode **vpp) {
+     vfs_context_t ctx;
+     char tname[PATHBUFLEN];
+     int code, flags;
+     size_t len;
+     
+     if (seg == AFS_UIOUSER) { /* XXX 64bit */
+ 	AFS_COPYINSTR(aname, tname, sizeof(tname), &len, code);
+ 	if (code)
+ 	    return code;
+ 	aname=tname;
+     }
+     flags = 0;
+     if (!followlink)
+ 	flags |= VNODE_LOOKUP_NOFOLLOW;
+     ctx=vfs_context_create(NULL);
+     code = vnode_lookup(aname, flags, vpp, ctx);
+     if (!code) { /* get a usecount */
+ 	vnode_ref(*vpp);
+ 	vnode_put(*vpp);
+     }
+     vfs_context_rele(ctx);
+     return code;
+ }
+ #else
  int
  osi_lookupname(char *aname, enum uio_seg seg, int followlink,
  	       struct vnode **vpp)
***************
*** 37,56 ****
      VOP_UNLOCK(n.ni_vp, 0, current_proc());
      return 0;
  }
  
  /*
   * afs_suser() returns true if the caller is superuser, false otherwise.
   *
   * Note that it must NOT set errno.
   */
! 
  afs_suser(void *credp)
  {
      int error;
      struct proc *p = current_proc();
  
      if ((error = suser(p->p_ucred, &p->p_acflag)) == 0) {
  	return (1);
      }
      return (0);
  }
--- 69,229 ----
      VOP_UNLOCK(n.ni_vp, 0, current_proc());
      return 0;
  }
+ #endif
  
  /*
   * afs_suser() returns true if the caller is superuser, false otherwise.
   *
   * Note that it must NOT set errno.
   */
! int
  afs_suser(void *credp)
  {
      int error;
      struct proc *p = current_proc();
  
+ #ifdef AFS_DARWIN80_ENV
+     if ((error = proc_suser(p)) == 0) {
+ 	return (1);
+     }
+     return (0);
+ #else
      if ((error = suser(p->p_ucred, &p->p_acflag)) == 0) {
  	return (1);
      }
      return (0);
+ #endif
+ }
+ 
+ #ifdef AFS_DARWIN80_ENV
+ uio_t afsio_darwin_partialcopy(uio_t auio, int size) {
+    uio_t res;
+    int i;
+    user_addr_t iovaddr;
+    user_size_t iovsize;
+ 
+    /* XXX 64 bit userspaace? */
+    res = uio_create(uio_iovcnt(auio), uio_offset(auio),
+                     uio_isuserspace(auio) ? UIO_USERSPACE32 : UIO_SYSSPACE32,
+                     uio_rw(auio));
+ 
+    for (i = 0;i < uio_iovcnt(auio) && size > 0;i++) {
+        if (uio_getiov(auio, i, &iovaddr, &iovsize))
+            break;
+        if (iovsize > size)
+           iovsize = size;
+        if (uio_addiov(res, iovaddr, iovsize))
+           break;
+        size -= iovsize;
+    }
+    return res;
  }
+ 
+ vfs_context_t afs_osi_ctxtp;
+ int afs_osi_ctxtp_initialized;
+ static thread_t vfs_context_owner;
+ #define RECURSIVE_VFS_CONTEXT 1
+ #if RECURSIVE_VFS_CONTEXT
+ static proc_t vfs_context_curproc;
+ int vfs_context_ref;
+ #else 
+ #define vfs_context_ref 1
+ #endif
+ void get_vfs_context(void) {
+   int isglock = ISAFS_GLOCK();
+ 
+   if (!isglock)
+      AFS_GLOCK();
+   if (afs_osi_ctxtp_initialized) {
+      if (!isglock)
+         AFS_GUNLOCK();
+       return;
+   }
+   osi_Assert(vfs_context_owner != current_thread());
+ #if RECURSIVE_VFS_CONTEXT
+   if (afs_osi_ctxtp && current_proc() == vfs_context_curproc) {
+      vfs_context_ref++;
+      vfs_context_owner = current_thread();
+      if (!isglock)
+         AFS_GUNLOCK();
+      return;
+   }
+ #endif
+   while (afs_osi_ctxtp && vfs_context_ref) {
+      printf("[%d] waiting for afs_osi_ctxtp\n", proc_selfpid());
+      afs_osi_Sleep(&afs_osi_ctxtp);
+      if (afs_osi_ctxtp_initialized) {
+        printf("[%d] ok\n", proc_selfpid());
+        if (!isglock)
+           AFS_GUNLOCK();
+        return;
+      }
+      if (!afs_osi_ctxtp || !vfs_context_ref)
+         printf("[%d] ok\n", proc_selfpid());
+   }
+ #if RECURSIVE_VFS_CONTEXT
+   vfs_context_rele(afs_osi_ctxtp);
+   vfs_context_ref=1;
+ #else
+   osi_Assert(vfs_context_owner == (thread_t)0);
+ #endif
+   afs_osi_ctxtp = vfs_context_create(NULL);
+   vfs_context_owner = current_thread();
+   vfs_context_curproc = current_proc();
+   if (!isglock)
+      AFS_GUNLOCK();
+ }
+ 
+ void put_vfs_context(void) {
+   int isglock = ISAFS_GLOCK();
+ 
+   if (!isglock)
+      AFS_GLOCK();
+   if (afs_osi_ctxtp_initialized) {
+      if (!isglock)
+         AFS_GUNLOCK();
+       return;
+   }
+ #if RECURSIVE_VFS_CONTEXT
+   if (vfs_context_owner == current_thread())
+       vfs_context_owner = (thread_t)0;
+   vfs_context_ref--;
+ #else
+   osi_Assert(vfs_context_owner == current_thread());
+   vfs_context_rele(afs_osi_ctxtp);
+   afs_osi_ctxtp = NULL;
+   vfs_context_owner = (thread_t)0;
+ #endif
+   afs_osi_Wakeup(&afs_osi_ctxtp);
+      if (!isglock)
+         AFS_GUNLOCK();
+ }
+ 
+ extern int afs3_syscall();
+ 
+ int afs_cdev_nop_openclose(dev_t dev, int flags, int devtype,struct proc *p) {
+   return 0;
+ }
+ extern int afs3_syscall(struct proc *p, void *data, unsigned long *retval);
+ 
+ int
+ afs_cdev_ioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct proc *p) {
+    unsigned long retval=0;
+    int code;
+    struct afssysargs *a = (struct afssysargs *)data;
+    if (proc_is64bit(p))
+      return EINVAL;
+ 
+   if (cmd != VIOC_SYSCALL) {
+      return EINVAL;
+   }
+ 
+  code=afs3_syscall(p, data, &retval);
+  if (code)
+     return code;
+  if (retval && a->syscall != AFSCALL_CALL && a->param1 != AFSOP_CACHEINODE) { printf("SSCall(%d,%d) is returning non-error value %d\n", a->syscall, a->param1, retval); }
+  a->retval = retval;
+  return 0; 
+ }
+ 
+ #endif
Index: openafs/src/afs/DARWIN/osi_module.c
diff -c openafs/src/afs/DARWIN/osi_module.c:1.10.2.1 openafs/src/afs/DARWIN/osi_module.c:1.10.2.2
*** openafs/src/afs/DARWIN/osi_module.c:1.10.2.1	Mon Apr  4 00:01:19 2005
--- openafs/src/afs/DARWIN/osi_module.c	Wed Oct  5 01:58:29 2005
***************
*** 2,19 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/DARWIN/osi_module.c,v 1.10.2.1 2005/04/04 04:01:19 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
  #ifdef AFS_DARWIN60_ENV		/* not in Kernel.framework anymore !?! */
  #include <sys/syscall.h>
  #else
  #include "sys/syscall.h"
  #endif
  #include <mach/kmod.h>
  
- struct vfsconf afs_vfsconf;
  extern struct vfsops afs_vfsops;
  extern struct mount *afs_globalVFS;
  extern int Afs_xsetgroups();
--- 2,39 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/DARWIN/osi_module.c,v 1.10.2.2 2005/10/05 05:58:29 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
+ #ifdef AFS_DARWIN80_ENV
+ static vfstable_t afs_vfstable;
+ static struct vfs_fsentry afs_vfsentry;
+ extern struct vnodeopv_desc afs_vnodeop_opv_desc;
+ extern struct vnodeopv_desc afs_dead_vnodeop_opv_desc;
+ static struct vnodeopv_desc *afs_vnodeop_opv_desc_list[2] =
+    { &afs_vnodeop_opv_desc, &afs_dead_vnodeop_opv_desc };
+ 
+ 
+ #include <sys/conf.h>
+ #include <miscfs/devfs/devfs.h>
+ #define seltrue eno_select
+ struct cdevsw afs_cdev = NO_CDEVICE;
+ #undef seltrue
+ static int afs_cdev_major;
+ extern open_close_fcn_t afs_cdev_nop_openclose;
+ extern ioctl_fcn_t afs_cdev_ioctl;
+ static void *afs_cdev_devfs_handle;
+ #else
  #ifdef AFS_DARWIN60_ENV		/* not in Kernel.framework anymore !?! */
  #include <sys/syscall.h>
  #else
  #include "sys/syscall.h"
  #endif
+ struct vfsconf afs_vfsconf;
+ #endif
  #include <mach/kmod.h>
  
  extern struct vfsops afs_vfsops;
  extern struct mount *afs_globalVFS;
  extern int Afs_xsetgroups();
***************
*** 26,35 ****
  kern_return_t
  afs_modload(struct kmod_info *ki, void *data)
  {
!     if (sysent[AFS_SYSCALL].sy_call != nosys) {
! 	printf("AFS_SYSCALL in use. aborting\n");
  	return KERN_FAILURE;
      }
      memset(&afs_vfsconf, 0, sizeof(struct vfsconf));
      strcpy(afs_vfsconf.vfc_name, "afs");
      afs_vfsconf.vfc_vfsops = &afs_vfsops;
--- 46,77 ----
  kern_return_t
  afs_modload(struct kmod_info *ki, void *data)
  {
!     osi_Init();
! #ifdef AFS_DARWIN80_ENV
!     memset(&afs_vfsentry, 0, sizeof(struct vfs_fsentry));
!     strcpy(afs_vfsentry.vfe_fsname, "afs");
!     afs_vfsentry.vfe_vfsops = &afs_vfsops;
!     afs_vfsentry.vfe_vopcnt = 2;
!     afs_vfsentry.vfe_opvdescs = afs_vnodeop_opv_desc_list;
!     /* We may be 64bit ready too (VFS_TBL64BITREADY) */
!     afs_vfsentry.vfe_flags = VFS_TBLTHREADSAFE|VFS_TBLNOTYPENUM;
!     if (vfs_fsadd(&afs_vfsentry, &afs_vfstable)) {
! 	printf("AFS: vfs_fsadd failed. aborting\n");
  	return KERN_FAILURE;
      }
+     afs_cdev.d_open = &afs_cdev_nop_openclose;
+     afs_cdev.d_close = &afs_cdev_nop_openclose;
+     afs_cdev.d_ioctl = &afs_cdev_ioctl;
+     afs_cdev_major = cdevsw_add(-1, &afs_cdev);
+     if (afs_cdev_major == -1) {
+ 	printf("AFS: cdevsw_add failed. aborting\n");
+         vfs_fsremove(afs_vfstable);
+ 	return KERN_FAILURE;
+     }
+     afs_cdev_devfs_handle = devfs_make_node(makedev(afs_cdev_major, 0),
+                                             DEVFS_CHAR, UID_ROOT, GID_WHEEL,
+                                             0666, "openafs_ioctl", 0);
+ #else
      memset(&afs_vfsconf, 0, sizeof(struct vfsconf));
      strcpy(afs_vfsconf.vfc_name, "afs");
      afs_vfsconf.vfc_vfsops = &afs_vfsops;
***************
*** 39,44 ****
--- 81,90 ----
  	printf("AFS: vfsconf_add failed. aborting\n");
  	return KERN_FAILURE;
      }
+     if (sysent[AFS_SYSCALL].sy_call != nosys) {
+ 	printf("AFS_SYSCALL in use. aborting\n");
+ 	return KERN_FAILURE;
+     }
      sysent[SYS_setgroups].sy_call = Afs_xsetgroups;
  #if 0
      sysent[SYS_ioctl].sy_call = afs_xioctl;
***************
*** 49,54 ****
--- 95,105 ----
  #ifdef KERNEL_FUNNEL
      sysent[AFS_SYSCALL].sy_funnel = KERNEL_FUNNEL;
  #endif
+ #endif
+ #ifdef AFS_DARWIN80_ENV
+     MUTEX_SETUP();
+     afs_global_lock = lck_mtx_alloc_init(openafs_lck_grp, 0);
+ #endif
      return KERN_SUCCESS;
  }
  
***************
*** 57,74 ****
  {
      if (afs_globalVFS)
  	return KERN_FAILURE;
      if (vfsconf_del("afs"))
  	return KERN_FAILURE;
      /* give up syscall entries for ioctl & setgroups, which we've stolen */
  #if 0
      sysent[SYS_ioctl].sy_call = ioctl;
  #endif
      sysent[SYS_setgroups].sy_call = setgroups;
      /* give up the stolen syscall entry */
      sysent[AFS_SYSCALL].sy_narg = 0;
      sysent[AFS_SYSCALL].sy_call = nosys;
      return KERN_SUCCESS;
  }
  
! KMOD_EXPLICIT_DECL(org.openafs.filesystems.afs, VERSION, afs_modload,
  		   afs_modunload)
--- 108,138 ----
  {
      if (afs_globalVFS)
  	return KERN_FAILURE;
+ #ifdef AFS_DARWIN80_ENV
+     if (vfs_fsremove(afs_vfstable))
+ 	return KERN_FAILURE;
+     devfs_remove(afs_cdev_devfs_handle);
+     cdevsw_remove(afs_cdev_major, &afs_cdev);
+ #else
      if (vfsconf_del("afs"))
  	return KERN_FAILURE;
      /* give up syscall entries for ioctl & setgroups, which we've stolen */
  #if 0
      sysent[SYS_ioctl].sy_call = ioctl;
  #endif
+ #ifndef AFS_DARWIN80_ENV
      sysent[SYS_setgroups].sy_call = setgroups;
+ #endif
      /* give up the stolen syscall entry */
      sysent[AFS_SYSCALL].sy_narg = 0;
      sysent[AFS_SYSCALL].sy_call = nosys;
+ #endif
+ #ifdef AFS_DARWIN80_ENV
+     MUTEX_FINISH();
+     lck_mtx_free(afs_global_lock, openafs_lck_grp);
+ #endif
      return KERN_SUCCESS;
  }
  
! KMOD_EXPLICIT_DECL(org.openafs.filesystems.afs, "1.3.82", afs_modload,
  		   afs_modunload)
Index: openafs/src/afs/DARWIN/osi_prototypes.h
diff -c openafs/src/afs/DARWIN/osi_prototypes.h:1.5.2.1 openafs/src/afs/DARWIN/osi_prototypes.h:1.5.2.2
*** openafs/src/afs/DARWIN/osi_prototypes.h:1.5.2.1	Fri Mar 11 01:50:35 2005
--- openafs/src/afs/DARWIN/osi_prototypes.h	Wed Oct  5 01:58:29 2005
***************
*** 20,25 ****
--- 20,28 ----
  /* osi_misc.c */
  extern int osi_lookupname(char *aname, enum uio_seg seg, int followlink,
  			  struct vnode **vpp);
+ extern int afs_suser(void *credp);
+ extern void get_vfs_context(void);
+ extern void put_vfs_context(void);
  
  /* osi_sleep.c */
  extern void afs_osi_fullSigMask(void);
***************
*** 28,31 ****
--- 31,39 ----
  /* osi_vm.c */
  extern void osi_VM_NukePages(struct vnode *vp, off_t offset, off_t size);
  extern int osi_VM_Setup(struct vcache *avc, int force);
+ 
+ /* osi_vnodeops.c */
+ extern int afs_darwin_getnewvnode(struct vcache *avc);
+ extern int afs_darwin_finalizevnode(struct vcache *avc, struct vnode *parent, 
+                                      struct componentname *cnp, int isroot);
  #endif /* _OSI_PROTO_H_ */
Index: openafs/src/afs/DARWIN/osi_sleep.c
diff -c openafs/src/afs/DARWIN/osi_sleep.c:1.10 openafs/src/afs/DARWIN/osi_sleep.c:1.10.2.1
*** openafs/src/afs/DARWIN/osi_sleep.c:1.10	Wed Jul 28 23:33:00 2004
--- openafs/src/afs/DARWIN/osi_sleep.c	Wed Oct  5 01:58:29 2005
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/DARWIN/osi_sleep.c,v 1.10 2004/07/29 03:33:00 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/DARWIN/osi_sleep.c,v 1.10.2.1 2005/10/05 05:58:29 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 138,143 ****
--- 138,146 ----
      while (seq == evp->seq) {
  	AFS_ASSERT_GLOCK();
  	AFS_GUNLOCK();
+ #ifdef AFS_DARWIN80_ENV
+         msleep(event, NULL, PVFS, "afs_osi_Sleep", NULL);
+ #else
  #ifdef AFS_DARWIN14_ENV
  	/* this is probably safe for all versions, but testing is hard */
  	sleep(event, PVFS);
***************
*** 145,150 ****
--- 148,154 ----
  	assert_wait((event_t) event, 0);
  	thread_block(0);
  #endif
+ #endif
  	AFS_GLOCK();
      }
      relevent(evp);
***************
*** 153,158 ****
--- 157,163 ----
  void 
  afs_osi_fullSigMask()
  {
+ #ifndef AFS_DARWIN80_ENV
      struct uthread *user_thread = (struct uthread *)get_bsdthread_info(current_act());
         
      /* Protect original sigmask */
***************
*** 162,172 ****
--- 167,179 ----
  	/* Mask all signals */
  	user_thread->uu_sigmask = ~(sigset_t)0;
      }
+ #endif
  }
  
  void 
  afs_osi_fullSigRestore()
  {
+ #ifndef AFS_DARWIN80_ENV
      struct uthread *user_thread = (struct uthread *)get_bsdthread_info(current_act());
         
      /* Protect original sigmask */
***************
*** 176,181 ****
--- 183,189 ----
  	/* Clear the oldmask */
  	user_thread->uu_oldmask = (sigset_t)0;
      }
+ #endif
  }
  
  int
***************
*** 199,213 ****
  {
      int code = 0;
      struct afs_event *evp;
!     int ticks, seq;
      int prio;
  
-     ticks = (ams * afs_hz) / 1000;
  
  
      evp = afs_getevent(event);
      seq = evp->seq;
      AFS_GUNLOCK();
  #ifdef AFS_DARWIN14_ENV
      /* this is probably safe for all versions, but testing is hard. */
      /* using tsleep instead of assert_wait/thread_set_timer/thread_block
--- 207,235 ----
  {
      int code = 0;
      struct afs_event *evp;
!     int seq;
      int prio;
+ #ifdef AFS_DARWIN80_ENV
+     struct timespec ts;
+ #else
+     int ticks;
+ #endif
  
  
  
      evp = afs_getevent(event);
      seq = evp->seq;
      AFS_GUNLOCK();
+ #ifdef AFS_DARWIN80_ENV
+     if (aintok)
+         prio = PCATCH | PPAUSE;
+     else
+         prio = PVFS;
+     ts.tv_sec = ams / 1000;
+     ts.tv_nsec = (ams % 1000) * 1000000;
+     code = msleep(event, NULL, prio, "afs_osi_TimedSleep", &ts);
+ #else
+     ticks = (ams * afs_hz) / 1000;
  #ifdef AFS_DARWIN14_ENV
      /* this is probably safe for all versions, but testing is hard. */
      /* using tsleep instead of assert_wait/thread_set_timer/thread_block
***************
*** 228,233 ****
--- 250,256 ----
      thread_block(0);
      code = 0;
  #endif
+ #endif
      AFS_GLOCK();
      if (seq == evp->seq)
  	code = EINTR;
Index: openafs/src/afs/DARWIN/osi_vfsops.c
diff -c openafs/src/afs/DARWIN/osi_vfsops.c:1.11.2.1 openafs/src/afs/DARWIN/osi_vfsops.c:1.11.2.2
*** openafs/src/afs/DARWIN/osi_vfsops.c:1.11.2.1	Mon Apr  4 00:01:19 2005
--- openafs/src/afs/DARWIN/osi_vfsops.c	Wed Oct  5 01:58:29 2005
***************
*** 5,11 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/DARWIN/osi_vfsops.c,v 1.11.2.1 2005/04/04 04:01:19 shadow Exp $");
  
  #include <afs/sysincludes.h>	/* Standard vendor system headers */
  #include <afsincludes.h>	/* Afs-based standard headers */
--- 5,11 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/DARWIN/osi_vfsops.c,v 1.11.2.2 2005/10/05 05:58:29 shadow Exp $");
  
  #include <afs/sysincludes.h>	/* Standard vendor system headers */
  #include <afsincludes.h>	/* Afs-based standard headers */
***************
*** 13,24 ****
--- 13,31 ----
  #include <sys/malloc.h>
  #include <sys/namei.h>
  #include <sys/conf.h>
+ #ifndef AFS_DARWIN80_ENV
  #include <sys/syscall.h>
+ #endif
  #include <sys/sysctl.h>
  #include "../afs/sysctl.h"
  
+ #ifndef M_UFSMNT
+ #define M_UFSMNT M_TEMP /* DARWIN80 MALLOC doesn't look at the type anyway */
+ #endif
+ 
  struct vcache *afs_globalVp = 0;
  struct mount *afs_globalVFS = 0;
+ int afs_vfs_typenum;
  
  int
  afs_quotactl()
***************
*** 45,107 ****
      return (EINVAL);
  }
  
  int
  afs_start(mp, flags, p)
       struct mount *mp;
       int flags;
!      struct proc *p;
  {
      return (0);			/* nothing to do. ? */
  }
  
  int
  afs_mount(mp, path, data, ndp, p)
       register struct mount *mp;
       char *path;
       caddr_t data;
       struct nameidata *ndp;
!      struct proc *p;
  {
      /* ndp contains the mounted-from device.  Just ignore it.
       * we also don't care about our proc struct. */
      size_t size;
      int error;
  
!     if (mp->mnt_flag & MNT_UPDATE)
  	return EINVAL;
  
      AFS_GLOCK();
      AFS_STATCNT(afs_mount);
  
!     if (data == NULL && afs_globalVFS) {	/* Don't allow remounts. */
  	AFS_GUNLOCK();
  	return (EBUSY);
      }
  
      afs_globalVFS = mp;
      mp->vfs_bsize = 8192;
-     vfs_getnewfsid(mp);
      mp->mnt_stat.f_iosize = 8192;
  
      (void)copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size);
      memset(mp->mnt_stat.f_mntonname + size, 0, MNAMELEN - size);
!     memset(mp->mnt_stat.f_mntfromname, 0, MNAMELEN);
  
!     if (data == NULL) {
! 	strcpy(mp->mnt_stat.f_mntfromname, "AFS");
  	/* null terminated string "AFS" will fit, just leave it be. */
! 	mp->mnt_data = (qaddr_t) NULL;
      } else {
  	struct VenusFid *rootFid = NULL;
  	struct volume *tvp;
  	char volName[MNAMELEN];
  
! 	(void)copyinstr((char *)data, volName, MNAMELEN - 1, &size);
  	memset(volName + size, 0, MNAMELEN - size);
  
  	if (volName[0] == 0) {
! 	    strcpy(mp->mnt_stat.f_mntfromname, "AFS");
! 	    mp->mnt_data = (qaddr_t) & afs_rootFid;
  	} else {
  	    struct cell *localcell = afs_GetPrimaryCell(READ_LOCK);
  	    if (localcell == NULL) {
--- 52,153 ----
      return (EINVAL);
  }
  
+ #ifdef AFS_DARWIN80_ENV
+ #define CTX_TYPE vfs_context_t
+ #define CTX_PROC_CONVERT(C) vfs_context_proc((C))
+ #define STATFS_TYPE struct vfsstatfs
+ #else
+ #define CTX_TYPE struct proc *
+ #define CTX_PROC_CONVERT(C) (C)
+ #define STATFS_TYPE struct statfs
+ #define vfs_statfs(VFS) &(VFS)->mnt_stat
+ #endif
+ #define PROC_DECL(out,in) struct proc *out = CTX_PROC_CONVERT(in)
+ 
  int
  afs_start(mp, flags, p)
       struct mount *mp;
       int flags;
!      CTX_TYPE p;
  {
      return (0);			/* nothing to do. ? */
  }
  
  int
+ afs_statfs(struct mount *mp, STATFS_TYPE *abp, CTX_TYPE ctx);
+ #ifdef AFS_DARWIN80_ENV
+ int
+ afs_mount(mp, devvp, data, ctx)
+      register struct mount *mp;
+      vnode_t *devvp;
+      user_addr_t data;
+      vfs_context_t ctx;
+ #else
+ int
  afs_mount(mp, path, data, ndp, p)
       register struct mount *mp;
       char *path;
       caddr_t data;
       struct nameidata *ndp;
!      CTX_TYPE ctx;
! #endif
  {
      /* ndp contains the mounted-from device.  Just ignore it.
       * we also don't care about our proc struct. */
      size_t size;
      int error;
+ #ifdef AFS_DARWIN80_ENV
+     struct vfsioattr ioattr;
+     /* vfs_statfs advertised as RO, but isn't */
+     /* new api will be needed to initialize this information (nfs needs to
+        set mntfromname too) */
+ #endif
+     STATFS_TYPE *mnt_stat = vfs_statfs(mp); 
  
!     if (vfs_isupdate(mp))
  	return EINVAL;
  
      AFS_GLOCK();
      AFS_STATCNT(afs_mount);
  
!     if (data == 0 && afs_globalVFS) {	/* Don't allow remounts. */
  	AFS_GUNLOCK();
  	return (EBUSY);
      }
  
      afs_globalVFS = mp;
+ #ifdef AFS_DARWIN80_ENV
+     vfs_ioattr(mp, &ioattr);
+     ioattr.io_devblocksize = 8192;
+     vfs_setioattr(mp, &ioattr);
+     /* f_iosize is handled in VFS_GETATTR */
+ #else
      mp->vfs_bsize = 8192;
      mp->mnt_stat.f_iosize = 8192;
+ #endif
+     vfs_getnewfsid(mp);
  
+ #ifndef AFS_DARWIN80_ENV
      (void)copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size);
      memset(mp->mnt_stat.f_mntonname + size, 0, MNAMELEN - size);
! #endif
!     memset(mnt_stat->f_mntfromname, 0, MNAMELEN);
  
!     if (data == 0) {
! 	strcpy(mnt_stat->f_mntfromname, "AFS");
  	/* null terminated string "AFS" will fit, just leave it be. */
! 	vfs_setfsprivate(mp, NULL);
      } else {
  	struct VenusFid *rootFid = NULL;
  	struct volume *tvp;
  	char volName[MNAMELEN];
  
! 	(void)copyinstr(data, volName, MNAMELEN - 1, &size);
  	memset(volName + size, 0, MNAMELEN - size);
  
  	if (volName[0] == 0) {
! 	    strcpy(mnt_stat->f_mntfromname, "AFS");
! 	    vfs_setfsprivate(mp, &afs_rootFid);
  	} else {
  	    struct cell *localcell = afs_GetPrimaryCell(READ_LOCK);
  	    if (localcell == NULL) {
***************
*** 110,116 ****
  	    }
  
  	    /* Set the volume identifier to "AFS:volume.name" */
! 	    snprintf(mp->mnt_stat.f_mntfromname, MNAMELEN - 1, "AFS:%s",
  		     volName);
  	    tvp =
  		afs_GetVolumeByName(volName, localcell->cellNum, 1,
--- 156,162 ----
  	    }
  
  	    /* Set the volume identifier to "AFS:volume.name" */
! 	    snprintf(mnt_stat->f_mntfromname, MNAMELEN - 1, "AFS:%s",
  		     volName);
  	    tvp =
  		afs_GetVolumeByName(volName, localcell->cellNum, 1,
***************
*** 129,163 ****
  		return ENODEV;
  	    }
  
! 	    mp->mnt_data = (qaddr_t) rootFid;
  	}
      }
      strcpy(mp->mnt_stat.f_fstypename, "afs");
      AFS_GUNLOCK();
!     (void)afs_statfs(mp, &mp->mnt_stat, p);
      return 0;
  }
  
  int
! afs_unmount(mp, flags, p)
       struct mount *mp;
       int flags;
!      struct proc *p;
  {
! 
      AFS_GLOCK();
      AFS_STATCNT(afs_unmount);
  
!     if (mp->mnt_data != (qaddr_t) - 1) {
! 	if (mp->mnt_data != NULL) {
! 	    FREE(mp->mnt_data, M_UFSMNT);
! 	    mp->mnt_data = (qaddr_t) - 1;
  	} else {
  	    if (flags & MNT_FORCE) {
                  if (afs_globalVp) {
                      AFS_GUNLOCK();
                      vrele(AFSTOV(afs_globalVp));
                      AFS_GLOCK();
                  }
  		afs_globalVp = NULL;
  		AFS_GUNLOCK();
--- 175,219 ----
  		return ENODEV;
  	    }
  
! 	    vfs_setfsprivate(mp, &rootFid);
  	}
      }
+ #ifdef AFS_DARWIN80_ENV
+     afs_vfs_typenum=vfs_typenum(mp);
+     vfs_setauthopaque(mp);
+     vfs_setauthopaqueaccess(mp);
+ #else
      strcpy(mp->mnt_stat.f_fstypename, "afs");
+ #endif
      AFS_GUNLOCK();
!     (void)afs_statfs(mp, mnt_stat, ctx);
      return 0;
  }
  
  int
! afs_unmount(mp, flags, ctx)
       struct mount *mp;
       int flags;
!      CTX_TYPE ctx;
  {
!     void *mdata = vfs_fsprivate(mp);
      AFS_GLOCK();
      AFS_STATCNT(afs_unmount);
  
!     if (mdata != (qaddr_t) - 1) {
! 	if (mdata != NULL) {
! 	    vfs_setfsprivate(mp, (qaddr_t) - 1);
! 	    FREE(mdata, M_UFSMNT);
  	} else {
  	    if (flags & MNT_FORCE) {
                  if (afs_globalVp) {
+ #ifdef AFS_DARWIN80_ENV
+                     afs_PutVCache(afs_globalVp);
+ #else
                      AFS_GUNLOCK();
                      vrele(AFSTOV(afs_globalVp));
                      AFS_GLOCK();
+ #endif
                  }
  		afs_globalVp = NULL;
  		AFS_GUNLOCK();
***************
*** 170,176 ****
  		return EBUSY;
  	    }
  	}
! 	mp->mnt_flag &= ~MNT_LOCAL;
      }
  
      AFS_GUNLOCK();
--- 226,232 ----
  		return EBUSY;
  	    }
  	}
! 	vfs_clearflags(mp, MNT_LOCAL);
      }
  
      AFS_GUNLOCK();
***************
*** 178,233 ****
      return 0;
  }
  
  int
  afs_root(struct mount *mp, struct vnode **vpp)
  {
      int error;
      struct vrequest treq;
      register struct vcache *tvp = 0;
      struct proc *p = current_proc();
!     struct ucred cr;
  
      pcred_readlock(p);
      cr = *p->p_cred->pc_ucred;
      pcred_unlock(p);
      AFS_GLOCK();
      AFS_STATCNT(afs_root);
!     if (mp->mnt_data == NULL && afs_globalVp
  	&& (afs_globalVp->states & CStatd)) {
  	tvp = afs_globalVp;
  	error = 0;
!     } else if (mp->mnt_data == (qaddr_t) - 1) {
  	error = ENOENT;
      } else {
! 	struct VenusFid *rootFid = (mp->mnt_data == NULL)
! 	    ? &afs_rootFid : (struct VenusFid *)mp->mnt_data;
! 
! 	if (afs_globalVp) {
! 	    afs_PutVCache(afs_globalVp);
! 	    afs_globalVp = NULL;
! 	}
  
! 	if (!(error = afs_InitReq(&treq, &cr)) && !(error = afs_CheckInit())) {
  	    tvp = afs_GetVCache(rootFid, &treq, NULL, NULL);
  	    /* we really want this to stay around */
  	    if (tvp) {
! 		if (mp->mnt_data == NULL)
  		    afs_globalVp = tvp;
  	    } else
  		error = ENOENT;
  	}
      }
      if (tvp) {
  	osi_vnhold(tvp, 0);
  	AFS_GUNLOCK();
  	vn_lock(AFSTOV(tvp), LK_EXCLUSIVE | LK_RETRY, p);
  	AFS_GLOCK();
! 	if (mp->mnt_data == NULL) {
  	    afs_globalVFS = mp;
  	}
  	*vpp = AFSTOV(tvp);
  	AFSTOV(tvp)->v_flag |= VROOT;
  	AFSTOV(tvp)->v_vfsp = mp;
      }
  
      afs_Trace2(afs_iclSetp, CM_TRACE_VFSROOT, ICL_TYPE_POINTER, *vpp,
--- 234,330 ----
      return 0;
  }
  
+ #ifdef AFS_DARWIN80_ENV
+ int
+ afs_root(struct mount *mp, struct vnode **vpp, vfs_context_t ctx)
+ #else
  int
  afs_root(struct mount *mp, struct vnode **vpp)
+ #endif
  {
+     void *mdata = vfs_fsprivate(mp);
      int error;
      struct vrequest treq;
      register struct vcache *tvp = 0;
+ #ifdef AFS_DARWIN80_ENV
+     struct ucred *cr = vfs_context_ucred(ctx);
+     int needref=0;
+ #else
      struct proc *p = current_proc();
!     struct ucred _cr;
!     struct ucred *cr =&_cr;
  
      pcred_readlock(p);
      cr = *p->p_cred->pc_ucred;
      pcred_unlock(p);
+ #endif
      AFS_GLOCK();
      AFS_STATCNT(afs_root);
!     if (mdata == NULL && afs_globalVp
  	&& (afs_globalVp->states & CStatd)) {
  	tvp = afs_globalVp;
  	error = 0;
! #ifdef AFS_DARWIN80_ENV
!         needref=1;
! #endif
!     } else if (mdata == (qaddr_t) - 1) {
  	error = ENOENT;
      } else {
! 	struct VenusFid *rootFid = (mdata == NULL)
! 	    ? &afs_rootFid : (struct VenusFid *)mdata;
  
! 	if (!(error = afs_InitReq(&treq, cr)) && !(error = afs_CheckInit())) {
  	    tvp = afs_GetVCache(rootFid, &treq, NULL, NULL);
+ #ifdef AFS_DARWIN80_ENV
+             if (tvp) {
+ 	        AFS_GUNLOCK();
+                 error = afs_darwin_finalizevnode(tvp, NULL, NULL, 1);
+ 	        AFS_GLOCK();
+                 if (error)
+                    tvp = NULL;
+                 else 
+                    /* re-acquire the usecount that finalizevnode disposed of */
+                    vnode_ref(AFSTOV(tvp));
+             }
+ #endif
  	    /* we really want this to stay around */
  	    if (tvp) {
! 		if (mdata == NULL) {
! 		    if (afs_globalVp) {
! 			afs_PutVCache(afs_globalVp);
! 			afs_globalVp = NULL;
! 		    }
  		    afs_globalVp = tvp;
+ #ifdef AFS_DARWIN80_ENV
+                     needref=1;
+ #endif
+                 }
  	    } else
  		error = ENOENT;
  	}
      }
      if (tvp) {
+ #ifndef AFS_DARWIN80_ENV /* DARWIN80 caller does not need a usecount reference */
  	osi_vnhold(tvp, 0);
  	AFS_GUNLOCK();
  	vn_lock(AFSTOV(tvp), LK_EXCLUSIVE | LK_RETRY, p);
  	AFS_GLOCK();
! #endif
! #ifdef AFS_DARWIN80_ENV
!         if (needref) /* this iocount is for the caller. the initial iocount
!                         is for the eventual afs_PutVCache. for mdata != null,
!                         there will not be a PutVCache, so the caller gets the
!                         initial (from GetVCache or finalizevnode) iocount*/
!            vnode_get(AFSTOV(tvp));
! #endif
! 	if (mdata == NULL) {
  	    afs_globalVFS = mp;
  	}
  	*vpp = AFSTOV(tvp);
+ #ifndef AFS_DARWIN80_ENV 
  	AFSTOV(tvp)->v_flag |= VROOT;
  	AFSTOV(tvp)->v_vfsp = mp;
+ #endif
      }
  
      afs_Trace2(afs_iclSetp, CM_TRACE_VFSROOT, ICL_TYPE_POINTER, *vpp,
***************
*** 236,241 ****
--- 333,339 ----
      return error;
  }
  
+ #ifndef AFS_DARWIN80_ENV /* vget vfsop never had this prototype AFAIK */
  int
  afs_vget(mp, lfl, vp)
       struct mount *mp;
***************
*** 254,270 ****
      return error;
  }
  
  int
! afs_statfs(struct mount *mp, struct statfs *abp, struct proc *p)
  {
      AFS_GLOCK();
      AFS_STATCNT(afs_statfs);
  
  #if 0
      abp->f_type = MOUNT_AFS;
  #endif
      abp->f_bsize = mp->vfs_bsize;
      abp->f_iosize = mp->vfs_bsize;
  
      /* Fake a high number below to satisfy programs that use the statfs call
       * to make sure that there's enough space in the device partition before
--- 352,380 ----
      return error;
  }
  
+ int afs_vfs_vget(struct mount *mp, void *ino, struct vnode **vpp)
+ {
+    return ENOENT; /* cannot implement */
+ }
+ 
+ #endif
+ 
  int
! afs_statfs(struct mount *mp, STATFS_TYPE *abp, CTX_TYPE ctx)
  {
+     STATFS_TYPE *sysstat = vfs_statfs(mp);
      AFS_GLOCK();
      AFS_STATCNT(afs_statfs);
  
  #if 0
      abp->f_type = MOUNT_AFS;
  #endif
+ #ifdef AFS_DARWIN80_ENV
+     abp->f_bsize = abp->f_iosize = vfs_devblocksize(mp);
+ #else
      abp->f_bsize = mp->vfs_bsize;
      abp->f_iosize = mp->vfs_bsize;
+ #endif
  
      /* Fake a high number below to satisfy programs that use the statfs call
       * to make sure that there's enough space in the device partition before
***************
*** 273,306 ****
      abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files =
  	abp->f_ffree = 2000000;
  
!     abp->f_fsid.val[0] = mp->mnt_stat.f_fsid.val[0];
!     abp->f_fsid.val[1] = mp->mnt_stat.f_fsid.val[1];
!     if (abp != &mp->mnt_stat) {
! 	abp->f_type = mp->mnt_vfc->vfc_typenum;
  	memcpy((caddr_t) & abp->f_mntonname[0],
! 	       (caddr_t) mp->mnt_stat.f_mntonname, MNAMELEN);
  	memcpy((caddr_t) & abp->f_mntfromname[0],
! 	       (caddr_t) mp->mnt_stat.f_mntfromname, MNAMELEN);
      }
  
      AFS_GUNLOCK();
      return 0;
  }
  
  int
  afs_sync(mp, waitfor, cred, p)
       struct mount *mp;
       int waitfor;
       struct ucred *cred;
!      struct prioc *p;
  {
      return 0;
  }
  
  u_int32_t afs_darwin_realmodes = 0;
  
  int afs_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, 
  	       void *newp, size_t newlen, struct proc *p)
  {
      int error;
  
--- 383,493 ----
      abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files =
  	abp->f_ffree = 2000000;
  
!     if (abp != sysstat) {
!         abp->f_fsid.val[0] = sysstat->f_fsid.val[0];
!         abp->f_fsid.val[1] = sysstat->f_fsid.val[1];
! #ifndef AFS_DARWIN80_ENV
! 	abp->f_type = vfs_typenum(mp);
! #endif
  	memcpy((caddr_t) & abp->f_mntonname[0],
! 	       (caddr_t) sysstat->f_mntonname, MNAMELEN);
  	memcpy((caddr_t) & abp->f_mntfromname[0],
! 	       (caddr_t) sysstat->f_mntfromname, MNAMELEN);
      }
  
      AFS_GUNLOCK();
      return 0;
  }
  
+ #ifdef AFS_DARWIN80_ENV
+ int
+ afs_vfs_getattr(struct mount *mp, struct vfs_attr *outattrs,
+                 vfs_context_t context)
+ {
+     VFSATTR_RETURN(outattrs, f_bsize, vfs_devblocksize(mp));
+     VFSATTR_RETURN(outattrs, f_iosize, vfs_devblocksize(mp));
+     VFSATTR_RETURN(outattrs, f_blocks, 2000000);
+     VFSATTR_RETURN(outattrs, f_bfree, 2000000);
+     VFSATTR_RETURN(outattrs, f_bavail, 2000000);
+     VFSATTR_RETURN(outattrs, f_files, 2000000);
+     VFSATTR_RETURN(outattrs, f_ffree, 2000000);
+     if ( VFSATTR_IS_ACTIVE(outattrs, f_capabilities) )
+     {
+          vol_capabilities_attr_t *vcapattrptr;
+          vcapattrptr = &outattrs->f_capabilities;
+          vcapattrptr->capabilities[VOL_CAPABILITIES_FORMAT] =
+                    VOL_CAP_FMT_SYMBOLICLINKS |
+                    VOL_CAP_FMT_HARDLINKS |
+                    VOL_CAP_FMT_ZERO_RUNS |
+                    VOL_CAP_FMT_CASE_SENSITIVE |
+                    VOL_CAP_FMT_CASE_PRESERVING |
+                    VOL_CAP_FMT_FAST_STATFS;
+          vcapattrptr->capabilities[VOL_CAPABILITIES_INTERFACES] = 
+                    VOL_CAP_INT_ADVLOCK | 
+                    VOL_CAP_INT_FLOCK;
+          vcapattrptr->capabilities[VOL_CAPABILITIES_RESERVED1] = 0;
+          vcapattrptr->capabilities[VOL_CAPABILITIES_RESERVED2] = 0;
+ 
+          /* Capabilities we know about: */
+          vcapattrptr->valid[VOL_CAPABILITIES_FORMAT] =
+                  VOL_CAP_FMT_PERSISTENTOBJECTIDS |
+                  VOL_CAP_FMT_SYMBOLICLINKS |
+                  VOL_CAP_FMT_HARDLINKS |
+                  VOL_CAP_FMT_JOURNAL |
+                  VOL_CAP_FMT_JOURNAL_ACTIVE |
+                  VOL_CAP_FMT_NO_ROOT_TIMES |
+                  VOL_CAP_FMT_SPARSE_FILES |
+                  VOL_CAP_FMT_ZERO_RUNS |
+                  VOL_CAP_FMT_CASE_SENSITIVE |
+                  VOL_CAP_FMT_CASE_PRESERVING |
+                  VOL_CAP_FMT_FAST_STATFS;
+          vcapattrptr->valid[VOL_CAPABILITIES_INTERFACES] =
+                  VOL_CAP_INT_SEARCHFS |
+                  VOL_CAP_INT_ATTRLIST |
+                  VOL_CAP_INT_NFSEXPORT |
+                  VOL_CAP_INT_READDIRATTR |
+                  VOL_CAP_INT_EXCHANGEDATA |
+                  VOL_CAP_INT_COPYFILE |
+                  VOL_CAP_INT_ALLOCATE |
+                  VOL_CAP_INT_VOL_RENAME |
+                  VOL_CAP_INT_ADVLOCK |
+                  VOL_CAP_INT_FLOCK;
+          vcapattrptr->valid[VOL_CAPABILITIES_RESERVED1] = 0;
+          vcapattrptr->valid[VOL_CAPABILITIES_RESERVED2] = 0;
+              
+          VFSATTR_SET_SUPPORTED(outattrs, f_capabilities);
+     }
+     return 0;
+ }
+ #endif
+ 
+ #ifdef AFS_DARWIN80_ENV
+ int
+ afs_sync(mp, waitfor, ctx)
+      struct mount *mp;
+      int waitfor;
+      CTX_TYPE ctx;
+ #else
  int
  afs_sync(mp, waitfor, cred, p)
       struct mount *mp;
       int waitfor;
       struct ucred *cred;
!      struct proc *p;
! #endif
  {
      return 0;
  }
  
  u_int32_t afs_darwin_realmodes = 0;
  
+ #ifdef AFS_DARWIN80_ENV
+ int afs_sysctl(int *name, u_int namelen, user_addr_t oldp, size_t *oldlenp, 
+ 	       user_addr_t newp, size_t newlen, vfs_context_t context)
+ #else
  int afs_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, 
  	       void *newp, size_t newlen, struct proc *p)
+ #endif
  {
      int error;
  
***************
*** 315,322 ****
--- 502,514 ----
  	case AFS_SC_DARWIN_ALL:
  	    switch (name[2]) {
  	    case AFS_SC_DARWIN_ALL_REALMODES:
+ #ifdef AFS_DARWIN80_ENV
+                newlen;
+                /* XXX complicated */
+ #else
  	        return sysctl_int(oldp, oldlenp, newp, newlen,
  				  &afs_darwin_realmodes);
+ #endif
  	    }
  	    break;
  	    /* darwin version specific sysctl's goes here */
***************
*** 332,337 ****
--- 524,530 ----
  int
  afs_init(struct vfsconf *vfc)
  {
+ #ifndef AFS_DARWIN80_ENV /* vfs_fsadd does all this junk */
      int j;
      int (**opv_desc_vector) ();
      struct vnodeopv_entry_desc *opve_descp;
***************
*** 393,411 ****
      for (j = 0; j < vfs_opv_numops; j++)
  	if (opv_desc_vector[j] == NULL)
  	    opv_desc_vector[j] = opv_desc_vector[VOFFSET(vop_default)];
  }
  
  struct vfsops afs_vfsops = {
!     afs_mount,
!     afs_start,
!     afs_unmount,
!     afs_root,
!     afs_quotactl,
!     afs_statfs,
!     afs_sync,
!     afs_vget,
!     afs_fhtovp,
!     afs_vptofh,
!     afs_init,
!     afs_sysctl
  };
--- 586,619 ----
      for (j = 0; j < vfs_opv_numops; j++)
  	if (opv_desc_vector[j] == NULL)
  	    opv_desc_vector[j] = opv_desc_vector[VOFFSET(vop_default)];
+ #endif
+     return 0;
  }
  
  struct vfsops afs_vfsops = {
!    afs_mount,
!    afs_start,
!    afs_unmount,
!    afs_root,
! #ifdef AFS_DARWIN80_ENV
!    0,
!    afs_vfs_getattr,
! #else
!    afs_quotactl,
!    afs_statfs,
! #endif
!    afs_sync,
! #ifdef AFS_DARWIN80_ENV
!    0,0,0,
! #else
!    afs_vfs_vget,
!    afs_fhtovp,
!    afs_vptofh,
! #endif
!    afs_init,
!    afs_sysctl, 
! #ifdef AFS_DARWIN80_ENV
!    0 /*setattr */,
!    {0}
! #endif
  };
Index: openafs/src/afs/DARWIN/osi_vm.c
diff -c openafs/src/afs/DARWIN/osi_vm.c:1.14.2.3 openafs/src/afs/DARWIN/osi_vm.c:1.14.2.4
*** openafs/src/afs/DARWIN/osi_vm.c:1.14.2.3	Mon Apr  4 00:01:19 2005
--- openafs/src/afs/DARWIN/osi_vm.c	Wed Oct  5 01:58:29 2005
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/DARWIN/osi_vm.c,v 1.14.2.3 2005/04/04 04:01:19 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/DARWIN/osi_vm.c,v 1.14.2.4 2005/10/05 05:58:29 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 66,74 ****
--- 66,78 ----
      struct vnode *vp = AFSTOV(avc);
      ReleaseWriteLock(&avc->lock);
      AFS_GUNLOCK();
+ #ifdef AFS_DARWIN80_ENV
+     ubc_sync_range(vp, 0, ubc_getsize(vp), UBC_SYNC|UBC_PUSHDIRTY);
+ #else
      if (UBCINFOEXISTS(vp)) {
  	ubc_pushdirty(vp);
      }
+ #endif
      AFS_GLOCK();
      ObtainWriteLock(&avc->lock, 94);
  }
***************
*** 92,103 ****
--- 96,111 ----
  
      ReleaseWriteLock(&avc->lock);
      AFS_GUNLOCK();
+ #ifdef AFS_DARWIN80_ENV
+     ubc_sync_range(vp, 0, ubc_getsize(vp), UBC_INVALIDATE);
+ #else
      if (UBCINFOEXISTS(vp)) {
  	size = ubc_getsize(vp);
  	kret = ubc_invalidate(vp, 0, size);
  	if (kret != 1)		/* should be KERN_SUCCESS */
  	    printf("TryToSmush: invalidate failed (error = %d)\n", kret);
      }
+ #endif
      AFS_GLOCK();
      ObtainWriteLock(&avc->lock, 59);
  }
***************
*** 116,121 ****
--- 124,136 ----
      void *object;
      kern_return_t kret;
      off_t size;
+ #ifdef AFS_DARWIN80_ENV
+     size = ubc_getsize(vp);
+     ubc_sync_range(vp, 0, size, UBC_INVALIDATE);
+ 	/* XXX what about when not CStatd */
+     if (avc->states & CStatd && size != avc->m.Length)
+        ubc_setsize(vp, avc->m.Length);
+ #else
      if (UBCINFOEXISTS(vp)) {
  	size = ubc_getsize(vp);
  	kret = ubc_invalidate(vp, 0, size);
***************
*** 126,131 ****
--- 141,147 ----
  	  if (UBCISVALID(vp))
  	    ubc_setsize(vp, avc->m.Length);
      }
+ #endif
  }
  
  /* Purge pages beyond end-of-file, when truncating a file.
***************
*** 138,146 ****
--- 154,166 ----
  osi_VM_Truncate(struct vcache *avc, int alen, struct AFS_UCRED *acred)
  {
      struct vnode *vp = AFSTOV(avc);
+ #ifdef AFS_DARWIN80_ENV
+     ubc_setsize(vp, alen);
+ #else
      if (UBCINFOEXISTS(vp) && UBCISVALID(vp)) {
  	ubc_setsize(vp, alen);
      }
+ #endif
  }
  
  void
***************
*** 167,172 ****
--- 187,193 ----
      int error;
      struct vnode *vp = AFSTOV(avc);
  
+ #ifndef AFS_DARWIN80_ENV
      if (UBCISVALID(vp) && ((avc->states & CStatd) || force)) {
  	if (!UBCINFOEXISTS(vp)) {
  	    osi_vnhold(avc, 0);
***************
*** 186,190 ****
--- 207,212 ----
  	    ubc_setsize(vp, avc->m.Length);
  	}
      }
+ #endif
      return 0;
  }
Index: openafs/src/afs/DARWIN/osi_vnodeops.c
diff -c openafs/src/afs/DARWIN/osi_vnodeops.c:1.18.2.4 openafs/src/afs/DARWIN/osi_vnodeops.c:1.18.2.5
*** openafs/src/afs/DARWIN/osi_vnodeops.c:1.18.2.4	Thu Apr 28 21:51:07 2005
--- openafs/src/afs/DARWIN/osi_vnodeops.c	Wed Oct  5 01:58:29 2005
***************
*** 5,11 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/DARWIN/osi_vnodeops.c,v 1.18.2.4 2005/04/29 01:51:07 shadow Exp $");
  
  #include <afs/sysincludes.h>	/* Standard vendor system headers */
  #include <afsincludes.h>	/* Afs-based standard headers */
--- 5,11 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/DARWIN/osi_vnodeops.c,v 1.18.2.5 2005/10/05 05:58:29 shadow Exp $");
  
  #include <afs/sysincludes.h>	/* Standard vendor system headers */
  #include <afsincludes.h>	/* Afs-based standard headers */
***************
*** 16,66 ****
  #if defined(AFS_DARWIN70_ENV)
  #include <vfs/vfs_support.h>
  #endif /* defined(AFS_DARWIN70_ENV) */
  
! int afs_vop_lookup(struct vop_lookup_args *);
! int afs_vop_create(struct vop_create_args *);
! int afs_vop_mknod(struct vop_mknod_args *);
! int afs_vop_open(struct vop_open_args *);
! int afs_vop_close(struct vop_close_args *);
! int afs_vop_access(struct vop_access_args *);
! int afs_vop_getattr(struct vop_getattr_args *);
! int afs_vop_setattr(struct vop_setattr_args *);
! int afs_vop_read(struct vop_read_args *);
! int afs_vop_write(struct vop_write_args *);
! int afs_vop_pagein(struct vop_pagein_args *);
! int afs_vop_pageout(struct vop_pageout_args *);
! int afs_vop_ioctl(struct vop_ioctl_args *);
! int afs_vop_select(struct vop_select_args *);
! int afs_vop_mmap(struct vop_mmap_args *);
! int afs_vop_fsync(struct vop_fsync_args *);
! int afs_vop_seek(struct vop_seek_args *);
! int afs_vop_remove(struct vop_remove_args *);
! int afs_vop_link(struct vop_link_args *);
! int afs_vop_rename(struct vop_rename_args *);
! int afs_vop_mkdir(struct vop_mkdir_args *);
! int afs_vop_rmdir(struct vop_rmdir_args *);
! int afs_vop_symlink(struct vop_symlink_args *);
! int afs_vop_readdir(struct vop_readdir_args *);
! int afs_vop_readlink(struct vop_readlink_args *);
  #if !defined(AFS_DARWIN70_ENV)
  extern int ufs_abortop(struct vop_abortop_args *);
  #endif /* !defined(AFS_DARWIN70_ENV) */
! int afs_vop_inactive(struct vop_inactive_args *);
! int afs_vop_reclaim(struct vop_reclaim_args *);
! int afs_vop_lock(struct vop_lock_args *);
! int afs_vop_unlock(struct vop_unlock_args *);
! int afs_vop_bmap(struct vop_bmap_args *);
! int afs_vop_strategy(struct vop_strategy_args *);
! int afs_vop_print(struct vop_print_args *);
! int afs_vop_islocked(struct vop_islocked_args *);
! int afs_vop_pathconf(struct vop_pathconf_args *);
! int afs_vop_advlock(struct vop_advlock_args *);
! int afs_vop_truncate(struct vop_truncate_args *);
! int afs_vop_update(struct vop_update_args *);
! int afs_vop_blktooff __P((struct vop_blktooff_args *));
! int afs_vop_offtoblk __P((struct vop_offtoblk_args *));
! int afs_vop_cmap __P((struct vop_cmap_args *));
! 
  
  #define afs_vop_opnotsupp \
  	((int (*) __P((struct  vop_reallocblks_args *)))eopnotsupp)
--- 16,96 ----
  #if defined(AFS_DARWIN70_ENV)
  #include <vfs/vfs_support.h>
  #endif /* defined(AFS_DARWIN70_ENV) */
+ #ifdef AFS_DARWIN80_ENV
+ #include <sys/vnode_if.h>
+ #include <sys/kauth.h>
+ #endif
+ 
+ #ifdef AFS_DARWIN80_ENV
+ #define VOPPREF(x) &vnop_ ## x
+ #define VOPPROT(x) vnop_ ## x
+ #define OSI_UPL_ABORT_RANGE(pl, offset, size, flags) \
+   ubc_upl_abort_range((pl), (offset), (size), (flags))
+ #define OSI_UPL_COMMIT_RANGE(pl, offset, size, flags) \
+   ubc_upl_commit_range((pl), (offset), (size), (flags))
+ #define OSI_UPL_MAP(upl, offset) ubc_upl_map((upl), (offset))
+ #define OSI_UPL_UNMAP(upl) ubc_upl_unmap((upl))
+ #define VOP_ABORTOP(x, y)
+ #else
+ #define VOPPREF(x) &vop_ ## x
+ #define VOPPROT(x) vop_ ## x
+ #define OSI_UPL_ABORT_RANGE(pl, offset, size, flags) \
+   kernel_upl_abort_range((pl), (offset), (size), (flags))
+ #define OSI_UPL_COMMIT_RANGE(pl, offset, size, flags) \
+   kernel_upl_commit_range((pl), (offset), (size), (flags), \
+                           UPL_GET_INTERNAL_PAGE_LIST((pl)),\
+                                     MAX_UPL_TRANSFER)
+ #define OSI_UPL_MAP(upl, offset) kernel_upl_map(kernel_map, (upl), (offset))
+ #define OSI_UPL_UNMAP(upl) kernel_upl_unmap(kernel_map, (upl))
+ #endif
  
! extern char afs_zeros[AFS_ZEROS];
! 
! int afs_vop_lookup(struct VOPPROT(lookup_args) *);
! int afs_vop_create(struct VOPPROT(create_args) *);
! int afs_vop_mknod(struct VOPPROT(mknod_args) *);
! int afs_vop_open(struct VOPPROT(open_args) *);
! int afs_vop_close(struct VOPPROT(close_args) *);
! int afs_vop_access(struct VOPPROT(access_args) *);
! int afs_vop_getattr(struct VOPPROT(getattr_args) *);
! int afs_vop_setattr(struct VOPPROT(setattr_args) *);
! int afs_vop_read(struct VOPPROT(read_args) *);
! int afs_vop_write(struct VOPPROT(write_args) *);
! int afs_vop_pagein(struct VOPPROT(pagein_args) *);
! int afs_vop_pageout(struct VOPPROT(pageout_args) *);
! int afs_vop_ioctl(struct VOPPROT(ioctl_args) *);
! int afs_vop_select(struct VOPPROT(select_args) *);
! int afs_vop_mmap(struct VOPPROT(mmap_args) *);
! int afs_vop_fsync(struct VOPPROT(fsync_args) *);
! int afs_vop_remove(struct VOPPROT(remove_args) *);
! int afs_vop_link(struct VOPPROT(link_args) *);
! int afs_vop_rename(struct VOPPROT(rename_args) *);
! int afs_vop_mkdir(struct VOPPROT(mkdir_args) *);
! int afs_vop_rmdir(struct VOPPROT(rmdir_args) *);
! int afs_vop_symlink(struct VOPPROT(symlink_args) *);
! int afs_vop_readdir(struct VOPPROT(readdir_args) *);
! int afs_vop_readlink(struct VOPPROT(readlink_args) *);
  #if !defined(AFS_DARWIN70_ENV)
  extern int ufs_abortop(struct vop_abortop_args *);
  #endif /* !defined(AFS_DARWIN70_ENV) */
! int afs_vop_inactive(struct VOPPROT(inactive_args) *);
! int afs_vop_reclaim(struct VOPPROT(reclaim_args) *);
! int afs_vop_strategy(struct VOPPROT(strategy_args) *);
! int afs_vop_pathconf(struct VOPPROT(pathconf_args) *);
! int afs_vop_advlock(struct VOPPROT(advlock_args) *);
! int afs_vop_blktooff __P((struct VOPPROT(blktooff_args) *));
! int afs_vop_offtoblk __P((struct VOPPROT(offtoblk_args) *));
! #ifndef AFS_DARWIN80_ENV
! int afs_vop_truncate(struct VOPPROT(truncate_args) *);
! int afs_vop_update(struct VOPPROT(update_args) *);
! int afs_vop_lock(struct VOPPROT(lock_args) *);
! int afs_vop_unlock(struct VOPPROT(unlock_args) *);
! int afs_vop_bmap(struct VOPPROT(bmap_args) *);
! int afs_vop_seek(struct VOPPROT(seek_args) *);
! int afs_vop_cmap __P((struct VOPPROT(cmap_args) *));
! int afs_vop_print(struct VOPPROT(print_args) *);
! int afs_vop_islocked(struct VOPPROT(islocked_args) *);
! #endif
  
  #define afs_vop_opnotsupp \
  	((int (*) __P((struct  vop_reallocblks_args *)))eopnotsupp)
***************
*** 71,135 ****
  
  /* Global vfs data structures for AFS. */
  int (**afs_vnodeop_p) ();
  struct vnodeopv_entry_desc afs_vnodeop_entries[] = {
!     {&vop_default_desc, vn_default_error},
!     {&vop_lookup_desc, afs_vop_lookup},	/* lookup */
!     {&vop_create_desc, afs_vop_create},	/* create */
!     {&vop_mknod_desc, afs_vop_mknod},	/* mknod */
!     {&vop_open_desc, afs_vop_open},	/* open */
!     {&vop_close_desc, afs_vop_close},	/* close */
!     {&vop_access_desc, afs_vop_access},	/* access */
!     {&vop_getattr_desc, afs_vop_getattr},	/* getattr */
!     {&vop_setattr_desc, afs_vop_setattr},	/* setattr */
!     {&vop_read_desc, afs_vop_read},	/* read */
!     {&vop_write_desc, afs_vop_write},	/* write */
!     {&vop_pagein_desc, afs_vop_pagein},	/* read */
!     {&vop_pageout_desc, afs_vop_pageout},	/* write */
!     {&vop_ioctl_desc, afs_vop_ioctl},	/* XXX ioctl */
!     {&vop_select_desc, afs_vop_select},	/* select */
!     {&vop_mmap_desc, afs_vop_mmap},	/* mmap */
!     {&vop_fsync_desc, afs_vop_fsync},	/* fsync */
!     {&vop_seek_desc, afs_vop_seek},	/* seek */
!     {&vop_remove_desc, afs_vop_remove},	/* remove */
!     {&vop_link_desc, afs_vop_link},	/* link */
!     {&vop_rename_desc, afs_vop_rename},	/* rename */
!     {&vop_mkdir_desc, afs_vop_mkdir},	/* mkdir */
!     {&vop_rmdir_desc, afs_vop_rmdir},	/* rmdir */
!     {&vop_symlink_desc, afs_vop_symlink},	/* symlink */
!     {&vop_readdir_desc, afs_vop_readdir},	/* readdir */
!     {&vop_readlink_desc, afs_vop_readlink},	/* readlink */
  #if defined(AFS_DARWIN70_ENV)
!     { &vop_abortop_desc, nop_abortop },             /* abortop */
  #else /* ! defined(AFS_DARWIN70_ENV) */
      /* Yes, we use the ufs_abortop call.  It just releases the namei
       * buffer stuff */
!     {&vop_abortop_desc, ufs_abortop},	/* abortop */
  #endif /* defined(AFS_DARWIN70_ENV) */
!     {&vop_inactive_desc, afs_vop_inactive},	/* inactive */
!     {&vop_reclaim_desc, afs_vop_reclaim},	/* reclaim */
!     {&vop_lock_desc, afs_vop_lock},	/* lock */
!     {&vop_unlock_desc, afs_vop_unlock},	/* unlock */
!     {&vop_bmap_desc, afs_vop_bmap},	/* bmap */
!     {&vop_strategy_desc, afs_vop_strategy},	/* strategy */
!     {&vop_print_desc, afs_vop_print},	/* print */
!     {&vop_islocked_desc, afs_vop_islocked},	/* islocked */
!     {&vop_pathconf_desc, afs_vop_pathconf},	/* pathconf */
!     {&vop_advlock_desc, afs_vop_advlock},	/* advlock */
!     {&vop_blkatoff_desc, afs_vop_blkatoff},	/* blkatoff */
!     {&vop_valloc_desc, afs_vop_valloc},	/* valloc */
!     {&vop_reallocblks_desc, afs_vop_reallocblks},	/* reallocblks */
!     {&vop_vfree_desc, afs_vop_vfree},	/* vfree */
!     {&vop_truncate_desc, afs_vop_truncate},	/* truncate */
!     {&vop_update_desc, afs_vop_update},	/* update */
!     {&vop_blktooff_desc, afs_vop_blktooff},	/* blktooff */
!     {&vop_offtoblk_desc, afs_vop_offtoblk},	/* offtoblk */
!     {&vop_cmap_desc, afs_vop_cmap},	/* cmap */
!     {&vop_bwrite_desc, vn_bwrite},
!     {(struct vnodeop_desc *)NULL, (int (*)())NULL}
  };
  struct vnodeopv_desc afs_vnodeop_opv_desc =
      { &afs_vnodeop_p, afs_vnodeop_entries };
  
  #define GETNAME()       \
      struct componentname *cnp = ap->a_cnp; \
      char *name; \
--- 101,226 ----
  
  /* Global vfs data structures for AFS. */
  int (**afs_vnodeop_p) ();
+ 
+ #define VOPFUNC int (*)(void *)
+ 
  struct vnodeopv_entry_desc afs_vnodeop_entries[] = {
!     {VOPPREF(default_desc), (VOPFUNC)vn_default_error},
!     {VOPPREF(lookup_desc), (VOPFUNC)afs_vop_lookup},	/* lookup */
!     {VOPPREF(create_desc), (VOPFUNC)afs_vop_create},	/* create */
!     {VOPPREF(mknod_desc), (VOPFUNC)afs_vop_mknod},	/* mknod */
!     {VOPPREF(open_desc), (VOPFUNC)afs_vop_open},	/* open */
!     {VOPPREF(close_desc), (VOPFUNC)afs_vop_close},	/* close */
!     {VOPPREF(access_desc), (VOPFUNC)afs_vop_access},	/* access */
!     {VOPPREF(getattr_desc), (VOPFUNC)afs_vop_getattr},	/* getattr */
!     {VOPPREF(setattr_desc), (VOPFUNC)afs_vop_setattr},	/* setattr */
!     {VOPPREF(read_desc), (VOPFUNC)afs_vop_read},	/* read */
!     {VOPPREF(write_desc), (VOPFUNC)afs_vop_write},	/* write */
!     {VOPPREF(pagein_desc), (VOPFUNC)afs_vop_pagein},	/* read */
!     {VOPPREF(pageout_desc), (VOPFUNC)afs_vop_pageout},	/* write */
!     {VOPPREF(ioctl_desc), (VOPFUNC)afs_vop_ioctl},	/* XXX ioctl */
!     {VOPPREF(select_desc), (VOPFUNC)afs_vop_select},	/* select */
!     {VOPPREF(mmap_desc), (VOPFUNC)afs_vop_mmap},	/* mmap */
!     {VOPPREF(fsync_desc), (VOPFUNC)afs_vop_fsync},	/* fsync */
! #ifndef AFS_DARWIN80_ENV
!     {VOPPREF(seek_desc), (VOPFUNC)afs_vop_seek},	/* seek */
! #endif
!     {VOPPREF(remove_desc), (VOPFUNC)afs_vop_remove},	/* remove */
!     {VOPPREF(link_desc), (VOPFUNC)afs_vop_link},	/* link */
!     {VOPPREF(rename_desc), (VOPFUNC)afs_vop_rename},	/* rename */
!     {VOPPREF(mkdir_desc), (VOPFUNC)afs_vop_mkdir},	/* mkdir */
!     {VOPPREF(rmdir_desc), (VOPFUNC)afs_vop_rmdir},	/* rmdir */
!     {VOPPREF(symlink_desc), (VOPFUNC)afs_vop_symlink},	/* symlink */
!     {VOPPREF(readdir_desc), (VOPFUNC)afs_vop_readdir},	/* readdir */
!     {VOPPREF(readlink_desc), (VOPFUNC)afs_vop_readlink},	/* readlink */
! #ifndef AFS_DARWIN80_ENV
  #if defined(AFS_DARWIN70_ENV)
!     {VOPPREF(abortop_desc), (VOPFUNC)nop_abortop },             /* abortop */
  #else /* ! defined(AFS_DARWIN70_ENV) */
      /* Yes, we use the ufs_abortop call.  It just releases the namei
       * buffer stuff */
!     {VOPPREF(abortop_desc), (VOPFUNC)ufs_abortop},	/* abortop */
  #endif /* defined(AFS_DARWIN70_ENV) */
! #endif
!     {VOPPREF(inactive_desc), (VOPFUNC)afs_vop_inactive},	/* inactive */
!     {VOPPREF(reclaim_desc), (VOPFUNC)afs_vop_reclaim},	/* reclaim */
! #ifndef AFS_DARWIN80_ENV
!     {VOPPREF(lock_desc), (VOPFUNC)afs_vop_lock},	/* lock */
!     {VOPPREF(unlock_desc), (VOPFUNC)afs_vop_unlock},	/* unlock */
!     {VOPPREF(bmap_desc), (VOPFUNC)afs_vop_bmap},	/* bmap */
! #endif
! #ifdef AFS_DARWIN80_ENV
!     {VOPPREF(strategy_desc), (VOPFUNC)err_strategy},	/* strategy */
! #else
!     {VOPPREF(strategy_desc), (VOPFUNC)afs_vop_strategy},	/* strategy */
! #endif
! #ifndef AFS_DARWIN80_ENV
!     {VOPPREF(print_desc), (VOPFUNC)afs_vop_print},	/* print */
!     {VOPPREF(islocked_desc), (VOPFUNC)afs_vop_islocked},	/* islocked */
! #endif
!     {VOPPREF(pathconf_desc), (VOPFUNC)afs_vop_pathconf},	/* pathconf */
!     {VOPPREF(advlock_desc), (VOPFUNC)afs_vop_advlock},	/* advlock */
! #ifndef AFS_DARWIN80_ENV
!     {VOPPREF(blkatoff_desc), (VOPFUNC)afs_vop_blkatoff},	/* blkatoff */
!     {VOPPREF(valloc_desc), (VOPFUNC)afs_vop_valloc},	/* valloc */
!     {VOPPREF(reallocblks_desc), (VOPFUNC)afs_vop_reallocblks},	/* reallocblks */
!     {VOPPREF(vfree_desc), (VOPFUNC)afs_vop_vfree},	/* vfree */
!     {VOPPREF(update_desc), (VOPFUNC)afs_vop_update},	/* update */
!     {VOPPREF(cmap_desc), (VOPFUNC)afs_vop_cmap},	/* cmap */
!     {VOPPREF(truncate_desc), (VOPFUNC)afs_vop_truncate},	/* truncate */
! #endif
!     {VOPPREF(blktooff_desc), (VOPFUNC)afs_vop_blktooff},	/* blktooff */
!     {VOPPREF(offtoblk_desc), (VOPFUNC)afs_vop_offtoblk},	/* offtoblk */
!     {VOPPREF(bwrite_desc), (VOPFUNC)vn_bwrite},
!     {(struct vnodeop_desc *)NULL, (void (*)())NULL}
  };
  struct vnodeopv_desc afs_vnodeop_opv_desc =
      { &afs_vnodeop_p, afs_vnodeop_entries };
  
+ #ifdef AFS_DARWIN80_ENV
+ /* vfs structures for incompletely initialized vnodes */
+ int (**afs_dead_vnodeop_p) ();
+ 
+ struct vnodeopv_entry_desc afs_dead_vnodeop_entries[] = {
+     {VOPPREF(default_desc), (VOPFUNC)vn_default_error},
+     {VOPPREF(lookup_desc), (VOPFUNC)vn_default_error},	/* lookup */
+     {VOPPREF(create_desc), (VOPFUNC)err_create},	/* create */
+     {VOPPREF(mknod_desc), (VOPFUNC)err_mknod},	/* mknod */
+     {VOPPREF(open_desc), (VOPFUNC)err_open},	/* open */
+     {VOPPREF(close_desc), (VOPFUNC)err_close},	/* close */
+     {VOPPREF(access_desc), (VOPFUNC)err_access},	/* access */
+     {VOPPREF(getattr_desc), (VOPFUNC)err_getattr},	/* getattr */
+     {VOPPREF(setattr_desc), (VOPFUNC)err_setattr},	/* setattr */
+     {VOPPREF(read_desc), (VOPFUNC)err_read},	/* read */
+     {VOPPREF(write_desc), (VOPFUNC)err_write},	/* write */
+     {VOPPREF(pagein_desc), (VOPFUNC)err_pagein},	/* read */
+     {VOPPREF(pageout_desc), (VOPFUNC)err_pageout},	/* write */
+     {VOPPREF(ioctl_desc), (VOPFUNC)err_ioctl},	/* XXX ioctl */
+     {VOPPREF(select_desc), (VOPFUNC)nop_select},	/* select */
+     {VOPPREF(mmap_desc), (VOPFUNC)err_mmap},	/* mmap */
+     {VOPPREF(fsync_desc), (VOPFUNC)err_fsync},	/* fsync */
+     {VOPPREF(remove_desc), (VOPFUNC)err_remove},	/* remove */
+     {VOPPREF(link_desc), (VOPFUNC)err_link},	/* link */
+     {VOPPREF(rename_desc), (VOPFUNC)err_rename},	/* rename */
+     {VOPPREF(mkdir_desc), (VOPFUNC)err_mkdir},	/* mkdir */
+     {VOPPREF(rmdir_desc), (VOPFUNC)err_rmdir},	/* rmdir */
+     {VOPPREF(symlink_desc), (VOPFUNC)err_symlink},	/* symlink */
+     {VOPPREF(readdir_desc), (VOPFUNC)err_readdir},	/* readdir */
+     {VOPPREF(readlink_desc), (VOPFUNC)err_readlink},	/* readlink */
+     {VOPPREF(inactive_desc), (VOPFUNC)afs_vop_inactive},	/* inactive */
+     {VOPPREF(reclaim_desc), (VOPFUNC)afs_vop_reclaim},	/* reclaim */
+     {VOPPREF(strategy_desc), (VOPFUNC)err_strategy},	/* strategy */
+     {VOPPREF(pathconf_desc), (VOPFUNC)err_pathconf},	/* pathconf */
+     {VOPPREF(advlock_desc), (VOPFUNC)err_advlock},	/* advlock */
+     {VOPPREF(blktooff_desc), (VOPFUNC)err_blktooff},	/* blktooff */
+     {VOPPREF(offtoblk_desc), (VOPFUNC)err_offtoblk},	/* offtoblk */
+     {VOPPREF(bwrite_desc), (VOPFUNC)err_bwrite},
+     {(struct vnodeop_desc *)NULL, (void (*)())NULL}
+ };
+ struct vnodeopv_desc afs_dead_vnodeop_opv_desc =
+     { &afs_dead_vnodeop_p, afs_dead_vnodeop_entries };
+ #endif
+ 
  #define GETNAME()       \
      struct componentname *cnp = ap->a_cnp; \
      char *name; \
***************
*** 145,174 ****
      int haveGlock=ISAFS_GLOCK(); 
      struct vcache *tvc = VTOAFS(vp);
  
      tvc->states |= CUBCinit;
      if (haveGlock) AFS_GUNLOCK(); 
  
      /* vget needed for 0 ref'd vnode in GetVCache to not panic in vref.
         vref needed for multiref'd vnode in vnop_remove not to deadlock
         ourselves during vop_inactive, except we also need to not reinst
         the ubc... so we just call VREF there now anyway. */
  
!     if (VREFCOUNT(tvc) > 0)
  	VREF(((struct vnode *)(vp))); 
!     else
  	afs_vget(afs_globalVFS, 0, (vp));
  
      if (UBCINFOMISSING(vp) || UBCINFORECLAIMED(vp)) {
  	ubc_info_init(vp); 
      }
  
      if (haveGlock) AFS_GLOCK(); 
      tvc->states &= ~CUBCinit;
  }
- 
  int
  afs_vop_lookup(ap)
!      struct vop_lookup_args	/* {
  				 * struct vnodeop_desc * a_desc;
  				 * struct vnode *a_dvp;
  				 * struct vnode **a_vpp;
--- 236,281 ----
      int haveGlock=ISAFS_GLOCK(); 
      struct vcache *tvc = VTOAFS(vp);
  
+ #ifndef AFS_DARWIN80_ENV
      tvc->states |= CUBCinit;
+ #endif
+ #ifdef AFS_DARWIN80_ENV
+     if (tvc->states & CDeadVnode)
+        osi_Assert(!vnode_isinuse(vp, 1));
+      osi_Assert((tvc->states & CVInit) == 0);
+ #endif
      if (haveGlock) AFS_GUNLOCK(); 
  
+ #ifdef AFS_DARWIN80_ENV
+ 	vnode_get(vp);
+ 	vnode_ref(vp);
+ 	vnode_put(vp);
+ #else
      /* vget needed for 0 ref'd vnode in GetVCache to not panic in vref.
         vref needed for multiref'd vnode in vnop_remove not to deadlock
         ourselves during vop_inactive, except we also need to not reinst
         the ubc... so we just call VREF there now anyway. */
  
!     if (VREFCOUNT_GT(tvc, 0))
  	VREF(((struct vnode *)(vp))); 
!      else 
  	afs_vget(afs_globalVFS, 0, (vp));
+ #endif
  
+ #ifndef AFS_DARWIN80_ENV
      if (UBCINFOMISSING(vp) || UBCINFORECLAIMED(vp)) {
  	ubc_info_init(vp); 
      }
+ #endif
  
      if (haveGlock) AFS_GLOCK(); 
+ #ifndef AFS_DARWIN80_ENV
      tvc->states &= ~CUBCinit;
+ #endif
  }
  int
  afs_vop_lookup(ap)
!      struct VOPPROT(lookup_args)/* {
  				 * struct vnodeop_desc * a_desc;
  				 * struct vnode *a_dvp;
  				 * struct vnode **a_vpp;
***************
*** 182,223 ****
      int lockparent;		/* 1 => lockparent flag is set */
      int wantparent;		/* 1 => wantparent or lockparent flag */
      struct proc *p;
      GETNAME();
!     p = cnp->cn_proc;
      lockparent = flags & LOCKPARENT;
      wantparent = flags & (LOCKPARENT | WANTPARENT);
  
!     if (ap->a_dvp->v_type != VDIR) {
  	*ap->a_vpp = 0;
  	DROPNAME();
  	return ENOTDIR;
      }
      dvp = ap->a_dvp;
      if (flags & ISDOTDOT)
  	VOP_UNLOCK(dvp, 0, p);
      AFS_GLOCK();
!     error = afs_lookup(VTOAFS(dvp), name, &vcp, cnp->cn_cred);
      AFS_GUNLOCK();
      if (error) {
  	if (flags & ISDOTDOT)
  	    VOP_LOCK(dvp, LK_EXCLUSIVE | LK_RETRY, p);
  	if ((cnp->cn_nameiop == CREATE || cnp->cn_nameiop == RENAME)
  	    && (flags & ISLASTCN) && error == ENOENT)
  	    error = EJUSTRETURN;
  	if (cnp->cn_nameiop != LOOKUP && (flags & ISLASTCN))
  	    cnp->cn_flags |= SAVENAME;
  	DROPNAME();
  	*ap->a_vpp = 0;
  	return (error);
      }
      vp = AFSTOV(vcp);		/* always get a node if no error */
      vp->v_vfsp = dvp->v_vfsp;
  
      if (UBCINFOMISSING(vp) ||
  	UBCINFORECLAIMED(vp)) {
  	    ubc_info_init(vp);
      }
  
      /* The parent directory comes in locked.  We unlock it on return
       * unless the caller wants it left locked.
       * we also always return the vnode locked. */
--- 289,354 ----
      int lockparent;		/* 1 => lockparent flag is set */
      int wantparent;		/* 1 => wantparent or lockparent flag */
      struct proc *p;
+ #ifdef AFS_DARWIN80_ENV
+     error = cache_lookup(ap->a_dvp, ap->a_vpp, ap->a_cnp);
+     if (error == -1) 
+        return 0;
+     if (error == ENOENT) 
+        return error;
+ #endif
+ 
      GETNAME();
!     p = vop_cn_proc;
! 
      lockparent = flags & LOCKPARENT;
      wantparent = flags & (LOCKPARENT | WANTPARENT);
  
!     if (!vnode_isdir(ap->a_dvp)) {
  	*ap->a_vpp = 0;
  	DROPNAME();
  	return ENOTDIR;
      }
      dvp = ap->a_dvp;
+ #ifndef AFS_DARWIN80_ENV
      if (flags & ISDOTDOT)
  	VOP_UNLOCK(dvp, 0, p);
+ #endif
      AFS_GLOCK();
!     error = afs_lookup(VTOAFS(dvp), name, &vcp, vop_cn_cred);
      AFS_GUNLOCK();
      if (error) {
+ #ifndef AFS_DARWIN80_ENV
  	if (flags & ISDOTDOT)
  	    VOP_LOCK(dvp, LK_EXCLUSIVE | LK_RETRY, p);
+ #endif
  	if ((cnp->cn_nameiop == CREATE || cnp->cn_nameiop == RENAME)
  	    && (flags & ISLASTCN) && error == ENOENT)
  	    error = EJUSTRETURN;
+ #ifndef AFS_DARWIN80_ENV
  	if (cnp->cn_nameiop != LOOKUP && (flags & ISLASTCN))
  	    cnp->cn_flags |= SAVENAME;
+ #endif
  	DROPNAME();
  	*ap->a_vpp = 0;
  	return (error);
      }
+ #ifdef AFS_DARWIN80_ENV
+     if ((error=afs_darwin_finalizevnode(vcp, ap->a_dvp, ap->a_cnp, 0))) {
+ 	*ap->a_vpp = 0;
+ 	return error;
+     }
+ #endif
      vp = AFSTOV(vcp);		/* always get a node if no error */
+ #ifndef AFS_DARWIN80_ENV /* XXX needed for multi-mount thing, but can't have it yet */
      vp->v_vfsp = dvp->v_vfsp;
  
      if (UBCINFOMISSING(vp) ||
  	UBCINFORECLAIMED(vp)) {
  	    ubc_info_init(vp);
      }
+ #endif
  
+ #ifndef AFS_DARWIN80_ENV
      /* The parent directory comes in locked.  We unlock it on return
       * unless the caller wants it left locked.
       * we also always return the vnode locked. */
***************
*** 240,250 ****
--- 371,384 ----
  	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
  	/* always return the child locked */
      }
+ #endif
      *ap->a_vpp = vp;
  
+ #ifndef AFS_DARWIN80_ENV
      if ((cnp->cn_nameiop == RENAME && wantparent && (flags & ISLASTCN)
  	 || (cnp->cn_nameiop != LOOKUP && (flags & ISLASTCN))))
  	cnp->cn_flags |= SAVENAME;
+ #endif
  
      DROPNAME();
      return error;
***************
*** 252,258 ****
  
  int
  afs_vop_create(ap)
!      struct vop_create_args	/* {
  				 * struct vnode *a_dvp;
  				 * struct vnode **a_vpp;
  				 * struct componentname *a_cnp;
--- 386,392 ----
  
  int
  afs_vop_create(ap)
!      struct VOPPROT(create_args)	/* {
  				 * struct vnode *a_dvp;
  				 * struct vnode **a_vpp;
  				 * struct componentname *a_cnp;
***************
*** 264,286 ****
      register struct vnode *dvp = ap->a_dvp;
      struct proc *p;
      GETNAME();
!     p = cnp->cn_proc;
  
      /* vnode layer handles excl/nonexcl */
      AFS_GLOCK();
      error =
  	afs_create(VTOAFS(dvp), name, ap->a_vap, NONEXCL, ap->a_vap->va_mode,
! 		   &vcp, cnp->cn_cred);
      AFS_GUNLOCK();
      if (error) {
  	VOP_ABORTOP(dvp, cnp);
  	vput(dvp);
  	DROPNAME();
  	return (error);
      }
  
      if (vcp) {
  	*ap->a_vpp = AFSTOV(vcp);
  	(*ap->a_vpp)->v_vfsp = dvp->v_vfsp;
  	vn_lock(*ap->a_vpp, LK_EXCLUSIVE | LK_RETRY, p);
  	if (UBCINFOMISSING(*ap->a_vpp) || UBCINFORECLAIMED(*ap->a_vpp)) {
--- 398,429 ----
      register struct vnode *dvp = ap->a_dvp;
      struct proc *p;
      GETNAME();
!     p = vop_cn_proc;
  
      /* vnode layer handles excl/nonexcl */
      AFS_GLOCK();
      error =
  	afs_create(VTOAFS(dvp), name, ap->a_vap, NONEXCL, ap->a_vap->va_mode,
! 		   &vcp, vop_cn_cred);
      AFS_GUNLOCK();
      if (error) {
+ #ifndef AFS_DARWIN80_ENV
  	VOP_ABORTOP(dvp, cnp);
  	vput(dvp);
+ #endif
  	DROPNAME();
  	return (error);
      }
  
      if (vcp) {
+ #ifdef AFS_DARWIN80_ENV
+         if ((error=afs_darwin_finalizevnode(vcp, ap->a_dvp, ap->a_cnp, 0))) {
+              *ap->a_vpp=0;
+              return error;
+         }
+ #endif
  	*ap->a_vpp = AFSTOV(vcp);
+ #ifndef AFS_DARWIN80_ENV /* XXX needed for multi-mount thing, but can't have it yet */
  	(*ap->a_vpp)->v_vfsp = dvp->v_vfsp;
  	vn_lock(*ap->a_vpp, LK_EXCLUSIVE | LK_RETRY, p);
  	if (UBCINFOMISSING(*ap->a_vpp) || UBCINFORECLAIMED(*ap->a_vpp)) {
***************
*** 288,320 ****
  	    ubc_info_init(*ap->a_vpp);
  	    vcp->states &= ~CUBCinit;
  	}
      } else
  	*ap->a_vpp = 0;
  
      if ((cnp->cn_flags & SAVESTART) == 0)
  	FREE_ZONE(cnp->cn_pnbuf, cnp->cn_pnlen, M_NAMEI);
      vput(dvp);
      DROPNAME();
      return error;
  }
  
  int
  afs_vop_mknod(ap)
!      struct vop_mknod_args	/* {
  				 * struct vnode *a_dvp;
  				 * struct vnode **a_vpp;
  				 * struct componentname *a_cnp;
  				 * struct vattr *a_vap;
  				 * } */ *ap;
  {
      FREE_ZONE(ap->a_cnp->cn_pnbuf, ap->a_cnp->cn_pnlen, M_NAMEI);
      vput(ap->a_dvp);
      return (ENODEV);
  }
  
  int
  afs_vop_open(ap)
!      struct vop_open_args	/* {
  				 * struct vnode *a_vp;
  				 * int  a_mode;
  				 * struct ucred *a_cred;
--- 431,468 ----
  	    ubc_info_init(*ap->a_vpp);
  	    vcp->states &= ~CUBCinit;
  	}
+ #endif
      } else
  	*ap->a_vpp = 0;
  
+ #ifndef AFS_DARWIN80_ENV
      if ((cnp->cn_flags & SAVESTART) == 0)
  	FREE_ZONE(cnp->cn_pnbuf, cnp->cn_pnlen, M_NAMEI);
      vput(dvp);
+ #endif
      DROPNAME();
      return error;
  }
  
  int
  afs_vop_mknod(ap)
!      struct VOPPROT(mknod_args)	/* {
  				 * struct vnode *a_dvp;
  				 * struct vnode **a_vpp;
  				 * struct componentname *a_cnp;
  				 * struct vattr *a_vap;
  				 * } */ *ap;
  {
+ #ifndef AFS_DARWIN80_ENV
      FREE_ZONE(ap->a_cnp->cn_pnbuf, ap->a_cnp->cn_pnlen, M_NAMEI);
      vput(ap->a_dvp);
+ #endif
      return (ENODEV);
  }
  
  int
  afs_vop_open(ap)
!      struct VOPPROT(open_args)	/* {
  				 * struct vnode *a_vp;
  				 * int  a_mode;
  				 * struct ucred *a_cred;
***************
*** 324,330 ****
      int error;
      struct vnode *vp = ap->a_vp;
      struct vcache *vc = VTOAFS(vp);
! #ifdef AFS_DARWIN14_ENV
      int didhold = 0;
      /*----------------------------------------------------------------
       * osi_VM_TryReclaim() removes the ubcinfo of a vnode, but that vnode
--- 472,478 ----
      int error;
      struct vnode *vp = ap->a_vp;
      struct vcache *vc = VTOAFS(vp);
! #if defined(AFS_DARWIN14_ENV) && !defined(AFS_DARWIN80_ENV)
      int didhold = 0;
      /*----------------------------------------------------------------
       * osi_VM_TryReclaim() removes the ubcinfo of a vnode, but that vnode
***************
*** 340,353 ****
  	didhold = ubc_hold(vp);
  #endif /* AFS_DARWIN14_ENV */
      AFS_GLOCK();
!     error = afs_open(&vc, ap->a_mode, ap->a_cred);
  #ifdef DIAGNOSTIC
      if (AFSTOV(vc) != vp)
  	panic("AFS open changed vnode!");
  #endif
!     osi_FlushPages(vc, ap->a_cred);
      AFS_GUNLOCK();
! #ifdef AFS_DARWIN14_ENV
      if (error && didhold)
  	ubc_rele(vp);
  #endif /* AFS_DARWIN14_ENV */
--- 488,501 ----
  	didhold = ubc_hold(vp);
  #endif /* AFS_DARWIN14_ENV */
      AFS_GLOCK();
!     error = afs_open(&vc, ap->a_mode, vop_cred);
  #ifdef DIAGNOSTIC
      if (AFSTOV(vc) != vp)
  	panic("AFS open changed vnode!");
  #endif
!     osi_FlushPages(vc, vop_cred);
      AFS_GUNLOCK();
! #if defined(AFS_DARWIN14_ENV) && !defined(AFS_DARWIN80_ENV)
      if (error && didhold)
  	ubc_rele(vp);
  #endif /* AFS_DARWIN14_ENV */
***************
*** 356,362 ****
  
  int
  afs_vop_close(ap)
!      struct vop_close_args	/* {
  				 * struct vnode *a_vp;
  				 * int  a_fflag;
  				 * struct ucred *a_cred;
--- 504,510 ----
  
  int
  afs_vop_close(ap)
!      struct VOPPROT(close_args)	/* {
  				 * struct vnode *a_vp;
  				 * int  a_fflag;
  				 * struct ucred *a_cred;
***************
*** 367,385 ****
      struct vnode *vp = ap->a_vp;
      struct vcache *avc = VTOAFS(vp);
      AFS_GLOCK();
!     if (ap->a_cred)
! 	code = afs_close(avc, ap->a_fflag, ap->a_cred, ap->a_p);
      else
! 	code = afs_close(avc, ap->a_fflag, &afs_osi_cred, ap->a_p);
!     osi_FlushPages(avc, ap->a_cred);	/* hold bozon lock, but not basic vnode lock */
      AFS_GUNLOCK();
  
      return code;
  }
  
  int
  afs_vop_access(ap)
!      struct vop_access_args	/* {
  				 * struct vnode *a_vp;
  				 * int  a_mode;
  				 * struct ucred *a_cred;
--- 515,625 ----
      struct vnode *vp = ap->a_vp;
      struct vcache *avc = VTOAFS(vp);
      AFS_GLOCK();
!     if (vop_cred)
! 	code = afs_close(avc, ap->a_fflag, vop_cred, vop_proc);
      else
! 	code = afs_close(avc, ap->a_fflag, &afs_osi_cred, vop_proc);
!     osi_FlushPages(avc, vop_cred);	/* hold bozon lock, but not basic vnode lock */
      AFS_GUNLOCK();
  
      return code;
  }
  
+ #ifdef AFS_DARWIN80_ENV
+ extern int afs_fakestat_enable;
+ 
  int
  afs_vop_access(ap)
!      struct VOPPROT(access_args)        /* {
!                                  * struct vnode *a_vp;
!                                  * int  a_action;
!                                  * vfs_context_t a_context;
!                                  * } */ *ap;
! {
!     int code;
!     struct vrequest treq;
!     struct afs_fakestat_state fakestate;
!     struct vcache * tvc = VTOAFS(ap->a_vp);
!     int bits=0;
!     AFS_GLOCK();
!     afs_InitFakeStat(&fakestate);
!     if ((code = afs_InitReq(&treq, vop_cred)))
!         goto out2;
! 
!     code = afs_TryEvalFakeStat(&tvc, &fakestate, &treq);
!     if (code) {
!         code = afs_CheckCode(code, &treq, 55);
!         goto out;
!     }
! 
!     code = afs_VerifyVCache(tvc, &treq);
!     if (code) {
!         code = afs_CheckCode(code, &treq, 56);
!         goto out;
!     }
!     if (afs_fakestat_enable && tvc->mvstat && !(tvc->states & CStatd)) {
!         code = 0;
!         goto out;
!     }
!     if (vnode_isdir(ap->a_vp)) {
!        if (ap->a_action & KAUTH_VNODE_LIST_DIRECTORY)
!           bits |= PRSFS_LOOKUP;
!        if (ap->a_action & KAUTH_VNODE_ADD_FILE)
!           bits |= PRSFS_INSERT;
!        if (ap->a_action & KAUTH_VNODE_SEARCH)
!           bits |= PRSFS_LOOKUP;
!        if (ap->a_action & KAUTH_VNODE_DELETE)
!           bits |= PRSFS_DELETE;
!        if (ap->a_action & KAUTH_VNODE_ADD_SUBDIRECTORY)
!           bits |= PRSFS_INSERT;
!        if (ap->a_action & KAUTH_VNODE_DELETE_CHILD)
!           bits |= PRSFS_DELETE;
!     } else {
!        if (ap->a_action & KAUTH_VNODE_READ_DATA)
!           bits |= PRSFS_READ;
!        if (ap->a_action & KAUTH_VNODE_WRITE_DATA)
!           bits |= PRSFS_WRITE;
!        if (ap->a_action & KAUTH_VNODE_EXECUTE)
!           bits |= PRSFS_READ; /* and mode bits.... */
!     }
!     if (ap->a_action & KAUTH_VNODE_READ_ATTRIBUTES)
!        bits |= PRSFS_READ;
!     if (ap->a_action & KAUTH_VNODE_WRITE_ATTRIBUTES)
!        bits |= PRSFS_WRITE;
! #if 0 /* no extended attributes */
!     if (ap->a_action & KAUTH_VNODE_READ_EXTATTRIBUTES)
!        bits |= PRSFS_READ;
!     if (ap->a_action & KAUTH_VNODE_WRITE_EXTATTRIBUTES)
!        bits |= PRSFS_WRITE;
! #endif
!     if (ap->a_action & KAUTH_VNODE_READ_SECURITY) /* mode bits/gid, not afs acl */
!        bits |= PRSFS_READ;
!     if (ap->a_action & KAUTH_VNODE_WRITE_SECURITY)
!        bits |= PRSFS_WRITE;
!     /* we can't check for KAUTH_VNODE_TAKE_OWNERSHIP, so we always permit it */
!     
!     code = afs_AccessOK(tvc, bits, &treq, CHECK_MODE_BITS);
! 
!     if (code == 1 && vnode_vtype(ap->a_vp) == VREG &&
!         ap->a_action & KAUTH_VNODE_EXECUTE &&
!         (tvc->m.Mode & 0100) != 0100) {
!         code = 0;
!      }
!     if (code) {
!         code= 0;               /* if access is ok */
!     } else {
!         code = afs_CheckCode(EACCES, &treq, 57);        /* failure code */
!     }
! out:
!      afs_PutFakeStat(&fakestate);
! out2:
!     AFS_GUNLOCK();
!     return code;
! }
! #else
! int
! afs_vop_access(ap)
!      struct VOPPROT(access_args)	/* {
  				 * struct vnode *a_vp;
  				 * int  a_mode;
  				 * struct ucred *a_cred;
***************
*** 388,401 ****
  {
      int code;
      AFS_GLOCK();
!     code = afs_access(VTOAFS(ap->a_vp), ap->a_mode, ap->a_cred);
      AFS_GUNLOCK();
      return code;
  }
  
  int
  afs_vop_getattr(ap)
!      struct vop_getattr_args	/* {
  				 * struct vnode *a_vp;
  				 * struct vattr *a_vap;
  				 * struct ucred *a_cred;
--- 628,642 ----
  {
      int code;
      AFS_GLOCK();
!     code = afs_access(VTOAFS(ap->a_vp), ap->a_mode, vop_cred);
      AFS_GUNLOCK();
      return code;
  }
+ #endif
  
  int
  afs_vop_getattr(ap)
!      struct VOPPROT(getattr_args)	/* {
  				 * struct vnode *a_vp;
  				 * struct vattr *a_vap;
  				 * struct ucred *a_cred;
***************
*** 405,418 ****
      int code;
  
      AFS_GLOCK();
!     code = afs_getattr(VTOAFS(ap->a_vp), ap->a_vap, ap->a_cred);
      AFS_GUNLOCK();
      return code;
  }
  
  int
  afs_vop_setattr(ap)
!      struct vop_setattr_args	/* {
  				 * struct vnode *a_vp;
  				 * struct vattr *a_vap;
  				 * struct ucred *a_cred;
--- 646,675 ----
      int code;
  
      AFS_GLOCK();
!     code = afs_getattr(VTOAFS(ap->a_vp), ap->a_vap, vop_cred);
      AFS_GUNLOCK();
+ #ifdef AFS_DARWIN80_ENV
+     VATTR_SET_SUPPORTED(ap->a_vap, va_type);
+     VATTR_SET_SUPPORTED(ap->a_vap, va_mode);
+     VATTR_SET_SUPPORTED(ap->a_vap, va_uid);
+     VATTR_SET_SUPPORTED(ap->a_vap, va_gid);
+     VATTR_SET_SUPPORTED(ap->a_vap, va_fileid);
+     VATTR_SET_SUPPORTED(ap->a_vap, va_nlink);
+     VATTR_SET_SUPPORTED(ap->a_vap, va_data_size);
+     VATTR_SET_SUPPORTED(ap->a_vap, va_access_time);
+     VATTR_SET_SUPPORTED(ap->a_vap, va_modify_time);
+     VATTR_SET_SUPPORTED(ap->a_vap, va_change_time);
+     VATTR_SET_SUPPORTED(ap->a_vap, va_gen);
+     VATTR_SET_SUPPORTED(ap->a_vap, va_flags);
+     VATTR_SET_SUPPORTED(ap->a_vap, va_iosize);
+     VATTR_SET_SUPPORTED(ap->a_vap, va_total_alloc);
+ #endif
      return code;
  }
  
  int
  afs_vop_setattr(ap)
!      struct VOPPROT(setattr_args)	/* {
  				 * struct vnode *a_vp;
  				 * struct vattr *a_vap;
  				 * struct ucred *a_cred;
***************
*** 421,434 ****
  {
      int code;
      AFS_GLOCK();
!     code = afs_setattr(VTOAFS(ap->a_vp), ap->a_vap, ap->a_cred);
      AFS_GUNLOCK();
      return code;
  }
  
  int
  afs_vop_read(ap)
!      struct vop_read_args	/* {
  				 * struct vnode *a_vp;
  				 * struct uio *a_uio;
  				 * int a_ioflag;
--- 678,691 ----
  {
      int code;
      AFS_GLOCK();
!     code = afs_setattr(VTOAFS(ap->a_vp), ap->a_vap, vop_cred);
      AFS_GUNLOCK();
      return code;
  }
  
  int
  afs_vop_read(ap)
!      struct VOPPROT(read_args)	/* {
  				 * struct vnode *a_vp;
  				 * struct uio *a_uio;
  				 * int a_ioflag;
***************
*** 438,453 ****
      int code;
      struct vnode *vp = ap->a_vp;
      struct vcache *avc = VTOAFS(vp);
      AFS_GLOCK();
!     osi_FlushPages(avc, ap->a_cred);	/* hold bozon lock, but not basic vnode lock */
!     code = afs_read(avc, ap->a_uio, ap->a_cred, 0, 0, 0);
      AFS_GUNLOCK();
      return code;
  }
  
  int
  afs_vop_pagein(ap)
!      struct vop_pagein_args	/* {
  				 * struct vnode *a_vp;
  				 * upl_t a_pl;
  				 * vm_offset_t a_pl_offset;
--- 695,717 ----
      int code;
      struct vnode *vp = ap->a_vp;
      struct vcache *avc = VTOAFS(vp);
+ #ifdef AFS_DARWIN80_ENV
+     ubc_sync_range(ap->a_vp, AFS_UIO_OFFSET(ap->a_uio), AFS_UIO_OFFSET(ap->a_uio) + AFS_UIO_RESID(ap->a_uio), UBC_PUSHDIRTY);
+ #else
+     if (UBCINFOEXISTS(ap->a_vp)) {
+ 	ubc_clean(ap->a_vp, 0);
+     }
+ #endif
      AFS_GLOCK();
!     osi_FlushPages(avc, vop_cred);	/* hold bozon lock, but not basic vnode lock */
!     code = afs_read(avc, ap->a_uio, vop_cred, 0, 0, 0);
      AFS_GUNLOCK();
      return code;
  }
  
  int
  afs_vop_pagein(ap)
!      struct VOPPROT(pagein_args)	/* {
  				 * struct vnode *a_vp;
  				 * upl_t a_pl;
  				 * vm_offset_t a_pl_offset;
***************
*** 465,478 ****
      int flags = ap->a_flags;
      struct ucred *cred;
      vm_offset_t ioaddr;
      struct uio auio;
      struct iovec aiov;
      struct uio *uio = &auio;
      int nocommit = flags & UPL_NOCOMMIT;
  
      int code;
      struct vcache *tvc = VTOAFS(vp);
! 
      if (UBCINVALID(vp)) {
  #if DIAGNOSTIC
  	panic("afs_vop_pagein: invalid vp");
--- 729,746 ----
      int flags = ap->a_flags;
      struct ucred *cred;
      vm_offset_t ioaddr;
+ #ifdef AFS_DARWIN80_ENV
+     struct uio *uio;
+ #else
      struct uio auio;
      struct iovec aiov;
      struct uio *uio = &auio;
+ #endif
      int nocommit = flags & UPL_NOCOMMIT;
  
      int code;
      struct vcache *tvc = VTOAFS(vp);
! #ifndef AFS_DARWIN80_ENV
      if (UBCINVALID(vp)) {
  #if DIAGNOSTIC
  	panic("afs_vop_pagein: invalid vp");
***************
*** 481,521 ****
      }
  
      UBCINFOCHECK("afs_vop_pagein", vp);
      if (pl == (upl_t) NULL) {
  	panic("afs_vop_pagein: no upl");
      }
  
      cred = ubc_getcred(vp);
      if (cred == NOCRED)
! 	cred = ap->a_cred;
  
      if (size == 0) {
  	if (!nocommit)
! 	    kernel_upl_abort_range(pl, pl_offset, size,
  				   UPL_ABORT_ERROR | UPL_ABORT_FREE_ON_EMPTY);
  	return (0);
      }
      if (f_offset < 0) {
  	if (!nocommit)
! 	    kernel_upl_abort_range(pl, pl_offset, size,
  				   UPL_ABORT_ERROR | UPL_ABORT_FREE_ON_EMPTY);
  	return (EINVAL);
      }
      if (f_offset & PAGE_MASK)
  	panic("afs_vop_pagein: offset not page aligned");
  
      auio.uio_iov = &aiov;
      auio.uio_iovcnt = 1;
      auio.uio_offset = f_offset;
      auio.uio_segflg = UIO_SYSSPACE;
      auio.uio_rw = UIO_READ;
      auio.uio_procp = NULL;
-     kernel_upl_map(kernel_map, pl, &ioaddr);
-     ioaddr += pl_offset;
      auio.uio_resid = aiov.iov_len = size;
      aiov.iov_base = (caddr_t) ioaddr;
      AFS_GLOCK();
!     osi_FlushPages(tvc, ap->a_cred);	/* hold bozon lock, but not basic vnode lock */
      code = afs_read(tvc, uio, cred, 0, 0, 0);
      if (code == 0) {
  	ObtainWriteLock(&tvc->lock, 2);
--- 749,795 ----
      }
  
      UBCINFOCHECK("afs_vop_pagein", vp);
+ #endif
      if (pl == (upl_t) NULL) {
  	panic("afs_vop_pagein: no upl");
      }
  
      cred = ubc_getcred(vp);
      if (cred == NOCRED)
! 	cred = vop_cred;
  
      if (size == 0) {
  	if (!nocommit)
! 	    OSI_UPL_ABORT_RANGE(pl, pl_offset, size,
  				   UPL_ABORT_ERROR | UPL_ABORT_FREE_ON_EMPTY);
  	return (0);
      }
      if (f_offset < 0) {
  	if (!nocommit)
! 	    OSI_UPL_ABORT_RANGE(pl, pl_offset, size,
  				   UPL_ABORT_ERROR | UPL_ABORT_FREE_ON_EMPTY);
  	return (EINVAL);
      }
      if (f_offset & PAGE_MASK)
  	panic("afs_vop_pagein: offset not page aligned");
  
+     OSI_UPL_MAP(pl, &ioaddr);
+     ioaddr += pl_offset;
+ #ifdef AFS_DARWIN80_ENV
+     uio = uio_create(1, f_offset, UIO_SYSSPACE32, UIO_READ);
+     uio_addiov(uio, CAST_USER_ADDR_T(ioaddr), size);
+ #else
      auio.uio_iov = &aiov;
      auio.uio_iovcnt = 1;
      auio.uio_offset = f_offset;
      auio.uio_segflg = UIO_SYSSPACE;
      auio.uio_rw = UIO_READ;
      auio.uio_procp = NULL;
      auio.uio_resid = aiov.iov_len = size;
      aiov.iov_base = (caddr_t) ioaddr;
+ #endif
      AFS_GLOCK();
!     osi_FlushPages(tvc, vop_cred);	/* hold bozon lock, but not basic vnode lock */
      code = afs_read(tvc, uio, cred, 0, 0, 0);
      if (code == 0) {
  	ObtainWriteLock(&tvc->lock, 2);
***************
*** 525,551 ****
      AFS_GUNLOCK();
  
      /* Zero out rest of last page if there wasn't enough data in the file */
!     if (code == 0 && auio.uio_resid > 0)
  	memset(aiov.iov_base, 0, auio.uio_resid);
  
!     kernel_upl_unmap(kernel_map, pl);
      if (!nocommit) {
  	if (code)
! 	    kernel_upl_abort_range(pl, pl_offset, size,
  				   UPL_ABORT_ERROR | UPL_ABORT_FREE_ON_EMPTY);
  	else
! 	    kernel_upl_commit_range(pl, pl_offset, size,
  				    UPL_COMMIT_CLEAR_DIRTY |
! 				    UPL_COMMIT_FREE_ON_EMPTY,
! 				    UPL_GET_INTERNAL_PAGE_LIST(pl),
! 				    MAX_UPL_TRANSFER);
      }
      return code;
  }
  
  int
  afs_vop_write(ap)
!      struct vop_write_args	/* {
  				 * struct vnode *a_vp;
  				 * struct uio *a_uio;
  				 * int a_ioflag;
--- 799,832 ----
      AFS_GUNLOCK();
  
      /* Zero out rest of last page if there wasn't enough data in the file */
!     if (code == 0 && AFS_UIO_RESID(uio) > 0) {
! #ifdef AFS_DARWIN80_ENV
! 	memset(((caddr_t)ioaddr) + (size - AFS_UIO_RESID(uio)), 0,
!                AFS_UIO_RESID(uio));
! #else
  	memset(aiov.iov_base, 0, auio.uio_resid);
+ #endif
+     }
  
!     OSI_UPL_UNMAP(pl);
      if (!nocommit) {
  	if (code)
! 	    OSI_UPL_ABORT_RANGE(pl, pl_offset, size,
  				   UPL_ABORT_ERROR | UPL_ABORT_FREE_ON_EMPTY);
  	else
! 	    OSI_UPL_COMMIT_RANGE(pl, pl_offset, size,
  				    UPL_COMMIT_CLEAR_DIRTY |
! 				    UPL_COMMIT_FREE_ON_EMPTY);
      }
+ #ifdef AFS_DARWIN80_ENV
+     uio_free(uio);
+ #endif
      return code;
  }
  
  int
  afs_vop_write(ap)
!      struct VOPPROT(write_args)	/* {
  				 * struct vnode *a_vp;
  				 * struct uio *a_uio;
  				 * int a_ioflag;
***************
*** 555,577 ****
      int code;
      struct vcache *avc = VTOAFS(ap->a_vp);
      void *object;
!     AFS_GLOCK();
!     osi_FlushPages(avc, ap->a_cred);	/* hold bozon lock, but not basic vnode lock */
      if (UBCINFOEXISTS(ap->a_vp)) {
  	ubc_clean(ap->a_vp, 1);
      }
      if (UBCINFOEXISTS(ap->a_vp))
! 	osi_VM_NukePages(ap->a_vp, ap->a_uio->uio_offset,
! 			 ap->a_uio->uio_resid);
      code =
! 	afs_write(VTOAFS(ap->a_vp), ap->a_uio, ap->a_ioflag, ap->a_cred, 0);
      AFS_GUNLOCK();
      return code;
  }
  
  int
  afs_vop_pageout(ap)
!      struct vop_pageout_args	/* {
  				 * struct vnode *a_vp;
  				 * upl_t   a_pl,
  				 * vm_offset_t   a_pl_offset,
--- 836,862 ----
      int code;
      struct vcache *avc = VTOAFS(ap->a_vp);
      void *object;
! #ifdef AFS_DARWIN80_ENV
!     ubc_sync_range(ap->a_vp, AFS_UIO_OFFSET(ap->a_uio), AFS_UIO_OFFSET(ap->a_uio) + AFS_UIO_RESID(ap->a_uio), UBC_INVALIDATE);
! #else
      if (UBCINFOEXISTS(ap->a_vp)) {
  	ubc_clean(ap->a_vp, 1);
      }
      if (UBCINFOEXISTS(ap->a_vp))
! 	osi_VM_NukePages(ap->a_vp, AFS_UIO_OFFSET(ap->a_uio),
! 			 AFS_UIO_RESID(ap->a_uio));
! #endif
!     AFS_GLOCK();
!     osi_FlushPages(avc, vop_cred);	/* hold bozon lock, but not basic vnode lock */
      code =
! 	afs_write(VTOAFS(ap->a_vp), ap->a_uio, ap->a_ioflag, vop_cred, 0);
      AFS_GUNLOCK();
      return code;
  }
  
  int
  afs_vop_pageout(ap)
!      struct VOPPROT(pageout_args)	/* {
  				 * struct vnode *a_vp;
  				 * upl_t   a_pl,
  				 * vm_offset_t   a_pl_offset,
***************
*** 589,603 ****
      int flags = ap->a_flags;
      struct ucred *cred;
      vm_offset_t ioaddr;
      struct uio auio;
      struct iovec aiov;
      struct uio *uio = &auio;
      int nocommit = flags & UPL_NOCOMMIT;
      int iosize;
  
      int code;
      struct vcache *tvc = VTOAFS(vp);
! 
      if (UBCINVALID(vp)) {
  #if DIAGNOSTIC
  	panic("afs_vop_pageout: invalid vp");
--- 874,892 ----
      int flags = ap->a_flags;
      struct ucred *cred;
      vm_offset_t ioaddr;
+ #ifdef AFS_DARWIN80_ENV
+     struct uio *uio;
+ #else
      struct uio auio;
      struct iovec aiov;
      struct uio *uio = &auio;
+ #endif
      int nocommit = flags & UPL_NOCOMMIT;
      int iosize;
  
      int code;
      struct vcache *tvc = VTOAFS(vp);
! #ifndef AFS_DARWIN80_ENV
      if (UBCINVALID(vp)) {
  #if DIAGNOSTIC
  	panic("afs_vop_pageout: invalid vp");
***************
*** 606,615 ****
      }
  
      UBCINFOCHECK("afs_vop_pageout", vp);
      if (pl == (upl_t) NULL) {
  	panic("afs_vop_pageout: no upl");
      }
! #if 1
      {
  	int lbn, s;
  	struct buf *bp;
--- 895,908 ----
      }
  
      UBCINFOCHECK("afs_vop_pageout", vp);
+ #endif
      if (pl == (upl_t) NULL) {
  	panic("afs_vop_pageout: no upl");
      }
! #if !defined(AFS_DARWIN80_ENV) /* XXX nfs now uses it's own bufs (struct nfsbuf)
!                                   maybe the generic
!                                   layer doesn't have them anymore? In any case,
!                                   we can't just copy code from nfs... */
      {
  	int lbn, s;
  	struct buf *bp;
***************
*** 634,644 ****
  #endif
      cred = ubc_getcred(vp);
      if (cred == NOCRED)
! 	cred = ap->a_cred;
  
      if (size == 0) {
  	if (!nocommit)
! 	    kernel_upl_abort_range(pl, pl_offset, size,
  				   UPL_ABORT_FREE_ON_EMPTY);
  	return (0);
      }
--- 927,937 ----
  #endif
      cred = ubc_getcred(vp);
      if (cred == NOCRED)
! 	cred = vop_cred;
  
      if (size == 0) {
  	if (!nocommit)
! 	    OSI_UPL_ABORT_RANGE(pl, pl_offset, size,
  				   UPL_ABORT_FREE_ON_EMPTY);
  	return (0);
      }
***************
*** 646,658 ****
  	panic("nfs_pageout: (IO_APPEND | IO_SYNC)");
      if (f_offset < 0) {
  	if (!nocommit)
! 	    kernel_upl_abort_range(pl, pl_offset, size,
  				   UPL_ABORT_FREE_ON_EMPTY);
  	return (EINVAL);
      }
      if (f_offset >= tvc->m.Length) {
  	if (!nocommit)
! 	    kernel_upl_abort_range(pl, pl_offset, size,
  				   UPL_ABORT_FREE_ON_EMPTY);
  	return (EINVAL);
      }
--- 939,951 ----
  	panic("nfs_pageout: (IO_APPEND | IO_SYNC)");
      if (f_offset < 0) {
  	if (!nocommit)
! 	    OSI_UPL_ABORT_RANGE(pl, pl_offset, size,
  				   UPL_ABORT_FREE_ON_EMPTY);
  	return (EINVAL);
      }
      if (f_offset >= tvc->m.Length) {
  	if (!nocommit)
! 	    OSI_UPL_ABORT_RANGE(pl, pl_offset, size,
  				   UPL_ABORT_FREE_ON_EMPTY);
  	return (EINVAL);
      }
***************
*** 669,688 ****
  
      if (size > (iosize + (PAGE_SIZE - 1)) & ~PAGE_MASK && !nocommit)  {
              int iosize_rnd=(iosize + (PAGE_SIZE - 1)) & ~PAGE_MASK;
! 	    kernel_upl_abort_range(pl, pl_offset + iosize_rnd,
                                     size - iosize_rnd,
  				   UPL_ABORT_FREE_ON_EMPTY);
      }
      auio.uio_iov = &aiov;
      auio.uio_iovcnt = 1;
      auio.uio_offset = f_offset;
      auio.uio_segflg = UIO_SYSSPACE;
      auio.uio_rw = UIO_WRITE;
      auio.uio_procp = NULL;
-     kernel_upl_map(kernel_map, pl, &ioaddr);
-     ioaddr += pl_offset;
      auio.uio_resid = aiov.iov_len = iosize;
      aiov.iov_base = (caddr_t) ioaddr;
  #if 1				/* USV [ */
      {
  	/* 
--- 962,986 ----
  
      if (size > (iosize + (PAGE_SIZE - 1)) & ~PAGE_MASK && !nocommit)  {
              int iosize_rnd=(iosize + (PAGE_SIZE - 1)) & ~PAGE_MASK;
! 	    OSI_UPL_ABORT_RANGE(pl, pl_offset + iosize_rnd,
                                     size - iosize_rnd,
  				   UPL_ABORT_FREE_ON_EMPTY);
      }
+     OSI_UPL_MAP(pl, &ioaddr);
+     ioaddr += pl_offset;
+ #ifdef AFS_DARWIN80_ENV
+     uio = uio_create(1, f_offset, UIO_SYSSPACE32, UIO_READ);
+     uio_addiov(uio, CAST_USER_ADDR_T(ioaddr), size);
+ #else
      auio.uio_iov = &aiov;
      auio.uio_iovcnt = 1;
      auio.uio_offset = f_offset;
      auio.uio_segflg = UIO_SYSSPACE;
      auio.uio_rw = UIO_WRITE;
      auio.uio_procp = NULL;
      auio.uio_resid = aiov.iov_len = iosize;
      aiov.iov_base = (caddr_t) ioaddr;
+ #endif
  #if 1				/* USV [ */
      {
  	/* 
***************
*** 699,705 ****
  #endif /* ] USV */
  
      AFS_GLOCK();
!     osi_FlushPages(tvc, ap->a_cred);	/* hold bozon lock, but not basic vnode lock */
      ObtainWriteLock(&tvc->lock, 1);
      afs_FakeOpen(tvc);
      ReleaseWriteLock(&tvc->lock);
--- 997,1003 ----
  #endif /* ] USV */
  
      AFS_GLOCK();
!     osi_FlushPages(tvc, vop_cred);	/* hold bozon lock, but not basic vnode lock */
      ObtainWriteLock(&tvc->lock, 1);
      afs_FakeOpen(tvc);
      ReleaseWriteLock(&tvc->lock);
***************
*** 710,734 ****
      afs_FakeClose(tvc, cred);
      ReleaseWriteLock(&tvc->lock);
      AFS_GUNLOCK();
!     kernel_upl_unmap(kernel_map, pl);
      if (!nocommit) {
  	if (code)
! 	    kernel_upl_abort_range(pl, pl_offset, size,
  				   UPL_ABORT_FREE_ON_EMPTY);
  	else
! 	    kernel_upl_commit_range(pl, pl_offset, size,
  				    UPL_COMMIT_CLEAR_DIRTY |
! 				    UPL_COMMIT_FREE_ON_EMPTY,
! 				    UPL_GET_INTERNAL_PAGE_LIST(pl),
! 				    MAX_UPL_TRANSFER);
      }
  
      return code;
  }
  
  int
  afs_vop_ioctl(ap)
!      struct vop_ioctl_args	/* {
  				 * struct vnode *a_vp;
  				 * int  a_command;
  				 * caddr_t  a_data;
--- 1008,1033 ----
      afs_FakeClose(tvc, cred);
      ReleaseWriteLock(&tvc->lock);
      AFS_GUNLOCK();
!     OSI_UPL_UNMAP(pl);
      if (!nocommit) {
  	if (code)
! 	    OSI_UPL_ABORT_RANGE(pl, pl_offset, size,
  				   UPL_ABORT_FREE_ON_EMPTY);
  	else
! 	    OSI_UPL_COMMIT_RANGE(pl, pl_offset, size,
  				    UPL_COMMIT_CLEAR_DIRTY |
! 				    UPL_COMMIT_FREE_ON_EMPTY);
      }
  
+ #ifdef AFS_DARWIN80_ENV
+     uio_free(uio);
+ #endif
      return code;
  }
  
  int
  afs_vop_ioctl(ap)
!      struct VOPPROT(ioctl_args)	/* {
  				 * struct vnode *a_vp;
  				 * int  a_command;
  				 * caddr_t  a_data;
***************
*** 760,766 ****
  /* ARGSUSED */
  int
  afs_vop_select(ap)
!      struct vop_select_args	/* {
  				 * struct vnode *a_vp;
  				 * int  a_which;
  				 * int  a_fflags;
--- 1059,1065 ----
  /* ARGSUSED */
  int
  afs_vop_select(ap)
!      struct VOPPROT(select_args)	/* {
  				 * struct vnode *a_vp;
  				 * int  a_which;
  				 * int  a_fflags;
***************
*** 782,788 ****
  /* ARGSUSED */
  int
  afs_vop_mmap(ap)
!      struct vop_mmap_args	/* {
  				 * struct vnode *a_vp;
  				 * int  a_fflags;
  				 * struct ucred *a_cred;
--- 1081,1087 ----
  /* ARGSUSED */
  int
  afs_vop_mmap(ap)
!      struct VOPPROT(mmap_args)	/* {
  				 * struct vnode *a_vp;
  				 * int  a_fflags;
  				 * struct ucred *a_cred;
***************
*** 794,800 ****
  
  int
  afs_vop_fsync(ap)
!      struct vop_fsync_args	/* {
  				 * struct vnode *a_vp;
  				 * struct ucred *a_cred;
  				 * int a_waitfor;
--- 1093,1099 ----
  
  int
  afs_vop_fsync(ap)
!      struct VOPPROT(fsync_args)	/* {
  				 * struct vnode *a_vp;
  				 * struct ucred *a_cred;
  				 * int a_waitfor;
***************
*** 808,824 ****
  
      /* afs_vop_lookup glocks, can call us through vinvalbuf from GetVCache */
      if (!haveGlock) AFS_GLOCK();
!     if (ap->a_cred)
! 	error = afs_fsync(VTOAFS(vp), ap->a_cred);
      else
  	error = afs_fsync(VTOAFS(vp), &afs_osi_cred);
      if (!haveGlock) AFS_GUNLOCK();
      return error;
  }
  
  int
  afs_vop_seek(ap)
!      struct vop_seek_args	/* {
  				 * struct vnode *a_vp;
  				 * off_t  a_oldoff;
  				 * off_t  a_newoff;
--- 1107,1124 ----
  
      /* afs_vop_lookup glocks, can call us through vinvalbuf from GetVCache */
      if (!haveGlock) AFS_GLOCK();
!     if (vop_cred)
! 	error = afs_fsync(VTOAFS(vp), vop_cred);
      else
  	error = afs_fsync(VTOAFS(vp), &afs_osi_cred);
      if (!haveGlock) AFS_GUNLOCK();
      return error;
  }
  
+ #ifndef AFS_DARWIN80_ENV
  int
  afs_vop_seek(ap)
!      struct VOPPROT(seek_args)	/* {
  				 * struct vnode *a_vp;
  				 * off_t  a_oldoff;
  				 * off_t  a_newoff;
***************
*** 829,838 ****
  	return EINVAL;
      return (0);
  }
  
  int
  afs_vop_remove(ap)
!      struct vop_remove_args	/* {
  				 * struct vnode *a_dvp;
  				 * struct vnode *a_vp;
  				 * struct componentname *a_cnp;
--- 1129,1139 ----
  	return EINVAL;
      return (0);
  }
+ #endif
  
  int
  afs_vop_remove(ap)
!      struct VOPPROT(remove_args)	/* {
  				 * struct vnode *a_dvp;
  				 * struct vnode *a_vp;
  				 * struct componentname *a_cnp;
***************
*** 842,874 ****
      register struct vnode *vp = ap->a_vp;
      register struct vnode *dvp = ap->a_dvp;
  
      GETNAME();
      AFS_GLOCK();
!     error = afs_remove(VTOAFS(dvp), name, cnp->cn_cred);
      AFS_GUNLOCK();
      cache_purge(vp);
-     vput(dvp);
      if (!error) {
          /* necessary so we don't deadlock ourselves in vclean */
          VOP_UNLOCK(vp, 0, cnp->cn_proc);
  
  	/* If crashes continue in ubc_hold, comment this out */
          (void)ubc_uncache(vp);
      }
  
      if (dvp == vp)
  	vrele(vp);
      else
  	vput(vp);
  
      FREE_ZONE(cnp->cn_pnbuf, cnp->cn_pnlen, M_NAMEI);
      DROPNAME();
      return error;
  }
  
  int
  afs_vop_link(ap)
!      struct vop_link_args	/* {
  				 * struct vnode *a_vp;
  				 * struct vnode *a_tdvp;
  				 * struct componentname *a_cnp;
--- 1143,1193 ----
      register struct vnode *vp = ap->a_vp;
      register struct vnode *dvp = ap->a_dvp;
  
+ #ifdef AFS_DARWIN80_ENV
+     if (ap->a_flags & VNODE_REMOVE_NODELETEBUSY) {
+             /* Caller requested Carbon delete semantics */
+             if (vnode_isinuse(vp, 0)) {
+                     return EBUSY;
+             }
+     }
+ #endif
+ 
      GETNAME();
      AFS_GLOCK();
!     error = afs_remove(VTOAFS(dvp), name, vop_cn_cred);
      AFS_GUNLOCK();
      cache_purge(vp);
      if (!error) {
+ #ifdef AFS_DARWIN80_ENV
+         ubc_setsize(vp, (off_t)0);
+         vnode_recycle(vp);
+ #else
          /* necessary so we don't deadlock ourselves in vclean */
          VOP_UNLOCK(vp, 0, cnp->cn_proc);
  
  	/* If crashes continue in ubc_hold, comment this out */
          (void)ubc_uncache(vp);
+ #endif
      }
  
+ #ifndef AFS_DARWIN80_ENV
+     vput(dvp);
      if (dvp == vp)
  	vrele(vp);
      else
  	vput(vp);
+ #endif
  
+ #ifndef AFS_DARWIN80_ENV
      FREE_ZONE(cnp->cn_pnbuf, cnp->cn_pnlen, M_NAMEI);
+ #endif
      DROPNAME();
      return error;
  }
  
  int
  afs_vop_link(ap)
!      struct VOPPROT(link_args)	/* {
  				 * struct vnode *a_vp;
  				 * struct vnode *a_tdvp;
  				 * struct componentname *a_cnp;
***************
*** 880,910 ****
      struct proc *p;
  
      GETNAME();
!     p = cnp->cn_proc;
!     if (vp->v_type == VDIR) {
  	VOP_ABORTOP(vp, cnp);
  	error = EISDIR;
  	goto out;
      }
      if (error = vn_lock(vp, LK_EXCLUSIVE, p)) {
  	VOP_ABORTOP(dvp, cnp);
  	goto out;
      }
      AFS_GLOCK();
!     error = afs_link(VTOAFS(vp), VTOAFS(dvp), name, cnp->cn_cred);
      AFS_GUNLOCK();
      FREE_ZONE(cnp->cn_pnbuf, cnp->cn_pnlen, M_NAMEI);
      if (dvp != vp)
  	VOP_UNLOCK(vp, 0, p);
    out:
      vput(dvp);
      DROPNAME();
      return error;
  }
  
  int
  afs_vop_rename(ap)
!      struct vop_rename_args	/* {
  				 * struct vnode *a_fdvp;
  				 * struct vnode *a_fvp;
  				 * struct componentname *a_fcnp;
--- 1199,1237 ----
      struct proc *p;
  
      GETNAME();
!     p = vop_cn_proc;
!     if (vnode_isdir(vp)) {
  	VOP_ABORTOP(vp, cnp);
  	error = EISDIR;
  	goto out;
      }
+ #ifndef AFS_DARWIN80_ENV
      if (error = vn_lock(vp, LK_EXCLUSIVE, p)) {
  	VOP_ABORTOP(dvp, cnp);
  	goto out;
      }
+ #endif
      AFS_GLOCK();
!     error = afs_link(VTOAFS(vp), VTOAFS(dvp), name, vop_cn_cred);
      AFS_GUNLOCK();
+ #ifndef AFS_DARWIN80_ENV
      FREE_ZONE(cnp->cn_pnbuf, cnp->cn_pnlen, M_NAMEI);
+ #endif
+ #ifndef AFS_DARWIN80_ENV
      if (dvp != vp)
  	VOP_UNLOCK(vp, 0, p);
+ #endif
    out:
+ #ifndef AFS_DARWIN80_ENV
      vput(dvp);
+ #endif
      DROPNAME();
      return error;
  }
  
  int
  afs_vop_rename(ap)
!      struct VOPPROT(rename_args)	/* {
  				 * struct vnode *a_fdvp;
  				 * struct vnode *a_fvp;
  				 * struct componentname *a_fcnp;
***************
*** 922,929 ****
      register struct vnode *tdvp = ap->a_tdvp;
      struct vnode *fvp = ap->a_fvp;
      register struct vnode *fdvp = ap->a_fdvp;
!     struct proc *p = fcnp->cn_proc;
  
      /* Check for cross-device rename.
       * For AFS, this means anything not in AFS-space
       */
--- 1249,1263 ----
      register struct vnode *tdvp = ap->a_tdvp;
      struct vnode *fvp = ap->a_fvp;
      register struct vnode *fdvp = ap->a_fdvp;
!     struct proc *p; 
! 
!     p = cn_proc(fcnp);
  
+ #ifdef AFS_DARWIN80_ENV
+ /* generic code tests for v_mount equality, so we don't have to, but we don't
+    get the multiple-mount "benefits" of the old behavior
+ */
+ #else
      /* Check for cross-device rename.
       * For AFS, this means anything not in AFS-space
       */
***************
*** 932,945 ****
  	error = EXDEV;
  	goto abortit;
      }
  
      /*
       * if fvp == tvp, we're just removing one name of a pair of
       * directory entries for the same element.  convert call into rename.
       ( (pinched from NetBSD 1.0's ufs_rename())
       */
      if (fvp == tvp) {
! 	if (fvp->v_type == VDIR) {
  	    error = EINVAL;
  	  abortit:
  	    VOP_ABORTOP(tdvp, tcnp);	/* XXX, why not in NFS? */
--- 1266,1284 ----
  	error = EXDEV;
  	goto abortit;
      }
+ #endif
  
+ #ifdef AFS_DARWIN80_ENV
+    /* the generic code doesn't do this, so we really should, but all the
+       vrele's are wrong... */
+ #else
      /*
       * if fvp == tvp, we're just removing one name of a pair of
       * directory entries for the same element.  convert call into rename.
       ( (pinched from NetBSD 1.0's ufs_rename())
       */
      if (fvp == tvp) {
! 	if (vnode_isdir(fvp)) {
  	    error = EINVAL;
  	  abortit:
  	    VOP_ABORTOP(tdvp, tcnp);	/* XXX, why not in NFS? */
***************
*** 959,966 ****
  	VOP_ABORTOP(tdvp, tcnp);
  	vput(tdvp);
  	vput(tvp);
- 
  	/* Delete source. */
  	vrele(fdvp);
  	vrele(fvp);
  	fcnp->cn_flags &= ~MODMASK;
--- 1298,1315 ----
  	VOP_ABORTOP(tdvp, tcnp);
  	vput(tdvp);
  	vput(tvp);
  	/* Delete source. */
+ #if defined(AFS_DARWIN80_ENV) 
+ 
+         MALLOC(fname, char *, fcnp->cn_namelen + 1, M_TEMP, M_WAITOK);
+         memcpy(fname, fcnp->cn_nameptr, fcnp->cn_namelen);
+         fname[fcnp->cn_namelen] = '\0';
+         AFS_GLOCK();
+         error = afs_remove(VTOAFS(fdvp), fname, vop_cn_cred);
+         AFS_GUNLOCK();
+         FREE(fname, M_TEMP);
+         cache_purge(fvp);
+ #else
  	vrele(fdvp);
  	vrele(fvp);
  	fcnp->cn_flags &= ~MODMASK;
***************
*** 976,983 ****
          if (fvp == NULL) {
  	    return (ENOENT);
          }
-         
          error=VOP_REMOVE(fdvp, fvp, fcnp);
          if (fdvp == fvp)
              vrele(fdvp);
          else
--- 1325,1333 ----
          if (fvp == NULL) {
  	    return (ENOENT);
          }
          error=VOP_REMOVE(fdvp, fvp, fcnp);
+ #endif
+         
          if (fdvp == fvp)
              vrele(fdvp);
          else
***************
*** 985,992 ****
--- 1335,1345 ----
          vput(fvp);
          return (error);
      }
+ #endif
+ #if !defined(AFS_DARWIN80_ENV) 
      if (error = vn_lock(fvp, LK_EXCLUSIVE, p))
  	goto abortit;
+ #endif
  
      MALLOC(fname, char *, fcnp->cn_namelen + 1, M_TEMP, M_WAITOK);
      memcpy(fname, fcnp->cn_nameptr, fcnp->cn_namelen);
***************
*** 999,1010 ****
      AFS_GLOCK();
      /* XXX use "from" or "to" creds? NFS uses "to" creds */
      error =
! 	afs_rename(VTOAFS(fdvp), fname, VTOAFS(tdvp), tname, tcnp->cn_cred);
      AFS_GUNLOCK();
  
      VOP_UNLOCK(fvp, 0, p);
      FREE(fname, M_TEMP);
      FREE(tname, M_TEMP);
      if (error)
  	goto abortit;		/* XXX */
      if (tdvp == tvp)
--- 1352,1378 ----
      AFS_GLOCK();
      /* XXX use "from" or "to" creds? NFS uses "to" creds */
      error =
! 	afs_rename(VTOAFS(fdvp), fname, VTOAFS(tdvp), tname, cn_cred(tcnp));
      AFS_GUNLOCK();
  
+ #if !defined(AFS_DARWIN80_ENV) 
      VOP_UNLOCK(fvp, 0, p);
+ #endif
      FREE(fname, M_TEMP);
      FREE(tname, M_TEMP);
+ #ifdef AFS_DARWIN80_ENV
+     cache_purge(fdvp);
+     cache_purge(fvp);
+     cache_purge(tdvp);
+     if (tvp) {
+        cache_purge(tvp);
+        if (!error) {
+           vnode_recycle(tvp);
+        }
+     }
+     if (!error)
+        cache_enter(tdvp, fvp, tcnp);
+ #else
      if (error)
  	goto abortit;		/* XXX */
      if (tdvp == tvp)
***************
*** 1015,1026 ****
  	vput(tvp);
      vrele(fdvp);
      vrele(fvp);
      return error;
  }
  
  int
  afs_vop_mkdir(ap)
!      struct vop_mkdir_args	/* {
  				 * struct vnode *a_dvp;
  				 * struct vnode **a_vpp;
  				 * struct componentname *a_cnp;
--- 1383,1395 ----
  	vput(tvp);
      vrele(fdvp);
      vrele(fvp);
+ #endif
      return error;
  }
  
  int
  afs_vop_mkdir(ap)
!      struct VOPPROT(mkdir_args)	/* {
  				 * struct vnode *a_dvp;
  				 * struct vnode **a_vpp;
  				 * struct componentname *a_cnp;
***************
*** 1034,1046 ****
      struct proc *p;
  
      GETNAME();
!     p = cnp->cn_proc;
! #ifdef DIAGNOSTIC
      if ((cnp->cn_flags & HASBUF) == 0)
  	panic("afs_vop_mkdir: no name");
  #endif
      AFS_GLOCK();
!     error = afs_mkdir(VTOAFS(dvp), name, vap, &vcp, cnp->cn_cred);
      AFS_GUNLOCK();
      if (error) {
  	VOP_ABORTOP(dvp, cnp);
--- 1403,1415 ----
      struct proc *p;
  
      GETNAME();
!     p = vop_cn_proc;
! #if defined(DIAGNOSTIC) && !defined(AFS_DARWIN80_ENV)
      if ((cnp->cn_flags & HASBUF) == 0)
  	panic("afs_vop_mkdir: no name");
  #endif
      AFS_GLOCK();
!     error = afs_mkdir(VTOAFS(dvp), name, vap, &vcp, vop_cn_cred);
      AFS_GUNLOCK();
      if (error) {
  	VOP_ABORTOP(dvp, cnp);
***************
*** 1049,1068 ****
  	return (error);
      }
      if (vcp) {
  	*ap->a_vpp = AFSTOV(vcp);
  	(*ap->a_vpp)->v_vfsp = dvp->v_vfsp;
  	vn_lock(*ap->a_vpp, LK_EXCLUSIVE | LK_RETRY, p);
      } else
  	*ap->a_vpp = 0;
      DROPNAME();
      FREE_ZONE(cnp->cn_pnbuf, cnp->cn_pnlen, M_NAMEI);
      vput(dvp);
      return error;
  }
  
  int
  afs_vop_rmdir(ap)
!      struct vop_rmdir_args	/* {
  				 * struct vnode *a_dvp;
  				 * struct vnode *a_vp;
  				 * struct componentname *a_cnp;
--- 1418,1444 ----
  	return (error);
      }
      if (vcp) {
+ #ifdef AFS_DARWIN80_ENV
+         afs_darwin_finalizevnode(vcp, ap->a_dvp, ap->a_cnp, 0);
+ #endif
  	*ap->a_vpp = AFSTOV(vcp);
+ #ifndef AFS_DARWIN80_ENV /* XXX needed for multi-mount thing, but can't have it yet */
  	(*ap->a_vpp)->v_vfsp = dvp->v_vfsp;
  	vn_lock(*ap->a_vpp, LK_EXCLUSIVE | LK_RETRY, p);
+ #endif
      } else
  	*ap->a_vpp = 0;
      DROPNAME();
+ #ifndef AFS_DARWIN80_ENV
      FREE_ZONE(cnp->cn_pnbuf, cnp->cn_pnlen, M_NAMEI);
      vput(dvp);
+ #endif
      return error;
  }
  
  int
  afs_vop_rmdir(ap)
!      struct VOPPROT(rmdir_args)	/* {
  				 * struct vnode *a_dvp;
  				 * struct vnode *a_vp;
  				 * struct componentname *a_cnp;
***************
*** 1074,1098 ****
  
      GETNAME();
      if (dvp == vp) {
  	vrele(dvp);
  	vput(vp);
  	FREE_ZONE(cnp->cn_pnbuf, cnp->cn_pnlen, M_NAMEI);
  	DROPNAME();
  	return (EINVAL);
      }
  
      AFS_GLOCK();
!     error = afs_rmdir(VTOAFS(dvp), name, cnp->cn_cred);
      AFS_GUNLOCK();
      DROPNAME();
      vput(dvp);
      vput(vp);
      return error;
  }
  
  int
  afs_vop_symlink(ap)
!      struct vop_symlink_args	/* {
  				 * struct vnode *a_dvp;
  				 * struct vnode **a_vpp;
  				 * struct componentname *a_cnp;
--- 1450,1480 ----
  
      GETNAME();
      if (dvp == vp) {
+ #ifndef AFS_DARWIN80_ENV
  	vrele(dvp);
  	vput(vp);
  	FREE_ZONE(cnp->cn_pnbuf, cnp->cn_pnlen, M_NAMEI);
+ #endif
  	DROPNAME();
  	return (EINVAL);
      }
  
      AFS_GLOCK();
!     error = afs_rmdir(VTOAFS(dvp), name, vop_cn_cred);
      AFS_GUNLOCK();
      DROPNAME();
+     cache_purge(dvp);
+     cache_purge(vp);
+ #ifndef AFS_DARWIN80_ENV
      vput(dvp);
      vput(vp);
+ #endif
      return error;
  }
  
  int
  afs_vop_symlink(ap)
!      struct VOPPROT(symlink_args)	/* {
  				 * struct vnode *a_dvp;
  				 * struct vnode **a_vpp;
  				 * struct componentname *a_cnp;
***************
*** 1107,1123 ****
      GETNAME();
      AFS_GLOCK();
      error =
! 	afs_symlink(VTOAFS(dvp), name, ap->a_vap, ap->a_target, cnp->cn_cred);
      AFS_GUNLOCK();
      DROPNAME();
      FREE_ZONE(cnp->cn_pnbuf, cnp->cn_pnlen, M_NAMEI);
      vput(dvp);
      return error;
  }
  
  int
  afs_vop_readdir(ap)
!      struct vop_readdir_args	/* {
  				 * struct vnode *a_vp;
  				 * struct uio *a_uio;
  				 * struct ucred *a_cred;
--- 1489,1507 ----
      GETNAME();
      AFS_GLOCK();
      error =
! 	afs_symlink(VTOAFS(dvp), name, ap->a_vap, ap->a_target, vop_cn_cred);
      AFS_GUNLOCK();
      DROPNAME();
+ #ifndef AFS_DARWIN80_ENV
      FREE_ZONE(cnp->cn_pnbuf, cnp->cn_pnlen, M_NAMEI);
      vput(dvp);
+ #endif
      return error;
  }
  
  int
  afs_vop_readdir(ap)
!      struct VOPPROT(readdir_args)	/* {
  				 * struct vnode *a_vp;
  				 * struct uio *a_uio;
  				 * struct ucred *a_cred;
***************
*** 1130,1140 ****
      off_t off;
  /*    printf("readdir %x cookies %x ncookies %d\n", ap->a_vp, ap->a_cookies,
  	   ap->a_ncookies); */
!     off = ap->a_uio->uio_offset;
      AFS_GLOCK();
      error =
! 	afs_readdir(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred, ap->a_eofflag);
      AFS_GUNLOCK();
      if (!error && ap->a_ncookies != NULL) {
  	struct uio *uio = ap->a_uio;
  	const struct dirent *dp, *dp_start, *dp_end;
--- 1514,1531 ----
      off_t off;
  /*    printf("readdir %x cookies %x ncookies %d\n", ap->a_vp, ap->a_cookies,
  	   ap->a_ncookies); */
! #ifdef AFS_DARWIN80_ENV
!     /* too much work for now */
!     /* should only break nfs exports */
!     if (ap->a_flags & (VNODE_READDIR_EXTENDED | VNODE_READDIR_REQSEEKOFF))
!          return (EINVAL);
! #endif
!     off = AFS_UIO_OFFSET(ap->a_uio);
      AFS_GLOCK();
      error =
! 	afs_readdir(VTOAFS(ap->a_vp), ap->a_uio, vop_cred, ap->a_eofflag);
      AFS_GUNLOCK();
+ #ifndef AFS_DARWIN80_ENV
      if (!error && ap->a_ncookies != NULL) {
  	struct uio *uio = ap->a_uio;
  	const struct dirent *dp, *dp_start, *dp_end;
***************
*** 1161,1173 ****
  	*ap->a_cookies = cookies;
  	*ap->a_ncookies = ncookies;
      }
  
      return error;
  }
  
  int
  afs_vop_readlink(ap)
!      struct vop_readlink_args	/* {
  				 * struct vnode *a_vp;
  				 * struct uio *a_uio;
  				 * struct ucred *a_cred;
--- 1552,1565 ----
  	*ap->a_cookies = cookies;
  	*ap->a_ncookies = ncookies;
      }
+ #endif
  
      return error;
  }
  
  int
  afs_vop_readlink(ap)
!      struct VOPPROT(readlink_args)	/* {
  				 * struct vnode *a_vp;
  				 * struct uio *a_uio;
  				 * struct ucred *a_cred;
***************
*** 1176,1182 ****
      int error;
  /*    printf("readlink %x\n", ap->a_vp);*/
      AFS_GLOCK();
!     error = afs_readlink(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred);
      AFS_GUNLOCK();
      return error;
  }
--- 1568,1574 ----
      int error;
  /*    printf("readlink %x\n", ap->a_vp);*/
      AFS_GLOCK();
!     error = afs_readlink(VTOAFS(ap->a_vp), ap->a_uio, vop_cred);
      AFS_GUNLOCK();
      return error;
  }
***************
*** 1185,1237 ****
  
  int
  afs_vop_inactive(ap)
!      struct vop_inactive_args	/* {
  				 * struct vnode *a_vp;
  				 * struct proc *a_p;
  				 * } */ *ap;
  {
      register struct vnode *vp = ap->a_vp;
! 
!     if (prtactive && vp->v_usecount != 0)
  	vprint("afs_vop_inactive(): pushing active", vp);
! 
!     AFS_GLOCK();
!     afs_InactiveVCache(VTOAFS(vp), 0);	/* decrs ref counts */
!     AFS_GUNLOCK();
      VOP_UNLOCK(vp, 0, ap->a_p);
      return 0;
  }
  
  int
  afs_vop_reclaim(ap)
!      struct vop_reclaim_args	/* {
  				 * struct vnode *a_vp;
  				 * } */ *ap;
  {
      int error = 0;
      int sl;
      register struct vnode *vp = ap->a_vp;
-     int haveGlock = ISAFS_GLOCK();
      struct vcache *tvc = VTOAFS(vp);
  
      cache_purge(vp);		/* just in case... */
!     if (!haveGlock)
! 	AFS_GLOCK();
!     error = afs_FlushVCache(VTOAFS(vp), &sl);	/* toss our stuff from vnode */
!     if (!haveGlock)
! 	AFS_GUNLOCK();
  
!     if (!error && vp->v_data)
! 	panic("afs_reclaim: vnode not cleaned");
!     if (!error && (tvc->v != NULL)) 
!         panic("afs_reclaim: vcache not cleaned");
  
      return error;
  }
  
  int
  afs_vop_lock(ap)
!      struct vop_lock_args	/* {
  				 * struct vnode *a_vp;
  				 * } */ *ap;
  {
--- 1577,1743 ----
  
  int
  afs_vop_inactive(ap)
!      struct VOPPROT(inactive_args)	/* {
  				 * struct vnode *a_vp;
  				 * struct proc *a_p;
  				 * } */ *ap;
  {
      register struct vnode *vp = ap->a_vp;
!     struct vcache *tvc = VTOAFS(vp);
! #ifndef AFS_DARWIN80_ENV
!     if (prtactive && vnode_isinuse(vp, 0) != 0)
  	vprint("afs_vop_inactive(): pushing active", vp);
! #endif
!     if (tvc) {
!        AFS_GLOCK();
!        afs_InactiveVCache(tvc, 0);	/* decrs ref counts */
!        AFS_GUNLOCK();
!     }
! #ifndef AFS_DARWIN80_ENV
      VOP_UNLOCK(vp, 0, ap->a_p);
+ #endif
      return 0;
  }
  
  int
  afs_vop_reclaim(ap)
!      struct VOPPROT(reclaim_args)	/* {
  				 * struct vnode *a_vp;
  				 * } */ *ap;
  {
      int error = 0;
      int sl;
      register struct vnode *vp = ap->a_vp;
      struct vcache *tvc = VTOAFS(vp);
  
+     osi_Assert(!ISAFS_GLOCK());
      cache_purge(vp);		/* just in case... */
!     if (tvc) {
!        AFS_GLOCK();
!        ObtainWriteLock(&afs_xvcache, 335);
!        error = afs_FlushVCache(tvc, &sl);	/* toss our stuff from vnode */
!        if (tvc->states & (CVInit | CDeadVnode)) {
!           tvc->states &= ~(CVInit | CDeadVnode);
!           afs_osi_Wakeup(&tvc->states);
!        }
!        ReleaseWriteLock(&afs_xvcache);
!        AFS_GUNLOCK();
!        if (!error && vnode_fsnode(vp))
! 	   panic("afs_reclaim: vnode not cleaned");
!        if (!error && (tvc->v != NULL)) 
!            panic("afs_reclaim: vcache not cleaned");
!     }
!     return error;
! }
  
! /*
!  * Return POSIX pathconf information applicable to ufs filesystems.
!  */
! afs_vop_pathconf(ap)
!      struct VOPPROT(pathconf_args)	/* {
! 				 * struct vnode *a_vp;
! 				 * int a_name;
! 				 * int *a_retval;
! 				 * } */ *ap;
! {
!     AFS_STATCNT(afs_cntl);
!     switch (ap->a_name) {
!     case _PC_LINK_MAX:
! 	*ap->a_retval = LINK_MAX;
! 	break;
!     case _PC_NAME_MAX:
! 	*ap->a_retval = NAME_MAX;
! 	break;
!     case _PC_PATH_MAX:
! 	*ap->a_retval = PATH_MAX;
! 	break;
!     case _PC_CHOWN_RESTRICTED:
! 	*ap->a_retval = 1;
! 	break;
!     case _PC_NO_TRUNC:
! 	*ap->a_retval = 1;
! 	break;
!     case _PC_PIPE_BUF:
! 	return EINVAL;
! 	break;
! #if defined(AFS_DARWIN70_ENV)
!     case _PC_NAME_CHARS_MAX:
!         *ap->a_retval = NAME_MAX;
! 	break;
!     case _PC_CASE_SENSITIVE:
!         *ap->a_retval = 1;
! 	break;
!     case _PC_CASE_PRESERVING:
!         *ap->a_retval = 1;
! 	break;
! #endif /* defined(AFS_DARWIN70_ENV) */
!     default:
! 	return EINVAL;
!     }
!     return 0;
! }
  
+ /*
+  * Advisory record locking support (fcntl() POSIX style)
+  */
+ int
+ afs_vop_advlock(ap)
+      struct VOPPROT(advlock_args)	/* {
+ 				 * struct vnode *a_vp;
+ 				 * caddr_t  a_id;
+ 				 * int  a_op;
+ 				 * struct flock *a_fl;
+ 				 * int  a_flags;
+ 				 * } */ *ap;
+ {
+     int error;
+     struct ucred *tcr;
+ #ifdef AFS_DARWIN80_ENV
+     tcr=vop_cred;
+ #else
+     struct proc *p = current_proc();
+     struct ucred cr;
+     pcred_readlock(p);
+     cr = *p->p_cred->pc_ucred;
+     pcred_unlock(p);
+     tcr=&cr;
+ #endif
+     AFS_GLOCK();
+     error =
+ 	afs_lockctl(VTOAFS(ap->a_vp), ap->a_fl, ap->a_op, tcr, (int)ap->a_id);
+     AFS_GUNLOCK();
      return error;
  }
  
  int
+ afs_vop_blktooff(ap)
+      struct VOPPROT(blktooff_args)	/* {
+ 				 * struct vnode *a_vp;
+ 				 * daddr_t a_lblkno;
+ 				 * off_t *a_offset;    
+ 				 * } */ *ap;
+ {
+     *ap->a_offset = (off_t) (ap->a_lblkno * DEV_BSIZE);
+     return 0;
+ }
+ 
+ int
+ afs_vop_offtoblk(ap)
+      struct VOPPROT(offtoblk_args)	/* {
+ 				 * struct vnode *a_vp;
+ 				 * off_t a_offset;    
+ 				 * daddr_t *a_lblkno;
+ 				 * } */ *ap;
+ {
+     *ap->a_lblkno = (daddr_t) (ap->a_offset / DEV_BSIZE);
+ 
+     return (0);
+ }
+ 
+ #ifndef AFS_DARWIN80_ENV
+ int
  afs_vop_lock(ap)
!      struct VOPPROT(lock_args)	/* {
  				 * struct vnode *a_vp;
  				 * } */ *ap;
  {
***************
*** 1246,1252 ****
  
  int
  afs_vop_unlock(ap)
!      struct vop_unlock_args	/* {
  				 * struct vnode *a_vp;
  				 * } */ *ap;
  {
--- 1752,1758 ----
  
  int
  afs_vop_unlock(ap)
!      struct VOPPROT(unlock_args)	/* {
  				 * struct vnode *a_vp;
  				 * } */ *ap;
  {
***************
*** 1260,1267 ****
  }
  
  int
  afs_vop_bmap(ap)
!      struct vop_bmap_args	/* {
  				 * struct vnode *a_vp;
  				 * daddr_t  a_bn;
  				 * struct vnode **a_vpp;
--- 1766,1800 ----
  }
  
  int
+ afs_vop_truncate(ap)
+      struct VOPPROT(truncate_args)	/* {
+ 				 * struct vnode *a_vp;
+ 				 * off_t a_length;
+ 				 * int a_flags;
+ 				 * struct ucred *a_cred;
+ 				 * struct proc *a_p;
+ 				 * } */ *ap;
+ {
+     printf("stray afs_vop_truncate\n");
+     return EOPNOTSUPP;
+ }
+ 
+ int
+ afs_vop_update(ap)
+      struct VOPPROT(update_args)	/* {
+ 				 * struct vnode *a_vp;
+ 				 * struct timeval *a_access;
+ 				 * struct timeval *a_modify;
+ 				 * int a_waitfor;
+ 				 * } */ *ap;
+ {
+     printf("stray afs_vop_update\n");
+     return EOPNOTSUPP;
+ }
+ 
+ int
  afs_vop_bmap(ap)
!      struct VOPPROT(bmap_args)	/* {
  				 * struct vnode *a_vp;
  				 * daddr_t  a_bn;
  				 * struct vnode **a_vpp;
***************
*** 1289,1295 ****
  
  int
  afs_vop_strategy(ap)
!      struct vop_strategy_args	/* {
  				 * struct buf *a_bp;
  				 * } */ *ap;
  {
--- 1822,1828 ----
  
  int
  afs_vop_strategy(ap)
!      struct VOPPROT(strategy_args)	/* {
  				 * struct buf *a_bp;
  				 * } */ *ap;
  {
***************
*** 1302,1308 ****
  
  int
  afs_vop_print(ap)
!      struct vop_print_args	/* {
  				 * struct vnode *a_vp;
  				 * } */ *ap;
  {
--- 1835,1841 ----
  
  int
  afs_vop_print(ap)
!      struct VOPPROT(print_args)	/* {
  				 * struct vnode *a_vp;
  				 * } */ *ap;
  {
***************
*** 1336,1342 ****
  
  int
  afs_vop_islocked(ap)
!      struct vop_islocked_args	/* {
  				 * struct vnode *a_vp;
  				 * } */ *ap;
  {
--- 1869,1875 ----
  
  int
  afs_vop_islocked(ap)
!      struct VOPPROT(islocked_args)	/* {
  				 * struct vnode *a_vp;
  				 * } */ *ap;
  {
***************
*** 1344,1477 ****
      return lockstatus(&vc->rwlock);
  }
  
- /*
-  * Return POSIX pathconf information applicable to ufs filesystems.
-  */
- afs_vop_pathconf(ap)
-      struct vop_pathconf_args	/* {
- 				 * struct vnode *a_vp;
- 				 * int a_name;
- 				 * int *a_retval;
- 				 * } */ *ap;
- {
-     AFS_STATCNT(afs_cntl);
-     switch (ap->a_name) {
-     case _PC_LINK_MAX:
- 	*ap->a_retval = LINK_MAX;
- 	break;
-     case _PC_NAME_MAX:
- 	*ap->a_retval = NAME_MAX;
- 	break;
-     case _PC_PATH_MAX:
- 	*ap->a_retval = PATH_MAX;
- 	break;
-     case _PC_CHOWN_RESTRICTED:
- 	*ap->a_retval = 1;
- 	break;
-     case _PC_NO_TRUNC:
- 	*ap->a_retval = 1;
- 	break;
-     case _PC_PIPE_BUF:
- 	return EINVAL;
- 	break;
- #if defined(AFS_DARWIN70_ENV)
-     case _PC_NAME_CHARS_MAX:
-         *ap->a_retval = NAME_MAX;
- 	break;
-     case _PC_CASE_SENSITIVE:
-         *ap->a_retval = 1;
- 	break;
-     case _PC_CASE_PRESERVING:
-         *ap->a_retval = 1;
- 	break;
- #endif /* defined(AFS_DARWIN70_ENV) */
-     default:
- 	return EINVAL;
-     }
-     return 0;
- }
- 
- /*
-  * Advisory record locking support (fcntl() POSIX style)
-  */
- int
- afs_vop_advlock(ap)
-      struct vop_advlock_args	/* {
- 				 * struct vnode *a_vp;
- 				 * caddr_t  a_id;
- 				 * int  a_op;
- 				 * struct flock *a_fl;
- 				 * int  a_flags;
- 				 * } */ *ap;
- {
-     int error;
-     struct proc *p = current_proc();
-     struct ucred cr;
-     pcred_readlock(p);
-     cr = *p->p_cred->pc_ucred;
-     pcred_unlock(p);
-     AFS_GLOCK();
-     error =
- 	afs_lockctl(VTOAFS(ap->a_vp), ap->a_fl, ap->a_op, &cr, (int)ap->a_id);
-     AFS_GUNLOCK();
-     return error;
- }
- 
- int
- afs_vop_truncate(ap)
-      struct vop_truncate_args	/* {
- 				 * struct vnode *a_vp;
- 				 * off_t a_length;
- 				 * int a_flags;
- 				 * struct ucred *a_cred;
- 				 * struct proc *a_p;
- 				 * } */ *ap;
- {
-     printf("stray afs_vop_truncate\n");
-     return EOPNOTSUPP;
- }
- 
- int
- afs_vop_update(ap)
-      struct vop_update_args	/* {
- 				 * struct vnode *a_vp;
- 				 * struct timeval *a_access;
- 				 * struct timeval *a_modify;
- 				 * int a_waitfor;
- 				 * } */ *ap;
- {
-     printf("stray afs_vop_update\n");
-     return EOPNOTSUPP;
- }
- 
- int
- afs_vop_blktooff(ap)
-      struct vop_blktooff_args	/* {
- 				 * struct vnode *a_vp;
- 				 * daddr_t a_lblkno;
- 				 * off_t *a_offset;    
- 				 * } */ *ap;
- {
-     *ap->a_offset = (off_t) (ap->a_lblkno * DEV_BSIZE);
-     return 0;
- }
- 
- int
- afs_vop_offtoblk(ap)
-      struct vop_offtoblk_args	/* {
- 				 * struct vnode *a_vp;
- 				 * off_t a_offset;    
- 				 * daddr_t *a_lblkno;
- 				 * } */ *ap;
- {
-     *ap->a_lblkno = (daddr_t) (ap->a_offset / DEV_BSIZE);
- 
-     return (0);
- }
- 
  int
  afs_vop_cmap(ap)
!      struct vop_cmap_args	/* {
  				 * struct vnode *a_vp;
  				 * off_t a_foffset;    
  				 * size_t a_size;
--- 1877,1885 ----
      return lockstatus(&vc->rwlock);
  }
  
  int
  afs_vop_cmap(ap)
!      struct VOPPROT(cmap_args)	/* {
  				 * struct vnode *a_vp;
  				 * off_t a_foffset;    
  				 * size_t a_size;
***************
*** 1484,1496 ****
      *ap->a_run = MAX(ap->a_size, AFS_CHUNKSIZE(ap->a_foffset));
      return 0;
  }
  
! void
! afs_darwin_getnewvnode(struct vcache *tvc)
  {
!     while (getnewvnode(VT_AFS, afs_globalVFS, afs_vnodeop_p, &tvc->v)) {
          /* no vnodes available, force an alloc (limits be damned)! */
  	printf("failed to get vnode\n");
      }
!     tvc->v->v_data = (void *)tvc;
  }
--- 1892,2018 ----
      *ap->a_run = MAX(ap->a_size, AFS_CHUNKSIZE(ap->a_foffset));
      return 0;
  }
+ #endif
  
! int
! afs_darwin_getnewvnode(struct vcache *avc)
  {
! #ifdef AFS_DARWIN80_ENV
!     vnode_t vp;
!     int error, dead;
!     struct vnode_fsparam par;
! 
!     memset(&par, 0, sizeof(struct vnode_fsparam));
! #if 0
!     AFS_GLOCK();
!     ObtainWriteLock(&avc->lock,342);
!     if (avc->states & CStatd) { 
!        par.vnfs_vtype = avc->m.Type;
!        par.vnfs_vops = afs_vnodeop_p;
!        par.vnfs_filesize = avc->m.Length;
!        if (!ac->cnp)
!            par.vnfs_flags = VNFS_NOCACHE;
!        dead = 0;
!     } else {
!        par.vnfs_vtype = VNON;
!        par.vnfs_vops = afs_dead_vnodeop_p;
!        par.vnfs_flags = VNFS_NOCACHE|VNFS_CANTCACHE;
!        dead = 1;
!     }
!     ReleaseWriteLock(&avc->lock);
!     AFS_GUNLOCK();
!     par.vnfs_dvp = ac->dvp;
!     par.vnfs_cnp = ac->cnp;
!     par.vnfs_markroot = ac->markroot;
! #else
!     par.vnfs_vtype = VNON;
!     par.vnfs_vops = afs_dead_vnodeop_p;
!     par.vnfs_flags = VNFS_NOCACHE|VNFS_CANTCACHE;
! #endif
!     par.vnfs_mp = afs_globalVFS;
!     par.vnfs_fsnode = avc;
! 
!     error = vnode_create(VNCREATE_FLAVOR, VCREATESIZE, &par, &vp);
!     if (!error) {
!       vnode_addfsref(vp);
!       vnode_ref(vp);
!       avc->v = vp;
! #if 0
!       if (dead) {
!          vnode_recycle(vp); /* terminate as soon as iocount drops */
!          avc->states |= CDeadVnode;
!       } else if (!ac->markroot && !ac->cnp) {
!        /* the caller doesn't know anything about this vnode. if markroot
!           should have been set and wasn't, bad things may happen, so encourage
!           it to recycle */
!           vnode_recycle(vp);
!       }
! #else
!       vnode_recycle(vp); /* terminate as soon as iocount drops */
!       avc->states |= CDeadVnode;
! #endif
!     }
!     return error;
! #else
!     while (getnewvnode(VT_AFS, afs_globalVFS, afs_vnodeop_p, &avc->v)) {
          /* no vnodes available, force an alloc (limits be damned)! */
  	printf("failed to get vnode\n");
      }
!     avc->v->v_data = (void *)avc;
!     return 0;
! #endif
  }
+ #ifdef AFS_DARWIN80_ENV
+ /* if this fails, then tvc has been unrefed and may have been freed. 
+    Don't touch! */
+ int 
+ afs_darwin_finalizevnode(struct vcache *avc, struct vnode *dvp, struct componentname *cnp, int isroot) {
+    vnode_t ovp = AFSTOV(avc);
+    vnode_t nvp;
+    int error;
+    struct vnode_fsparam par;
+    AFS_GLOCK();
+    ObtainWriteLock(&avc->lock,325);
+    if (!(avc->states & CDeadVnode) && vnode_vtype(ovp) != VNON) {
+         ReleaseWriteLock(&avc->lock);
+         AFS_GUNLOCK();
+ #if 0 /* unsupported */
+         if (dvp && cnp)
+         vnode_update_identity(ovp, dvp, cnp->cn_nameptr, cnp->cn_namelen,
+                               cnp->cn_hash,
+                               VNODE_UPDATE_PARENT|VNODE_UPDATE_NAME);
+ #endif
+         vnode_rele(ovp);
+         return 0;
+    }
+    if ((avc->states & CDeadVnode) && vnode_vtype(ovp) != VNON) 
+        panic("vcache %p should not be CDeadVnode", avc);
+    AFS_GUNLOCK();
+    memset(&par, 0, sizeof(struct vnode_fsparam));
+    par.vnfs_mp = afs_globalVFS;
+    par.vnfs_vtype = avc->m.Type;
+    par.vnfs_vops = afs_vnodeop_p;
+    par.vnfs_filesize = avc->m.Length;
+    par.vnfs_fsnode = avc;
+    par.vnfs_dvp = dvp;
+    par.vnfs_cnp = cnp;
+    if (isroot)
+        par.vnfs_markroot = 1;
+    error = vnode_create(VNCREATE_FLAVOR, VCREATESIZE, &par, &nvp);
+    if (!error) {
+      vnode_addfsref(nvp);
+      avc->v = nvp;
+      avc->states &=~ CDeadVnode;
+      vnode_clearfsnode(ovp);
+      vnode_removefsref(ovp);
+    }
+    AFS_GLOCK();
+    ReleaseWriteLock(&avc->lock);
+    if (!error)
+       afs_osi_Wakeup(&avc->states);
+    AFS_GUNLOCK();
+    vnode_put(ovp);
+    vnode_rele(ovp);
+    return error;
+ }
+ #endif
Index: openafs/src/afs/LINUX/osi_vfsops.c
diff -c openafs/src/afs/LINUX/osi_vfsops.c:1.29.2.10 openafs/src/afs/LINUX/osi_vfsops.c:1.29.2.11
*** openafs/src/afs/LINUX/osi_vfsops.c:1.29.2.10	Fri Aug 19 13:51:50 2005
--- openafs/src/afs/LINUX/osi_vfsops.c	Thu Oct 13 14:08:40 2005
***************
*** 16,22 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_vfsops.c,v 1.29.2.10 2005/08/19 17:51:50 shadow Exp $");
  
  #define __NO_VERSION__		/* don't define kernel_version in module.h */
  #include <linux/module.h> /* early to avoid printf->printk mapping */
--- 16,22 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_vfsops.c,v 1.29.2.11 2005/10/13 18:08:40 shadow Exp $");
  
  #define __NO_VERSION__		/* don't define kernel_version in module.h */
  #include <linux/module.h> /* early to avoid printf->printk mapping */
***************
*** 324,330 ****
  
      if (vcp->vlruq.prev || vcp->vlruq.next)
  	osi_Panic("inode freed while on LRU");
!     if (vcp->hnext || vcp->vhnext)
  	osi_Panic("inode freed while still hashed");
  
  #if !defined(STRUCT_SUPER_HAS_ALLOC_INODE)
--- 324,330 ----
  
      if (vcp->vlruq.prev || vcp->vlruq.next)
  	osi_Panic("inode freed while on LRU");
!     if (vcp->hnext)
  	osi_Panic("inode freed while still hashed");
  
  #if !defined(STRUCT_SUPER_HAS_ALLOC_INODE)
Index: openafs/src/afs/LINUX/osi_vnodeops.c
diff -c openafs/src/afs/LINUX/osi_vnodeops.c:1.81.2.36 openafs/src/afs/LINUX/osi_vnodeops.c:1.81.2.37
*** openafs/src/afs/LINUX/osi_vnodeops.c:1.81.2.36	Sun Sep  4 00:11:55 2005
--- openafs/src/afs/LINUX/osi_vnodeops.c	Sat Oct 15 11:52:13 2005
***************
*** 22,28 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_vnodeops.c,v 1.81.2.36 2005/09/04 04:11:55 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
--- 22,28 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_vnodeops.c,v 1.81.2.37 2005/10/15 15:52:13 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
***************
*** 126,137 ****
      }
  
      ObtainWriteLock(&vcp->lock, 530);
-     vcp->m.Date = osi_Time();	/* set modification time */
      afs_FakeClose(vcp, credp);
-     if (code >= 0)
- 	code2 = afs_DoPartialWrite(vcp, &treq);
-     if (code2 && code >= 0)
- 	code = (ssize_t) - code2;
      ReleaseWriteLock(&vcp->lock);
  
      afs_Trace4(afs_iclSetp, CM_TRACE_WRITEOP, ICL_TYPE_POINTER, vcp,
--- 126,132 ----
***************
*** 1475,1480 ****
--- 1470,1494 ----
      ip->i_size = vcp->m.Length;
      ip->i_blocks = ((vcp->m.Length + 1023) >> 10) << 1;
  
+     if (!code) {
+ 	struct vrequest treq;
+ 
+ 	ObtainWriteLock(&vcp->lock, 533);
+ 	vcp->m.Date = osi_Time();   /* set modification time */
+ 	if (!afs_InitReq(&treq, credp))
+ 	    code = afs_DoPartialWrite(vcp, &treq);
+ 	ReleaseWriteLock(&vcp->lock);
+     }
+     if (!code) {
+ 	struct vrequest treq;
+ 
+ 	ObtainWriteLock(&vcp->lock, 533);
+ 	vcp->m.Date = osi_Time();   /* set modification time */
+ 	if (!afs_InitReq(&treq, credp))
+ 	    code = afs_DoPartialWrite(vcp, &treq);
+ 	ReleaseWriteLock(&vcp->lock);
+     }
+ 
      code = code ? -code : count - tuio.uio_resid;
      afs_Trace4(afs_iclSetp, CM_TRACE_UPDATEPAGE, ICL_TYPE_POINTER, vcp,
  	       ICL_TYPE_POINTER, pp, ICL_TYPE_INT32, page_count(pp),
Index: openafs/src/afs/SOLARIS/osi_vnodeops.c
diff -c openafs/src/afs/SOLARIS/osi_vnodeops.c:1.20.2.3.2.1 openafs/src/afs/SOLARIS/osi_vnodeops.c:1.20.2.6
*** openafs/src/afs/SOLARIS/osi_vnodeops.c:1.20.2.3.2.1	Wed Oct 12 02:06:47 2005
--- openafs/src/afs/SOLARIS/osi_vnodeops.c	Thu Oct 13 14:23:41 2005
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/SOLARIS/osi_vnodeops.c,v 1.20.2.3.2.1 2005/10/12 06:06:47 shadow Exp $");
  
  /*
   * SOLARIS/osi_vnodeops.c
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/SOLARIS/osi_vnodeops.c,v 1.20.2.6 2005/10/13 18:23:41 shadow Exp $");
  
  /*
   * SOLARIS/osi_vnodeops.c
***************
*** 457,463 ****
--- 457,467 ----
  	    buf = pageio_setup(page, PAGESIZE, vp, B_READ);	/* allocate a buf structure */
  	    buf->b_edev = 0;
  	    buf->b_dev = 0;
+ #if defined(AFS_SUN56_ENV)
+ 	    buf->b_lblkno = lbtodb(toffset);
+ #else
  	    buf->b_blkno = btodb(toffset);
+ #endif
  	    bp_mapin(buf);	/* map it in to our address space */
  
  	    AFS_GLOCK();
***************
*** 685,691 ****
--- 689,699 ----
  	    return (ENOMEM);
  
  	tbuf->b_dev = 0;
+ #if defined(AFS_SUN56_ENV)
+ 	tbuf->b_lblkno = lbtodb(pages->p_offset);
+ #else
  	tbuf->b_blkno = btodb(pages->p_offset);
+ #endif
  	bp_mapin(tbuf);
  	AFS_GLOCK();
  	afs_Trace4(afs_iclSetp, CM_TRACE_PAGEOUTONE, ICL_TYPE_LONG, avc,
***************
*** 743,749 ****
  
      afs_Trace4(afs_iclSetp, CM_TRACE_VMRW, ICL_TYPE_POINTER, (afs_int32) avc,
  	       ICL_TYPE_LONG, (arw == UIO_WRITE ? 1 : 0), ICL_TYPE_OFFSET,
! 	       ICL_HANDLE_OFFSET(auio->uio_offset), ICL_TYPE_OFFSET,
  	       ICL_HANDLE_OFFSET(auio->uio_resid));
  
  #ifndef AFS_64BIT_CLIENT
--- 751,757 ----
  
      afs_Trace4(afs_iclSetp, CM_TRACE_VMRW, ICL_TYPE_POINTER, (afs_int32) avc,
  	       ICL_TYPE_LONG, (arw == UIO_WRITE ? 1 : 0), ICL_TYPE_OFFSET,
! 	       ICL_HANDLE_OFFSET(auio->uio_loffset), ICL_TYPE_OFFSET,
  	       ICL_HANDLE_OFFSET(auio->uio_resid));
  
  #ifndef AFS_64BIT_CLIENT
***************
*** 762,770 ****
       */
      afs_MaybeWakeupTruncateDaemon();
      while ((arw == UIO_WRITE)
! 	   && (afs_blocksUsed > (CM_WAITFORDRAINPCT * afs_cacheBlocks) / 100)) {
  	if (afs_blocksUsed - afs_blocksDiscarded >
! 	    (CM_WAITFORDRAINPCT * afs_cacheBlocks) / 100) {
  	    afs_WaitForCacheDrain = 1;
  	    afs_osi_Sleep(&afs_WaitForCacheDrain);
  	}
--- 770,778 ----
       */
      afs_MaybeWakeupTruncateDaemon();
      while ((arw == UIO_WRITE)
! 	   && (afs_blocksUsed > PERCENT(CM_WAITFORDRAINPCT, afs_cacheBlocks))) {
  	if (afs_blocksUsed - afs_blocksDiscarded >
! 	    PERCENT(CM_WAITFORDRAINPCT, afs_cacheBlocks)) {
  	    afs_WaitForCacheDrain = 1;
  	    afs_osi_Sleep(&afs_WaitForCacheDrain);
  	}
***************
*** 782,793 ****
  
      /* adjust parameters when appending files */
      if ((ioflag & IO_APPEND) && arw == UIO_WRITE) {
! #if	defined(AFS_SUN56_ENV)
! 	auio->uio_loffset = 0;
! #endif
  	auio->uio_offset = avc->m.Length;	/* write at EOF position */
      }
!     if (auio->uio_offset < 0 || (auio->uio_offset + auio->uio_resid) < 0) {
  	ReleaseWriteLock(&avc->lock);
  	afs_BozonUnlock(&avc->pvnLock, avc);
  	return EINVAL;
--- 790,802 ----
  
      /* adjust parameters when appending files */
      if ((ioflag & IO_APPEND) && arw == UIO_WRITE) {
! #if defined(AFS_SUN56_ENV)
! 	auio->uio_loffset = avc->m.Length;	/* write at EOF position */
! #else
  	auio->uio_offset = avc->m.Length;	/* write at EOF position */
+ #endif
      }
!     if (auio->afsio_offset < 0 || (auio->afsio_offset + auio->uio_resid) < 0) {
  	ReleaseWriteLock(&avc->lock);
  	afs_BozonUnlock(&avc->pvnLock, avc);
  	return EINVAL;
***************
*** 1233,1239 ****
  {
      register int code = 0;
  
!     if ((*noffp < 0 || *noffp > MAXOFF_T))
  	code = EINVAL;
      return code;
  }
--- 1242,1254 ----
  {
      register int code = 0;
  
! #ifndef AFS_64BIT_CLIENT
! # define __MAXOFF_T MAXOFF_T
! #else
! # define __MAXOFF_T MAXOFFSET_T
! #endif
! 
!     if ((*noffp < 0 || *noffp > __MAXOFF_T))
  	code = EINVAL;
      return code;
  }
Index: openafs/src/afs/VNOPS/afs_vnop_attrs.c
diff -c openafs/src/afs/VNOPS/afs_vnop_attrs.c:1.27.2.8 openafs/src/afs/VNOPS/afs_vnop_attrs.c:1.27.2.9
*** openafs/src/afs/VNOPS/afs_vnop_attrs.c:1.27.2.8	Mon Jul 11 15:29:59 2005
--- openafs/src/afs/VNOPS/afs_vnop_attrs.c	Wed Oct  5 01:58:31 2005
***************
*** 24,30 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_attrs.c,v 1.27.2.8 2005/07/11 19:29:59 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 24,30 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_attrs.c,v 1.27.2.9 2005/10/05 05:58:31 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 93,98 ****
--- 93,100 ----
      attrs->va_fsid = avc->v.v_vfsp->vfs_fsid.val[0];
  #elif defined(AFS_OSF_ENV)
      attrs->va_fsid = avc->v.v_mount->m_stat.f_fsid.val[0];
+ #elif defined(AFS_DARWIN80_ENV)
+     VATTR_RETURN(attrs, va_fsid, vfs_statfs(vnode_mount(AFSTOV(avc)))->f_fsid.val[0]);
  #elif defined(AFS_DARWIN70_ENV)
      attrs->va_fsid = avc->v->v_mount->mnt_stat.f_fsid.val[0];
  #else /* ! AFS_DARWIN70_ENV */
***************
*** 156,181 ****
       * Below return 0 (and not 1) blocks if the file is zero length. This conforms
       * better with the other filesystems that do return 0.      
       */
! #if !defined(AFS_OSF_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_XBSD_ENV)
! #if !defined(AFS_HPUX_ENV)
! #ifdef	AFS_SUN5_ENV
!     attrs->va_nblocks =
! 	(attrs->va_size ? ((attrs->va_size + 1023) >> 10) << 1 : 0);
  #elif defined(AFS_SGI_ENV)
      attrs->va_blocks = BTOBB(attrs->va_size);
! #else
!     attrs->va_blocks =
! 	(attrs->va_size ? ((attrs->va_size + 1023) >> 10) << 1 : 0);
! #endif
! #else /* !defined(AFS_HPUX_ENV) */
!     attrs->va_blocks = (attrs->va_size ? ((attrs->va_size + 1023) >> 10) : 0);
! #endif /* !defined(AFS_HPUX_ENV) */
! #else /* ! AFS_OSF_ENV && !AFS_DARWIN_ENV && !AFS_XBSD_ENV */
      attrs->va_bytes = (attrs->va_size ? (attrs->va_size + 1023) : 1024);
  #ifdef	va_bytes_rsv
      attrs->va_bytes_rsv = -1;
  #endif
! #endif /* ! AFS_OSF_ENV && !AFS_DARWIN_ENV && !AFS_XBSD_ENV */
  
      return 0;
  }
--- 158,176 ----
       * Below return 0 (and not 1) blocks if the file is zero length. This conforms
       * better with the other filesystems that do return 0.      
       */
! #ifdef AFS_HPUX_ENV
!     attrs->va_blocks = (attrs->va_size ? ((attrs->va_size + 1023) >> 10) : 0);
  #elif defined(AFS_SGI_ENV)
      attrs->va_blocks = BTOBB(attrs->va_size);
! #elif defined(AFS_XBSD_ENV) || defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV)
      attrs->va_bytes = (attrs->va_size ? (attrs->va_size + 1023) : 1024);
  #ifdef	va_bytes_rsv
      attrs->va_bytes_rsv = -1;
  #endif
! #else
!     attrs->va_blocks =
! 	(attrs->va_size ? ((attrs->va_size + 1023) >> 10) << 1 : 0);
! #endif
  
      return 0;
  }
***************
*** 225,231 ****
  	return code;
      }
  #endif
! #if defined(AFS_DARWIN_ENV)
      if (avc->states & CUBCinit) {
  	code = afs_CopyOutAttrs(avc, attrs);
  	return code;
--- 220,226 ----
  	return code;
      }
  #endif
! #if defined(AFS_DARWIN_ENV) && !defined(AFS_DARWIN80_ENV)
      if (avc->states & CUBCinit) {
  	code = afs_CopyOutAttrs(avc, attrs);
  	return code;
***************
*** 297,305 ****
  			attrs->va_nodeid = ip->i_ino;	/* VTOI()? */
  		    }
  #else
! 		    if (AFSTOV(avc)->v_flag & VROOT) {
  			struct vnode *vp = AFSTOV(avc);
  
  			vp = vp->v_vfsp->vfs_vnodecovered;
  			if (vp) {	/* Ignore weird failures */
  #ifdef AFS_SGI62_ENV
--- 292,310 ----
  			attrs->va_nodeid = ip->i_ino;	/* VTOI()? */
  		    }
  #else
! 		    if (
! #ifdef AFS_DARWIN_ENV		    
! 			vnode_isvroot(AFSTOV(avc))
! #else
! 			AFSTOV(avc)->v_flag & VROOT
! #endif
! 			) {
  			struct vnode *vp = AFSTOV(avc);
  
+ #ifdef AFS_DARWIN80_ENV
+ 			/* XXX vp = vnode_mount(vp)->mnt_vnodecovered; */
+ 			vp = 0;
+ #else
  			vp = vp->v_vfsp->vfs_vnodecovered;
  			if (vp) {	/* Ignore weird failures */
  #ifdef AFS_SGI62_ENV
***************
*** 312,317 ****
--- 317,323 ----
  				attrs->va_nodeid = ip->i_number;
  #endif
  			}
+ #endif
  		    }
  #endif /* AFS_LINUX22_ENV */
  		}
***************
*** 333,339 ****
      register int mask;
      mask = 0;
      AFS_STATCNT(afs_VAttrToAS);
! #if	defined(AFS_AIX_ENV)
  /* Boy, was this machine dependent bogosity hard to swallow????.... */
      if (av->va_mode != -1) {
  #elif	defined(AFS_LINUX22_ENV)
--- 339,347 ----
      register int mask;
      mask = 0;
      AFS_STATCNT(afs_VAttrToAS);
! #if     defined(AFS_DARWIN80_ENV)
!     if (VATTR_IS_ACTIVE(av, va_mode)) {
! #elif	defined(AFS_AIX_ENV)
  /* Boy, was this machine dependent bogosity hard to swallow????.... */
      if (av->va_mode != -1) {
  #elif	defined(AFS_LINUX22_ENV)
***************
*** 353,359 ****
  	    ReleaseWriteLock(&avc->lock);
  	}
      }
! #if defined(AFS_LINUX22_ENV)
      if (av->va_mask & ATTR_GID) {
  #elif defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
      if (av->va_mask & AT_GID) {
--- 361,369 ----
  	    ReleaseWriteLock(&avc->lock);
  	}
      }
! #if     defined(AFS_DARWIN80_ENV)
!     if (VATTR_IS_ACTIVE(av, va_gid)) {
! #elif defined(AFS_LINUX22_ENV)
      if (av->va_mask & ATTR_GID) {
  #elif defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
      if (av->va_mask & AT_GID) {
***************
*** 371,377 ****
  	mask |= AFS_SETGROUP;
  	as->Group = av->va_gid;
      }
! #if defined(AFS_LINUX22_ENV)
      if (av->va_mask & ATTR_UID) {
  #elif defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
      if (av->va_mask & AT_UID) {
--- 381,389 ----
  	mask |= AFS_SETGROUP;
  	as->Group = av->va_gid;
      }
! #if     defined(AFS_DARWIN80_ENV)
!     if (VATTR_IS_ACTIVE(av, va_uid)) {
! #elif defined(AFS_LINUX22_ENV)
      if (av->va_mask & ATTR_UID) {
  #elif defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
      if (av->va_mask & AT_UID) {
***************
*** 389,395 ****
  	mask |= AFS_SETOWNER;
  	as->Owner = av->va_uid;
      }
! #if	defined(AFS_LINUX22_ENV)
      if (av->va_mask & ATTR_MTIME) {
  #elif	defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
      if (av->va_mask & AT_MTIME) {
--- 401,409 ----
  	mask |= AFS_SETOWNER;
  	as->Owner = av->va_uid;
      }
! #if     defined(AFS_DARWIN80_ENV)
!     if (VATTR_IS_ACTIVE(av, va_modify_time)) {
! #elif	defined(AFS_LINUX22_ENV)
      if (av->va_mask & ATTR_MTIME) {
  #elif	defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
      if (av->va_mask & AT_MTIME) {
***************
*** 466,472 ****
       * chmod) give it a shot; if it fails, we'll discard the status
       * info.
       */
! #if	defined(AFS_LINUX22_ENV)
      if (attrs->va_mask & ATTR_SIZE) {
  #elif	defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
      if (attrs->va_mask & AT_SIZE) {
--- 480,488 ----
       * chmod) give it a shot; if it fails, we'll discard the status
       * info.
       */
! #if	defined(AFS_DARWIN80_ENV)
!     if (VATTR_IS_ACTIVE(attrs, va_data_size)) {
! #elif	defined(AFS_LINUX22_ENV)
      if (attrs->va_mask & ATTR_SIZE) {
  #elif	defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
      if (attrs->va_mask & AT_SIZE) {
***************
*** 497,503 ****
  #if defined(AFS_SGI_ENV)
      AFS_RWLOCK((vnode_t *) avc, VRWLOCK_WRITE);
  #endif
! #if	defined(AFS_LINUX22_ENV)
      if (attrs->va_mask & ATTR_SIZE) {
  #elif	defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
      if (attrs->va_mask & AT_SIZE) {
--- 513,521 ----
  #if defined(AFS_SGI_ENV)
      AFS_RWLOCK((vnode_t *) avc, VRWLOCK_WRITE);
  #endif
! #if	defined(AFS_DARWIN80_ENV)
!     if (VATTR_IS_ACTIVE(attrs, va_data_size)) {
! #elif	defined(AFS_LINUX22_ENV)
      if (attrs->va_mask & ATTR_SIZE) {
  #elif	defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
      if (attrs->va_mask & AT_SIZE) {
Index: openafs/src/afs/VNOPS/afs_vnop_create.c
diff -c openafs/src/afs/VNOPS/afs_vnop_create.c:1.16.2.5 openafs/src/afs/VNOPS/afs_vnop_create.c:1.16.2.7
*** openafs/src/afs/VNOPS/afs_vnop_create.c:1.16.2.5	Thu Jul 21 12:31:34 2005
--- openafs/src/afs/VNOPS/afs_vnop_create.c	Sat Oct 15 10:24:27 2005
***************
*** 17,23 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_create.c,v 1.16.2.5 2005/07/21 16:31:34 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 17,23 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_create.c,v 1.16.2.7 2005/10/15 14:24:27 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 179,185 ****
  		    code = EACCES;
  		    goto done;
  		}
! #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
  		if ((amode & VWRITE) || (attrs->va_mask & AT_SIZE))
  #else
  		if ((amode & VWRITE) || len != 0xffffffff)
--- 179,187 ----
  		    code = EACCES;
  		    goto done;
  		}
! #if defined(AFS_DARWIN80_ENV)
! 		if ((amode & VWRITE) || VATTR_IS_ACTIVE(attrs, va_data_size))
! #elif defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
  		if ((amode & VWRITE) || (attrs->va_mask & AT_SIZE))
  #else
  		if ((amode & VWRITE) || len != 0xffffffff)
***************
*** 196,202 ****
  			goto done;
  		    }
  		}
! #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
  		if (attrs->va_mask & AT_SIZE)
  #else
  		if (len != 0xffffffff)
--- 198,206 ----
  			goto done;
  		    }
  		}
! #if defined(AFS_DARWIN80_ENV)
! 		if (VATTR_IS_ACTIVE(attrs, va_data_size))
! #elif defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
  		if (attrs->va_mask & AT_SIZE)
  #else
  		if (len != 0xffffffff)
***************
*** 208,214 ****
  			goto done;
  		    }
  		    /* do a truncate */
! #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
  		    attrs->va_mask = AT_SIZE;
  #else
  		    VATTR_NULL(attrs);
--- 212,222 ----
  			goto done;
  		    }
  		    /* do a truncate */
! #if defined(AFS_DARWIN80_ENV)
! 		    VATTR_INIT(attrs);
! 		    VATTR_SET_SUPPORTED(attrs, va_data_size);
! 		    VATTR_SET_ACTIVE(attrs, va_data_size);
! #elif defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
  		    attrs->va_mask = AT_SIZE;
  #else
  		    VATTR_NULL(attrs);
***************
*** 492,500 ****
  	hset(avc->m.DataVersion, avers);
  #ifdef AFS_64BIT_CLIENT
  	FillInt64(avc->m.Length, astat->Length_hi, astat->Length);
! #else /* AFS_64BIT_ENV */
  	avc->m.Length = astat->Length;
! #endif /* AFS_64BIT_ENV */
  	avc->m.Date = astat->ClientModTime;
      }
      if (ok) {
--- 500,508 ----
  	hset(avc->m.DataVersion, avers);
  #ifdef AFS_64BIT_CLIENT
  	FillInt64(avc->m.Length, astat->Length_hi, astat->Length);
! #else /* AFS_64BIT_CLIENT */
  	avc->m.Length = astat->Length;
! #endif /* AFS_64BIT_CLIENT */
  	avc->m.Date = astat->ClientModTime;
      }
      if (ok) {
Index: openafs/src/afs/VNOPS/afs_vnop_lookup.c
diff -c openafs/src/afs/VNOPS/afs_vnop_lookup.c:1.50.2.10.2.2 openafs/src/afs/VNOPS/afs_vnop_lookup.c:1.50.2.14
*** openafs/src/afs/VNOPS/afs_vnop_lookup.c:1.50.2.10.2.2	Wed Oct 12 02:13:24 2005
--- openafs/src/afs/VNOPS/afs_vnop_lookup.c	Fri Oct 14 22:33:12 2005
***************
*** 18,24 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_lookup.c,v 1.50.2.10.2.2 2005/10/12 06:13:24 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 18,24 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_lookup.c,v 1.50.2.14 2005/10/15 02:33:12 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 249,255 ****
   *
   * Only issues RPCs if canblock is non-zero.
   */
! int
  afs_EvalFakeStat_int(struct vcache **avcp, struct afs_fakestat_state *state,
  		     struct vrequest *areq, int canblock)
  {
--- 249,255 ----
   *
   * Only issues RPCs if canblock is non-zero.
   */
! static int
  afs_EvalFakeStat_int(struct vcache **avcp, struct afs_fakestat_state *state,
  		     struct vrequest *areq, int canblock)
  {
***************
*** 305,310 ****
--- 305,318 ----
  	    code = canblock ? ENOENT : 0;
  	    goto done;
  	}
+ #ifdef AFS_DARWIN80_ENV
+         root_vp->m.Type = VDIR;
+         AFS_GUNLOCK();
+         code = afs_darwin_finalizevnode(root_vp, NULL, NULL, 0);
+         AFS_GLOCK();
+         if (code) goto done;
+         vnode_ref(AFSTOV(root_vp));
+ #endif
  	if (tvolp) {
  	    /* Is this always kosher?  Perhaps we should instead use
  	     * NBObtainWriteLock to avoid potential deadlock.
***************
*** 563,568 ****
--- 571,579 ----
      int flagIndex = 0;		/* First file with bulk fetch flag set */
      int inlinebulk = 0;		/* Did we use InlineBulk RPC or not? */
      XSTATS_DECLS;
+ #ifdef AFS_DARWIN80_ENV
+     panic("bulkstatus doesn't work on AFS_DARWIN80_ENV. don't call it");
+ #endif
      /* first compute some basic parameters.  We dont want to prefetch more
       * than a fraction of the cache in any given call, and we want to preserve
       * a portion of the LRU queue in any event, so as to avoid thrashing
***************
*** 698,713 ****
  	    } while (tvcp && retry);
  	    if (!tvcp) {	/* otherwise, create manually */
  		tvcp = afs_NewVCache(&tfid, hostp);
! 		ObtainWriteLock(&tvcp->lock, 505);
! 		ReleaseWriteLock(&afs_xvcache);
! 		afs_RemoveVCB(&tfid);
! 		ReleaseWriteLock(&tvcp->lock);
  	    } else {
  		ReleaseWriteLock(&afs_xvcache);
  	    }
  	    if (!tvcp)
! 		goto done;	/* can't happen at present, more's the pity */
  
  	    /* WARNING: afs_DoBulkStat uses the Length field to store a
  	     * sequence number for each bulk status request. Under no
  	     * circumstances should afs_DoBulkStat store a sequence number
--- 709,742 ----
  	    } while (tvcp && retry);
  	    if (!tvcp) {	/* otherwise, create manually */
  		tvcp = afs_NewVCache(&tfid, hostp);
! 		if (tvcp)
! 		{
! 			ObtainWriteLock(&tvcp->lock, 505);
! 			ReleaseWriteLock(&afs_xvcache);
! 			afs_RemoveVCB(&tfid);
! 			ReleaseWriteLock(&tvcp->lock);
! 		} else {
! 			ReleaseWriteLock(&afs_xvcache);
! 		}
  	    } else {
  		ReleaseWriteLock(&afs_xvcache);
  	    }
  	    if (!tvcp)
! 	    {
! 		ReleaseReadLock(&dcp->lock);
! 		ReleaseReadLock(&adp->lock);
! 		goto done;	/* can happen if afs_NewVCache fails */
! 	    }
  
+ #ifdef AFS_DARWIN80_ENV
+             if (tvcp->states & CVInit) {
+                  /* XXX don't have status yet, so creating the vnode is
+                     not yet useful. we would get CDeadVnode set, and the
+                     upcoming PutVCache will cause the vcache to be flushed &
+                     freed, which in turn means the bulkstatus results won't 
+                     be used */
+             }
+ #endif
  	    /* WARNING: afs_DoBulkStat uses the Length field to store a
  	     * sequence number for each bulk status request. Under no
  	     * circumstances should afs_DoBulkStat store a sequence number
***************
*** 869,874 ****
--- 898,906 ----
      ReleaseReadLock(&afs_xvcache);	/* could be read lock */
      if (retry)
  	goto reskip;
+ #ifdef AFS_DARWIN80_ENV
+     vnode_get(AFSTOV(lruvcp));
+ #endif
  
      /* otherwise, merge in the info.  We have to be quite careful here,
       * since we need to ensure that we don't merge old info over newer
***************
*** 1066,1072 ****
--- 1098,1108 ----
  }
  
  /* was: (AFS_DEC_ENV) || defined(AFS_OSF30_ENV) || defined(AFS_NCR_ENV) */
+ #ifdef AFS_DARWIN80_ENV
+ #define AFSDOBULK 0
+ #else
  static int AFSDOBULK = 1;
+ #endif
  
  int
  #ifdef AFS_OSF_ENV
***************
*** 1169,1175 ****
  	*avcp = tvc;
  	code = (tvc ? 0 : ENOENT);
  	hit = 1;
! 	if (tvc && !VREFCOUNT(tvc)) {
  	    osi_Panic("TT1");
  	}
  	if (code) {
--- 1205,1211 ----
  	*avcp = tvc;
  	code = (tvc ? 0 : ENOENT);
  	hit = 1;
! 	if (tvc && !VREFCOUNT_GT(tvc, 0)) {
  	    osi_Panic("TT1");
  	}
  	if (code) {
***************
*** 1202,1211 ****
  	ObtainReadLock(&afs_xvcache);
  	osi_vnhold(adp, 0);
  	ReleaseReadLock(&afs_xvcache);
  	code = 0;
  	*avcp = tvc = adp;
  	hit = 1;
! 	if (adp && !VREFCOUNT(adp)) {
  	    osi_Panic("TT2");
  	}
  	goto done;
--- 1238,1250 ----
  	ObtainReadLock(&afs_xvcache);
  	osi_vnhold(adp, 0);
  	ReleaseReadLock(&afs_xvcache);
+ #ifdef AFS_DARWIN80_ENV
+         vnode_get(AFSTOV(adp));
+ #endif
  	code = 0;
  	*avcp = tvc = adp;
  	hit = 1;
! 	if (adp && !VREFCOUNT_GT(adp, 0)) {
  	    osi_Panic("TT2");
  	}
  	goto done;
***************
*** 1489,1495 ****
  		}
  	    }
  	*avcp = tvc;
! 	if (tvc && !VREFCOUNT(tvc)) {
  	    osi_Panic("TT3");
  	}
  	code = 0;
--- 1528,1534 ----
  		}
  	    }
  	*avcp = tvc;
! 	if (tvc && !VREFCOUNT_GT(tvc, 0)) {
  	    osi_Panic("TT3");
  	}
  	code = 0;
Index: openafs/src/afs/VNOPS/afs_vnop_read.c
diff -c openafs/src/afs/VNOPS/afs_vnop_read.c:1.26.2.2 openafs/src/afs/VNOPS/afs_vnop_read.c:1.26.2.3
*** openafs/src/afs/VNOPS/afs_vnop_read.c:1.26.2.2	Sun Apr 24 16:11:15 2005
--- openafs/src/afs/VNOPS/afs_vnop_read.c	Wed Oct  5 01:58:31 2005
***************
*** 19,25 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_read.c,v 1.26.2.2 2005/04/24 20:11:15 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 19,25 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_read.c,v 1.26.2.3 2005/10/05 05:58:31 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 60,67 ****
--- 60,72 ----
      afs_int32 trimlen;
      struct dcache *tdc = 0;
      afs_int32 error, trybusy = 1;
+ #ifdef AFS_DARWIN80_ENV
+     uio_t tuiop = NULL;
+ #else
      struct uio tuio;
+     struct uio *tuiop = &tuio;
      struct iovec *tvec;
+ #endif
      afs_int32 code;
      struct vrequest treq;
  
***************
*** 89,97 ****
      }
  #endif
  
      tvec = (struct iovec *)osi_AllocSmallSpace(sizeof(struct iovec));
!     totalLength = auio->afsio_resid;
!     filePos = auio->afsio_offset;
      afs_Trace4(afs_iclSetp, CM_TRACE_READ, ICL_TYPE_POINTER, avc,
  	       ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(filePos), ICL_TYPE_INT32,
  	       totalLength, ICL_TYPE_OFFSET,
--- 94,104 ----
      }
  #endif
  
+ #ifndef AFS_DARWIN80_ENV
      tvec = (struct iovec *)osi_AllocSmallSpace(sizeof(struct iovec));
! #endif
!     totalLength = AFS_UIO_RESID(auio);
!     filePos = AFS_UIO_OFFSET(auio);
      afs_Trace4(afs_iclSetp, CM_TRACE_READ, ICL_TYPE_POINTER, avc,
  	       ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(filePos), ICL_TYPE_INT32,
  	       totalLength, ICL_TYPE_OFFSET,
***************
*** 301,310 ****
  		len = tlen;
  	    if (len > AFS_ZEROS)
  		len = sizeof(afs_zeros);	/* and in 0 buffer */
  	    afsio_copy(auio, &tuio, tvec);
  	    trimlen = len;
  	    afsio_trim(&tuio, trimlen);
! 	    AFS_UIOMOVE(afs_zeros, trimlen, UIO_READ, &tuio, code);
  	    if (code) {
  		error = code;
  		break;
--- 308,322 ----
  		len = tlen;
  	    if (len > AFS_ZEROS)
  		len = sizeof(afs_zeros);	/* and in 0 buffer */
+ #ifdef AFS_DARWIN80_ENV
+ 	    trimlen = len;
+             tuiop = afsio_darwin_partialcopy(auio, trimlen);
+ #else
  	    afsio_copy(auio, &tuio, tvec);
  	    trimlen = len;
  	    afsio_trim(&tuio, trimlen);
! #endif
! 	    AFS_UIOMOVE(afs_zeros, trimlen, UIO_READ, tuiop, code);
  	    if (code) {
  		error = code;
  		break;
***************
*** 313,324 ****
  	    /* get the data from the mem cache */
  
  	    /* mung uio structure to be right for this transfer */
  	    afsio_copy(auio, &tuio, tvec);
  	    trimlen = len;
  	    afsio_trim(&tuio, trimlen);
  	    tuio.afsio_offset = offset;
  
! 	    code = afs_MemReadUIO(tdc->f.inode, &tuio);
  
  	    if (code) {
  		error = code;
--- 325,342 ----
  	    /* get the data from the mem cache */
  
  	    /* mung uio structure to be right for this transfer */
+ #ifdef AFS_DARWIN80_ENV
+ 	    trimlen = len;
+             tuiop = afsio_darwin_partialcopy(auio, trimlen);
+ 	    uio_setoffset(tuiop, offset);
+ #else
  	    afsio_copy(auio, &tuio, tvec);
  	    trimlen = len;
  	    afsio_trim(&tuio, trimlen);
  	    tuio.afsio_offset = offset;
+ #endif
  
! 	    code = afs_MemReadUIO(tdc->f.inode, tuiop);
  
  	    if (code) {
  		error = code;
***************
*** 326,332 ****
  	    }
  	}
  	/* otherwise we've read some, fixup length, etc and continue with next seg */
! 	len = len - tuio.afsio_resid;	/* compute amount really transferred */
  	trimlen = len;
  	afsio_skip(auio, trimlen);	/* update input uio structure */
  	totalLength -= len;
--- 344,350 ----
  	    }
  	}
  	/* otherwise we've read some, fixup length, etc and continue with next seg */
! 	len = len - AFS_UIO_RESID(tuiop);	/* compute amount really transferred */
  	trimlen = len;
  	afsio_skip(auio, trimlen);	/* update input uio structure */
  	totalLength -= len;
***************
*** 359,365 ****
--- 377,388 ----
      }
      if (!noLock)
  	ReleaseReadLock(&avc->lock);
+ #ifdef AFS_DARWIN80_ENV
+     if (tuiop)
+        uio_free(tuiop);
+ #else
      osi_FreeSmallSpace(tvec);
+ #endif
      error = afs_CheckCode(error, &treq, 10);
      return error;
  }
***************
*** 448,455 ****
--- 471,483 ----
      afs_int32 trimlen;
      struct dcache *tdc = 0;
      afs_int32 error;
+ #ifdef AFS_DARWIN80_ENV
+     uio_t tuiop=NULL;
+ #else
      struct uio tuio;
+     struct uio *tuiop = &tuio;
      struct iovec *tvec;
+ #endif
      struct osi_file *tfile;
      afs_int32 code;
      int trybusy = 1;
***************
*** 483,491 ****
      }
  #endif
  
      tvec = (struct iovec *)osi_AllocSmallSpace(sizeof(struct iovec));
!     totalLength = auio->afsio_resid;
!     filePos = auio->afsio_offset;
      afs_Trace4(afs_iclSetp, CM_TRACE_READ, ICL_TYPE_POINTER, avc,
  	       ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(filePos), ICL_TYPE_INT32,
  	       totalLength, ICL_TYPE_OFFSET,
--- 511,521 ----
      }
  #endif
  
+ #ifndef AFS_DARWIN80_ENV
      tvec = (struct iovec *)osi_AllocSmallSpace(sizeof(struct iovec));
! #endif
!     totalLength = AFS_UIO_RESID(auio);
!     filePos = AFS_UIO_OFFSET(auio);
      afs_Trace4(afs_iclSetp, CM_TRACE_READ, ICL_TYPE_POINTER, avc,
  	       ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(filePos), ICL_TYPE_INT32,
  	       totalLength, ICL_TYPE_OFFSET,
***************
*** 686,695 ****
  		len = tlen;
  	    if (len > AFS_ZEROS)
  		len = sizeof(afs_zeros);	/* and in 0 buffer */
  	    afsio_copy(auio, &tuio, tvec);
  	    trimlen = len;
  	    afsio_trim(&tuio, trimlen);
! 	    AFS_UIOMOVE(afs_zeros, trimlen, UIO_READ, &tuio, code);
  	    if (code) {
  		error = code;
  		break;
--- 716,730 ----
  		len = tlen;
  	    if (len > AFS_ZEROS)
  		len = sizeof(afs_zeros);	/* and in 0 buffer */
+ #ifdef AFS_DARWIN80_ENV
+ 	    trimlen = len;
+             tuiop = afsio_darwin_partialcopy(auio, trimlen);
+ #else
  	    afsio_copy(auio, &tuio, tvec);
  	    trimlen = len;
  	    afsio_trim(&tuio, trimlen);
! #endif
! 	    AFS_UIOMOVE(afs_zeros, trimlen, UIO_READ, tuiop, code);
  	    if (code) {
  		error = code;
  		break;
***************
*** 712,722 ****
--- 747,764 ----
  #endif /* IHINT */
  
  		tfile = (struct osi_file *)osi_UFSOpen(tdc->f.inode);
+ #ifdef AFS_DARWIN80_ENV
+ 	    trimlen = len;
+             tuiop = afsio_darwin_partialcopy(auio, trimlen);
+ 	    uio_setoffset(tuiop, offset);
+ #else
  	    /* mung uio structure to be right for this transfer */
  	    afsio_copy(auio, &tuio, tvec);
  	    trimlen = len;
  	    afsio_trim(&tuio, trimlen);
  	    tuio.afsio_offset = offset;
+ #endif
+ 
  #if defined(AFS_AIX41_ENV)
  	    AFS_GUNLOCK();
  	    code =
***************
*** 790,795 ****
--- 832,841 ----
  	    AFS_GUNLOCK();
  	    code = osi_rdwr(tfile, &tuio, UIO_READ);
  	    AFS_GLOCK();
+ #elif defined(AFS_DARWIN80_ENV)
+ 	    AFS_GUNLOCK();
+ 	    code = VNOP_READ(tfile->vnode, tuiop, 0, afs_osi_ctxtp);
+ 	    AFS_GLOCK();
  #elif defined(AFS_DARWIN_ENV)
  	    AFS_GUNLOCK();
  	    VOP_LOCK(tfile->vnode, LK_EXCLUSIVE, current_proc());
***************
*** 826,832 ****
  	    }
  	}
  	/* otherwise we've read some, fixup length, etc and continue with next seg */
! 	len = len - tuio.afsio_resid;	/* compute amount really transferred */
  	trimlen = len;
  	afsio_skip(auio, trimlen);	/* update input uio structure */
  	totalLength -= len;
--- 872,878 ----
  	    }
  	}
  	/* otherwise we've read some, fixup length, etc and continue with next seg */
! 	len = len - AFS_UIO_RESID(tuiop);	/* compute amount really transferred */
  	trimlen = len;
  	afsio_skip(auio, trimlen);	/* update input uio structure */
  	totalLength -= len;
***************
*** 854,860 ****
--- 900,911 ----
      if (!noLock)
  	ReleaseReadLock(&avc->lock);
  
+ #ifdef AFS_DARWIN80_ENV
+     if (tuiop)
+        uio_free(tuiop);
+ #else
      osi_FreeSmallSpace(tvec);
+ #endif
      error = afs_CheckCode(error, &treq, 13);
      return error;
  }
Index: openafs/src/afs/VNOPS/afs_vnop_readdir.c
diff -c openafs/src/afs/VNOPS/afs_vnop_readdir.c:1.24.2.6 openafs/src/afs/VNOPS/afs_vnop_readdir.c:1.24.2.7
*** openafs/src/afs/VNOPS/afs_vnop_readdir.c:1.24.2.6	Sun Oct  2 22:46:32 2005
--- openafs/src/afs/VNOPS/afs_vnop_readdir.c	Wed Oct  5 01:58:31 2005
***************
*** 23,29 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_readdir.c,v 1.24.2.6 2005/10/03 02:46:32 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 23,29 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_readdir.c,v 1.24.2.7 2005/10/05 05:58:31 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 143,149 ****
  #else
  struct min_direct {		/* miniature direct structure */
      /* If struct direct changes, this must too */
! #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
      afs_uint32 d_fileno;
      u_short d_reclen;
      u_char d_type;
--- 143,154 ----
  #else
  struct min_direct {		/* miniature direct structure */
      /* If struct direct changes, this must too */
! #if defined(AFS_DARWIN80_ENV)
!     ino_t d_fileno;
!     u_short d_reclen;
!     u_char d_type;
!     u_char d_namlen;
! #elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
      afs_uint32 d_fileno;
      u_short d_reclen;
      u_char d_type;
***************
*** 626,632 ****
  	*eofp = 0;
  #endif
      if (AfsLargeFileUio(auio)	/* file is large than 2 GB */
! 	||AfsLargeFileSize(auio->uio_offset, auio->uio_resid))
  	return EFBIG;
  
      if ((code = afs_InitReq(&treq, acred))) {
--- 631,637 ----
  	*eofp = 0;
  #endif
      if (AfsLargeFileUio(auio)	/* file is large than 2 GB */
! 	||AfsLargeFileSize(AFS_UIO_OFFSET(auio), AFS_UIO_RESID(auio)))
  	return EFBIG;
  
      if ((code = afs_InitReq(&treq, acred))) {
***************
*** 710,716 ****
      auio->uio_fpflags = 0;
  #endif
      while (code == 0) {
! 	origOffset = auio->afsio_offset;
  	/* scan for the next interesting entry scan for in-use blob otherwise up point at
  	 * this blob note that ode, if non-zero, also represents a held dir page */
  	if (!(us = BlobScan(tdc, (origOffset >> 5)))
--- 715,721 ----
      auio->uio_fpflags = 0;
  #endif
      while (code == 0) {
! 	origOffset = AFS_UIO_OFFSET(auio);
  	/* scan for the next interesting entry scan for in-use blob otherwise up point at
  	 * this blob note that ode, if non-zero, also represents a held dir page */
  	if (!(us = BlobScan(tdc, (origOffset >> 5)))
***************
*** 722,728 ****
  		sdirEntry->d_fileno =
  		    (avc->fid.Fid.Volume << 16) + ntohl(ode->fid.vnode);
  		FIXUPSTUPIDINODE(sdirEntry->d_fileno);
! 		sdirEntry->d_reclen = rlen = auio->afsio_resid;
  		sdirEntry->d_namlen = o_slen;
  #if defined(AFS_SUN5_ENV) || defined(AFS_AIX32_ENV) || defined(AFS_HPUX100_ENV)
  		sdirEntry->d_off = origOffset;
--- 727,733 ----
  		sdirEntry->d_fileno =
  		    (avc->fid.Fid.Volume << 16) + ntohl(ode->fid.vnode);
  		FIXUPSTUPIDINODE(sdirEntry->d_fileno);
! 		sdirEntry->d_reclen = rlen = AFS_UIO_RESID(auio);
  		sdirEntry->d_namlen = o_slen;
  #if defined(AFS_SUN5_ENV) || defined(AFS_AIX32_ENV) || defined(AFS_HPUX100_ENV)
  		sdirEntry->d_off = origOffset;
***************
*** 752,762 ****
  #if defined(AFS_SUN5_ENV)
  					len, origOffset);
  #else
! 					auio->afsio_resid, origOffset);
  #endif
  #endif /* AFS_HPUX_ENV */
  #if !defined(AFS_SUN5_ENV)
! 		auio->afsio_resid = 0;
  #endif
  	    } else {
  		/* nothin to hand over */
--- 757,767 ----
  #if defined(AFS_SUN5_ENV)
  					len, origOffset);
  #else
! 					AFS_UIO_RESID(auio), origOffset);
  #endif
  #endif /* AFS_HPUX_ENV */
  #if !defined(AFS_SUN5_ENV)
! 		AFS_UIO_SETRESID(auio, 0);
  #endif
  	    } else {
  		/* nothin to hand over */
***************
*** 780,788 ****
  #ifdef	AFS_SGI53_ENV
  	dirsiz =
  	    use64BitDirent ? DIRENTSIZE(n_slen) : IRIX5_DIRENTSIZE(n_slen);
! 	if (dirsiz >= (auio->afsio_resid - len)) {
  #else
! 	if (DIRSIZ_LEN(n_slen) >= (auio->afsio_resid - len)) {
  #endif /* AFS_SGI53_ENV */
  	    /* No can do no more now; ya know... at this time */
  	    DRelease((struct buffer *)nde, 0);	/* can't use this one. */
--- 785,793 ----
  #ifdef	AFS_SGI53_ENV
  	dirsiz =
  	    use64BitDirent ? DIRENTSIZE(n_slen) : IRIX5_DIRENTSIZE(n_slen);
! 	if (dirsiz >= (AFS_UIO_RESID(auio) - len)) {
  #else
! 	if (DIRSIZ_LEN(n_slen) >= (AFS_UIO_RESID(auio) - len)) {
  #endif /* AFS_SGI53_ENV */
  	    /* No can do no more now; ya know... at this time */
  	    DRelease((struct buffer *)nde, 0);	/* can't use this one. */
***************
*** 791,797 ****
  		sdirEntry->d_fileno =
  		    (avc->fid.Fid.Volume << 16) + ntohl(ode->fid.vnode);
  		FIXUPSTUPIDINODE(sdirEntry->d_fileno);
! 		sdirEntry->d_reclen = rlen = auio->afsio_resid;
  		sdirEntry->d_namlen = o_slen;
  #if defined(AFS_SUN5_ENV) || defined(AFS_AIX32_ENV) || defined(AFS_HPUX100_ENV)
  		sdirEntry->d_off = origOffset;
--- 796,802 ----
  		sdirEntry->d_fileno =
  		    (avc->fid.Fid.Volume << 16) + ntohl(ode->fid.vnode);
  		FIXUPSTUPIDINODE(sdirEntry->d_fileno);
! 		sdirEntry->d_reclen = rlen = AFS_UIO_RESID(auio);
  		sdirEntry->d_namlen = o_slen;
  #if defined(AFS_SUN5_ENV) || defined(AFS_AIX32_ENV) || defined(AFS_HPUX100_ENV)
  		sdirEntry->d_off = origOffset;
***************
*** 819,830 ****
  #else /* AFS_HPUX_ENV */
  		code =
  		    afs_readdir_move(ode, avc, auio, o_slen,
! 				     auio->afsio_resid, origOffset);
  #endif /* AFS_HPUX_ENV */
  		/* this next line used to be AFSVFS40 or AIX 3.1, but is
  		 * really generic */
! 		auio->afsio_offset = origOffset;
! 		auio->afsio_resid = 0;
  	    } else {		/* trouble, can't give anything to the user! */
  		/* even though he has given us a buffer, 
  		 * even though we have something to give us,
--- 824,835 ----
  #else /* AFS_HPUX_ENV */
  		code =
  		    afs_readdir_move(ode, avc, auio, o_slen,
! 				     AFS_UIO_RESID(auio), origOffset);
  #endif /* AFS_HPUX_ENV */
  		/* this next line used to be AFSVFS40 or AIX 3.1, but is
  		 * really generic */
! 		AFS_UIO_SETOFFSET(auio, origOffset);
! 		AFS_UIO_SETRESID(auio, 0);
  	    } else {		/* trouble, can't give anything to the user! */
  		/* even though he has given us a buffer, 
  		 * even though we have something to give us,
***************
*** 885,892 ****
  	if (ode)
  	    DRelease((struct buffer *)ode, 0);
  	ode = nde;
! 	auio->afsio_offset =
! 	    (afs_int32) ((us + afs_dir_NameBlobs(nde->name)) << 5);
      }
      if (ode)
  	DRelease((struct buffer *)ode, 0);
--- 890,896 ----
  	if (ode)
  	    DRelease((struct buffer *)ode, 0);
  	ode = nde;
! 	AFS_UIO_SETOFFSET(auio, (afs_int32) ((us + afs_dir_NameBlobs(nde->name)) << 5));
      }
      if (ode)
  	DRelease((struct buffer *)ode, 0);
***************
*** 1000,1006 ****
      auio->uio_fpflags = 0;
  #endif
      while (code == 0) {
! 	origOffset = auio->afsio_offset;
  
  	/* scan for the next interesting entry scan for in-use blob otherwise up point at
  	 * this blob note that ode, if non-zero, also represents a held dir page */
--- 1004,1010 ----
      auio->uio_fpflags = 0;
  #endif
      while (code == 0) {
! 	origOffset = AFS_UIO_OFFSET(auio);
  
  	/* scan for the next interesting entry scan for in-use blob otherwise up point at
  	 * this blob note that ode, if non-zero, also represents a held dir page */
***************
*** 1013,1019 ****
  		sdirEntry->d_fileno =
  		    (avc->fid.Fid.Volume << 16) + ntohl(ode->fid.vnode);
  		FIXUPSTUPIDINODE(sdirEntry->d_fileno);
! 		sdirEntry->d_reclen = rlen = auio->afsio_resid;
  		sdirEntry->d_namlen = o_slen;
  		sdirEntry->d_off = origOffset;
  		AFS_UIOMOVE((char *)sdirEntry, sizeof(*sdirEntry), UIO_READ,
--- 1017,1023 ----
  		sdirEntry->d_fileno =
  		    (avc->fid.Fid.Volume << 16) + ntohl(ode->fid.vnode);
  		FIXUPSTUPIDINODE(sdirEntry->d_fileno);
! 		sdirEntry->d_reclen = rlen = AFS_UIO_RESID(auio);
  		sdirEntry->d_namlen = o_slen;
  		sdirEntry->d_off = origOffset;
  		AFS_UIOMOVE((char *)sdirEntry, sizeof(*sdirEntry), UIO_READ,
***************
*** 1040,1048 ****
  #else
  		code =
  		    afs_readdir_move(ode, avc, auio, o_slen,
! 				     auio->afsio_resid, origOffset);
  #endif /* AFS_HPUX_ENV */
! 		auio->afsio_resid = 0;
  	    } else {
  		/* nothin to hand over */
  	    }
--- 1044,1052 ----
  #else
  		code =
  		    afs_readdir_move(ode, avc, auio, o_slen,
! 				     AFS_UIO_RESID(auio), origOffset);
  #endif /* AFS_HPUX_ENV */
! 		AFS_UIO_SETRESID(auio, 0);
  	    } else {
  		/* nothin to hand over */
  	    }
***************
*** 1062,1068 ****
  #else
  	n_slen = strlen(nde->name);
  #endif
! 	if (NDIRSIZ_LEN(n_slen) >= (auio->afsio_resid - len)) {
  	    /* No can do no more now; ya know... at this time */
  	    DRelease(nde, 0);	/* can't use this one. */
  	    if (len) {
--- 1066,1072 ----
  #else
  	n_slen = strlen(nde->name);
  #endif
! 	if (NDIRSIZ_LEN(n_slen) >= (AFS_UIO_RESID(auio) - len)) {
  	    /* No can do no more now; ya know... at this time */
  	    DRelease(nde, 0);	/* can't use this one. */
  	    if (len) {
***************
*** 1070,1076 ****
  		sdirEntry->d_fileno =
  		    (avc->fid.Fid.Volume << 16) + ntohl(ode->fid.vnode);
  		FIXUPSTUPIDINODE(sdirEntry->d_fileno);
! 		sdirEntry->d_reclen = rlen = auio->afsio_resid;
  		sdirEntry->d_namlen = o_slen;
  		sdirEntry->d_off = origOffset;
  		AFS_UIOMOVE((char *)sdirEntry, sizeof(*sdirEntry), UIO_READ,
--- 1074,1080 ----
  		sdirEntry->d_fileno =
  		    (avc->fid.Fid.Volume << 16) + ntohl(ode->fid.vnode);
  		FIXUPSTUPIDINODE(sdirEntry->d_fileno);
! 		sdirEntry->d_reclen = rlen = AFS_UIO_RESID(auio);
  		sdirEntry->d_namlen = o_slen;
  		sdirEntry->d_off = origOffset;
  		AFS_UIOMOVE((char *)sdirEntry, sizeof(*sdirEntry), UIO_READ,
***************
*** 1096,1106 ****
  #else
  		code =
  		    afs_readdir_move(ode, avc, auio, o_slen,
! 				     auio->afsio_resid, origOffset);
  #endif /* AFS_HPUX_ENV */
  		/* this next line used to be AFSVFS40 or AIX 3.1, but is really generic */
! 		auio->afsio_offset = origOffset;
! 		auio->afsio_resid = 0;
  	    } else {		/* trouble, can't give anything to the user! */
  		/* even though he has given us a buffer, 
  		 * even though we have something to give us,
--- 1100,1110 ----
  #else
  		code =
  		    afs_readdir_move(ode, avc, auio, o_slen,
! 				     AFS_UIO_RESID(auio), origOffset);
  #endif /* AFS_HPUX_ENV */
  		/* this next line used to be AFSVFS40 or AIX 3.1, but is really generic */
! 		AFS_UIO_SETOFFSET(auio, origOffset);
! 		AFS_UIO_SETRESID(auio, 0);
  	    } else {		/* trouble, can't give anything to the user! */
  		/* even though he has given us a buffer, 
  		 * even though we have something to give us,
***************
*** 1153,1159 ****
  	if (ode)
  	    DRelease(ode, 0);
  	ode = nde;
! 	auio->afsio_offset = ((us + afs_dir_NameBlobs(nde->name)) << 5);
      }
      if (ode)
  	DRelease(ode, 0);
--- 1157,1163 ----
  	if (ode)
  	    DRelease(ode, 0);
  	ode = nde;
! 	AFS_UIO_OFFSET(auio) = ((us + afs_dir_NameBlobs(nde->name)) << 5);
      }
      if (ode)
  	DRelease(ode, 0);
Index: openafs/src/afs/VNOPS/afs_vnop_remove.c
diff -c openafs/src/afs/VNOPS/afs_vnop_remove.c:1.31.2.9 openafs/src/afs/VNOPS/afs_vnop_remove.c:1.31.2.10
*** openafs/src/afs/VNOPS/afs_vnop_remove.c:1.31.2.9	Mon May 30 00:05:44 2005
--- openafs/src/afs/VNOPS/afs_vnop_remove.c	Wed Oct  5 01:58:31 2005
***************
*** 21,27 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_remove.c,v 1.31.2.9 2005/05/30 04:05:44 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 21,27 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_remove.c,v 1.31.2.10 2005/10/05 05:58:31 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 362,381 ****
      osi_dnlc_remove(adp, aname, tvc);
  
      Tadp1 = adp;
      Tadpr = VREFCOUNT(adp);
      Ttvc = tvc;
      Tnam = aname;
      Tnam1 = 0;
      if (tvc)
  	Ttvcr = VREFCOUNT(tvc);
  #ifdef	AFS_AIX_ENV
!     if (tvc && (VREFCOUNT(tvc) > 2) && tvc->opens > 0
! 	&& !(tvc->states & CUnlinked))
  #else
!     if (tvc && (VREFCOUNT(tvc) > 1) && tvc->opens > 0
! 	&& !(tvc->states & CUnlinked))
  #endif
-     {
  	char *unlname = afs_newname();
  
  	ReleaseWriteLock(&adp->lock);
--- 362,384 ----
      osi_dnlc_remove(adp, aname, tvc);
  
      Tadp1 = adp;
+ #ifndef AFS_DARWIN80_ENV
      Tadpr = VREFCOUNT(adp);
+ #endif
      Ttvc = tvc;
      Tnam = aname;
      Tnam1 = 0;
      if (tvc)
+ #ifndef AFS_DARWIN80_ENV
  	Ttvcr = VREFCOUNT(tvc);
+ #endif
  #ifdef	AFS_AIX_ENV
!     if (tvc && VREFCOUNT_GT(tvc, 2) && tvc->opens > 0
! 	&& !(tvc->states & CUnlinked)) {
  #else
!     if (tvc && VREFCOUNT_GT(tvc, 1) && tvc->opens > 0
! 	&& !(tvc->states & CUnlinked)) {
  #endif
  	char *unlname = afs_newname();
  
  	ReleaseWriteLock(&adp->lock);
***************
*** 401,406 ****
--- 404,410 ----
  	code = afsremove(adp, tdc, tvc, aname, acred, &treq);
      }
      afs_PutFakeStat(&fakestate);
+     osi_Assert(!WriteLocked(&adp->lock) || !(adp->lock.pid_writer != MyPidxx));
      return code;
  }
  
***************
*** 436,442 ****
  	    cred = avc->uncred;
  	    avc->uncred = NULL;
  
! #ifdef AFS_DARWIN_ENV
  	    VREF(AFSTOV(avc));
  #else
  	    VN_HOLD(AFSTOV(avc));
--- 440,446 ----
  	    cred = avc->uncred;
  	    avc->uncred = NULL;
  
! #if defined(AFS_DARWIN_ENV) && !defined(AFS_DARWIN80_ENV)
  	    VREF(AFSTOV(avc));
  #else
  	    VN_HOLD(AFSTOV(avc));
Index: openafs/src/afs/VNOPS/afs_vnop_strategy.c
diff -c openafs/src/afs/VNOPS/afs_vnop_strategy.c:1.18.2.2 openafs/src/afs/VNOPS/afs_vnop_strategy.c:1.18.2.4
*** openafs/src/afs/VNOPS/afs_vnop_strategy.c:1.18.2.2	Sat Apr 23 20:58:06 2005
--- openafs/src/afs/VNOPS/afs_vnop_strategy.c	Wed Oct 12 02:17:27 2005
***************
*** 16,24 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_strategy.c,v 1.18.2.2 2005/04/24 00:58:06 shadow Exp $");
  
! #if !defined(AFS_HPUX_ENV) && !defined(AFS_SGI_ENV) && !defined(AFS_LINUX20_ENV)
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 16,24 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_strategy.c,v 1.18.2.4 2005/10/12 06:17:27 shadow Exp $");
  
! #if !defined(AFS_HPUX_ENV) && !defined(AFS_SGI_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN80_ENV)
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 40,45 ****
--- 40,47 ----
  {
      register afs_int32 code;
      struct uio tuio;
+     struct uio *tuiop = &tuio;
+     struct iovec tiovec[1];
      register struct vcache *tvc = VTOAFS(abp->b_vp);
      register afs_int32 len = abp->b_bcount;
  #if	!defined(AFS_SUN5_ENV) && !defined(AFS_OSF_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_XBSD_ENV)
***************
*** 49,55 ****
      struct AFS_UCRED *credp = u.u_cred;
  #endif
  #endif
-     struct iovec tiovec[1];
  
      AFS_STATCNT(afs_ustrategy);
  #ifdef	AFS_AIX41_ENV
--- 51,56 ----
***************
*** 80,91 ****
  	tuio.afsio_iovcnt = 1;
  #if	defined(AFS_OSF_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_XBSD_ENV)
  #ifdef AFS_64BIT_CLIENT
  	tuio.afsio_offset = (afs_offs_t) dbtob(abp->b_blkno);
  #else /* AFS_64BIT_CLIENT */
  	tuio.afsio_offset = (u_int) dbtob(abp->b_blkno);
- #if	defined(AFS_SUN5_ENV)
- 	tuio._uio_offset._p._u = 0;
- #endif
  #endif /* AFS_64BIT_CLIENT */
  #else
  	tuio.afsio_offset = DEV_BSIZE * abp->b_blkno;
--- 81,93 ----
  	tuio.afsio_iovcnt = 1;
  #if	defined(AFS_OSF_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_XBSD_ENV)
  #ifdef AFS_64BIT_CLIENT
+ #ifdef AFS_SUN5_ENV
+ 	tuio.afsio_offset = (afs_offs_t) ldbtob(abp->b_lblkno);
+ #else
  	tuio.afsio_offset = (afs_offs_t) dbtob(abp->b_blkno);
+ #endif
  #else /* AFS_64BIT_CLIENT */
  	tuio.afsio_offset = (u_int) dbtob(abp->b_blkno);
  #endif /* AFS_64BIT_CLIENT */
  #else
  	tuio.afsio_offset = DEV_BSIZE * abp->b_blkno;
***************
*** 138,149 ****
  	tuio.afsio_iovcnt = 1;
  #if	defined(AFS_OSF_ENV) || defined(AFS_SUN5_ENV)
  #ifdef AFS_64BIT_CLIENT
  	tuio.afsio_offset = (afs_offs_t) dbtob(abp->b_blkno);
  #else /* AFS_64BIT_CLIENT */
  	tuio.afsio_offset = (u_int) dbtob(abp->b_blkno);
- #ifdef	AFS_SUN5_ENV
- 	tuio._uio_offset._p._u = 0;
- #endif
  #endif /* AFS_64BIT_CLIENT */
  #ifdef	AFS_SUN5_ENV
  #ifdef	AFS_SUN59_ENV
--- 140,152 ----
  	tuio.afsio_iovcnt = 1;
  #if	defined(AFS_OSF_ENV) || defined(AFS_SUN5_ENV)
  #ifdef AFS_64BIT_CLIENT
+ #ifdef AFS_SUN5_ENV
+ 	tuio.afsio_offset = (afs_offs_t) ldbtob(abp->b_lblkno);
+ #else
  	tuio.afsio_offset = (afs_offs_t) dbtob(abp->b_blkno);
+ #endif
  #else /* AFS_64BIT_CLIENT */
  	tuio.afsio_offset = (u_int) dbtob(abp->b_blkno);
  #endif /* AFS_64BIT_CLIENT */
  #ifdef	AFS_SUN5_ENV
  #ifdef	AFS_SUN59_ENV
Index: openafs/src/afs/VNOPS/afs_vnop_symlink.c
diff -c openafs/src/afs/VNOPS/afs_vnop_symlink.c:1.19.2.4 openafs/src/afs/VNOPS/afs_vnop_symlink.c:1.19.2.5
*** openafs/src/afs/VNOPS/afs_vnop_symlink.c:1.19.2.4	Sun Jan 30 22:49:15 2005
--- openafs/src/afs/VNOPS/afs_vnop_symlink.c	Fri Oct 14 22:33:12 2005
***************
*** 22,28 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_symlink.c,v 1.19.2.4 2005/01/31 03:49:15 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 22,28 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_symlink.c,v 1.19.2.5 2005/10/15 02:33:12 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 191,196 ****
--- 191,202 ----
       * no one can get a pointer to the new cache entry until we release 
       * the xvcache lock. */
      tvc = afs_NewVCache(&newFid, hostp);
+     if (!tvc)
+     {
+ 	code = -2;
+ 	ReleaseWriteLock(&afs_xvcache);
+ 	goto done;
+     }
      ObtainWriteLock(&tvc->lock, 157);
      ObtainWriteLock(&afs_xcbhash, 500);
      tvc->states |= CStatd;	/* have valid info */
Index: openafs/src/afs/VNOPS/afs_vnop_write.c
diff -c openafs/src/afs/VNOPS/afs_vnop_write.c:1.36.2.6 openafs/src/afs/VNOPS/afs_vnop_write.c:1.36.2.8
*** openafs/src/afs/VNOPS/afs_vnop_write.c:1.36.2.6	Sun Oct  2 22:55:33 2005
--- openafs/src/afs/VNOPS/afs_vnop_write.c	Thu Oct 13 14:23:42 2005
***************
*** 21,27 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_write.c,v 1.36.2.6 2005/10/03 02:55:33 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 21,27 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_write.c,v 1.36.2.8 2005/10/13 18:23:42 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 105,112 ****
--- 105,117 ----
      volatile
  #endif
      afs_int32 error;
+ #ifdef AFS_DARWIN80_ENV
+     uio_t tuiop;
+ #else
      struct uio tuio;
+     struct uio *tuiop = &tuio;
      struct iovec *tvec;		/* again, should have define */
+ #endif
      register afs_int32 code;
      struct vrequest treq;
  
***************
*** 118,125 ****
      if ((code = afs_InitReq(&treq, acred)))
  	return code;
      /* otherwise we read */
!     totalLength = auio->afsio_resid;
!     filePos = auio->afsio_offset;
      error = 0;
      transferLength = 0;
      afs_Trace4(afs_iclSetp, CM_TRACE_WRITE, ICL_TYPE_POINTER, avc,
--- 123,130 ----
      if ((code = afs_InitReq(&treq, acred)))
  	return code;
      /* otherwise we read */
!     totalLength = AFS_UIO_RESID(auio);
!     filePos = AFS_UIO_OFFSET(auio);
      error = 0;
      transferLength = 0;
      afs_Trace4(afs_iclSetp, CM_TRACE_WRITE, ICL_TYPE_POINTER, avc,
***************
*** 141,148 ****
  	 */
  	osi_Assert(filePos <= avc->m.Length);
  	diff = avc->m.Length - filePos;
! 	auio->afsio_resid = MIN(totalLength, diff);
! 	totalLength = auio->afsio_resid;
      }
  #else
      if (aio & IO_APPEND) {
--- 146,153 ----
  	 */
  	osi_Assert(filePos <= avc->m.Length);
  	diff = avc->m.Length - filePos;
! 	AFS_UIO_SETRESID(auio, MIN(totalLength, diff));
! 	totalLength = AFS_UIO_RESID(auio);
      }
  #else
      if (aio & IO_APPEND) {
***************
*** 150,156 ****
  #if	defined(AFS_SUN56_ENV)
  	auio->uio_loffset = 0;
  #endif
! 	filePos = auio->afsio_offset = avc->m.Length;
      }
  #endif
      /*
--- 155,162 ----
  #if	defined(AFS_SUN56_ENV)
  	auio->uio_loffset = 0;
  #endif
! 	filePos = avc->m.Length;
! 	AFS_UIO_SETOFFSET(auio, filePos);
      }
  #endif
      /*
***************
*** 184,190 ****
--- 190,198 ----
      afs_FakeOpen(avc);
  #endif
      avc->states |= CDirty;
+ #ifndef AFS_DARWIN80_ENV
      tvec = (struct iovec *)osi_AllocSmallSpace(sizeof(struct iovec));
+ #endif
      while (totalLength > 0) {
  	/* 
  	 *  The following line is necessary because afs_GetDCache with
***************
*** 198,204 ****
  	    if (tdc)
  		ObtainWriteLock(&tdc->lock, 653);
  	} else if (afs_blocksUsed >
! 		   (CM_WAITFORDRAINPCT * afs_cacheBlocks) / 100) {
  	    tdc = afs_FindDCache(avc, filePos);
  	    if (tdc) {
  		ObtainWriteLock(&tdc->lock, 654);
--- 206,212 ----
  	    if (tdc)
  		ObtainWriteLock(&tdc->lock, 653);
  	} else if (afs_blocksUsed >
! 		   PERCENT(CM_WAITFORDRAINPCT, afs_cacheBlocks)) {
  	    tdc = afs_FindDCache(avc, filePos);
  	    if (tdc) {
  		ObtainWriteLock(&tdc->lock, 654);
***************
*** 212,221 ****
  	    if (!tdc) {
  		afs_MaybeWakeupTruncateDaemon();
  		while (afs_blocksUsed >
! 		       (CM_WAITFORDRAINPCT * afs_cacheBlocks) / 100) {
  		    ReleaseWriteLock(&avc->lock);
  		    if (afs_blocksUsed - afs_blocksDiscarded >
! 			(CM_WAITFORDRAINPCT * afs_cacheBlocks) / 100) {
  			afs_WaitForCacheDrain = 1;
  			afs_osi_Sleep(&afs_WaitForCacheDrain);
  		    }
--- 220,229 ----
  	    if (!tdc) {
  		afs_MaybeWakeupTruncateDaemon();
  		while (afs_blocksUsed >
! 		       PERCENT(CM_WAITFORDRAINPCT, afs_cacheBlocks)) {
  		    ReleaseWriteLock(&avc->lock);
  		    if (afs_blocksUsed - afs_blocksDiscarded >
! 			PERCENT(CM_WAITFORDRAINPCT, afs_cacheBlocks)) {
  			afs_WaitForCacheDrain = 1;
  			afs_osi_Sleep(&afs_WaitForCacheDrain);
  		    }
***************
*** 254,266 ****
  	     * as will fit */
  	    len = max - offset;
  	}
  	/* mung uio structure to be right for this transfer */
  	afsio_copy(auio, &tuio, tvec);
  	trimlen = len;
  	afsio_trim(&tuio, trimlen);
! 	tuio.afsio_offset = offset;
  
! 	code = afs_MemWriteUIO(tdc->f.inode, &tuio);
  	if (code) {
  	    void *mep;		/* XXX in prototype world is struct memCacheEntry * */
  	    error = code;
--- 262,280 ----
  	     * as will fit */
  	    len = max - offset;
  	}
+ 
+ #ifdef  AFS_DARWIN80_ENV
+ 	trimlen = len;
+ 	tuiop = afsio_darwin_partialcopy(auio, trimlen);
+ #else
  	/* mung uio structure to be right for this transfer */
  	afsio_copy(auio, &tuio, tvec);
  	trimlen = len;
  	afsio_trim(&tuio, trimlen);
! #endif
! 	AFS_UIO_SETOFFSET(tuiop, offset);
  
! 	code = afs_MemWriteUIO(tdc->f.inode, tuiop);
  	if (code) {
  	    void *mep;		/* XXX in prototype world is struct memCacheEntry * */
  	    error = code;
***************
*** 275,281 ****
  	    break;
  	}
  	/* otherwise we've written some, fixup length, etc and continue with next seg */
! 	len = len - tuio.afsio_resid;	/* compute amount really transferred */
  	tlen = len;
  	afsio_skip(auio, tlen);	/* advance auio over data written */
  	/* compute new file size */
--- 289,295 ----
  	    break;
  	}
  	/* otherwise we've written some, fixup length, etc and continue with next seg */
! 	len = len - AFS_UIO_RESID(tuiop);	/* compute amount really transferred */
  	tlen = len;
  	afsio_skip(auio, tlen);	/* advance auio over data written */
  	/* compute new file size */
***************
*** 323,329 ****
--- 337,347 ----
  	avc->vc_error = error;
      if (!noLock)
  	ReleaseWriteLock(&avc->lock);
+ #ifdef AFS_DARWIN80_ENV
+     uio_free(tuiop);
+ #else
      osi_FreeSmallSpace(tvec);
+ #endif
      error = afs_CheckCode(error, &treq, 6);
      return error;
  }
***************
*** 347,354 ****
--- 365,377 ----
      volatile
  #endif
      afs_int32 error;
+ #ifdef AFS_DARWIN80_ENV
+     uio_t tuiop;
+ #else
      struct uio tuio;
+     struct uio *tuiop = &tuio;
      struct iovec *tvec;		/* again, should have define */
+ #endif
      struct osi_file *tfile;
      register afs_int32 code;
      struct vrequest treq;
***************
*** 361,368 ****
      if ((code = afs_InitReq(&treq, acred)))
  	return code;
      /* otherwise we read */
!     totalLength = auio->afsio_resid;
!     filePos = auio->afsio_offset;
      error = 0;
      transferLength = 0;
      afs_Trace4(afs_iclSetp, CM_TRACE_WRITE, ICL_TYPE_POINTER, avc,
--- 384,391 ----
      if ((code = afs_InitReq(&treq, acred)))
  	return code;
      /* otherwise we read */
!     totalLength = AFS_UIO_RESID(auio);
!     filePos = AFS_UIO_OFFSET(auio);
      error = 0;
      transferLength = 0;
      afs_Trace4(afs_iclSetp, CM_TRACE_WRITE, ICL_TYPE_POINTER, avc,
***************
*** 384,391 ****
  	 */
  	osi_Assert(filePos <= avc->m.Length);
  	diff = avc->m.Length - filePos;
! 	auio->afsio_resid = MIN(totalLength, diff);
! 	totalLength = auio->afsio_resid;
      }
  #else
      if (aio & IO_APPEND) {
--- 407,414 ----
  	 */
  	osi_Assert(filePos <= avc->m.Length);
  	diff = avc->m.Length - filePos;
! 	AFS_UIO_SETRESID(auio, MIN(totalLength, diff));
! 	totalLength = AFS_UIO_RESID(auio);
      }
  #else
      if (aio & IO_APPEND) {
***************
*** 393,399 ****
  #if     defined(AFS_SUN56_ENV)
  	auio->uio_loffset = 0;
  #endif
! 	filePos = auio->afsio_offset = avc->m.Length;
      }
  #endif
      /*
--- 416,423 ----
  #if     defined(AFS_SUN56_ENV)
  	auio->uio_loffset = 0;
  #endif
! 	filePos = avc->m.Length;
! 	AFS_UIO_SETOFFSET(auio, avc->m.Length);
      }
  #endif
      /*
***************
*** 427,433 ****
--- 451,459 ----
      afs_FakeOpen(avc);
  #endif
      avc->states |= CDirty;
+ #ifndef AFS_DARWIN80_ENV
      tvec = (struct iovec *)osi_AllocSmallSpace(sizeof(struct iovec));
+ #endif
      while (totalLength > 0) {
  	/* 
  	 *  The following line is necessary because afs_GetDCache with
***************
*** 442,448 ****
  	    if (tdc)
  		ObtainWriteLock(&tdc->lock, 657);
  	} else if (afs_blocksUsed >
! 		   (CM_WAITFORDRAINPCT * afs_cacheBlocks) / 100) {
  	    tdc = afs_FindDCache(avc, filePos);
  	    if (tdc) {
  		ObtainWriteLock(&tdc->lock, 658);
--- 468,474 ----
  	    if (tdc)
  		ObtainWriteLock(&tdc->lock, 657);
  	} else if (afs_blocksUsed >
! 		   PERCENT(CM_WAITFORDRAINPCT, afs_cacheBlocks)) {
  	    tdc = afs_FindDCache(avc, filePos);
  	    if (tdc) {
  		ObtainWriteLock(&tdc->lock, 658);
***************
*** 456,465 ****
  	    if (!tdc) {
  		afs_MaybeWakeupTruncateDaemon();
  		while (afs_blocksUsed >
! 		       (CM_WAITFORDRAINPCT * afs_cacheBlocks) / 100) {
  		    ReleaseWriteLock(&avc->lock);
  		    if (afs_blocksUsed - afs_blocksDiscarded >
! 			(CM_WAITFORDRAINPCT * afs_cacheBlocks) / 100) {
  			afs_WaitForCacheDrain = 1;
  			afs_osi_Sleep(&afs_WaitForCacheDrain);
  		    }
--- 482,491 ----
  	    if (!tdc) {
  		afs_MaybeWakeupTruncateDaemon();
  		while (afs_blocksUsed >
! 		       PERCENT(CM_WAITFORDRAINPCT, afs_cacheBlocks)) {
  		    ReleaseWriteLock(&avc->lock);
  		    if (afs_blocksUsed - afs_blocksDiscarded >
! 			PERCENT(CM_WAITFORDRAINPCT, afs_cacheBlocks)) {
  			afs_WaitForCacheDrain = 1;
  			afs_osi_Sleep(&afs_WaitForCacheDrain);
  		    }
***************
*** 499,509 ****
  	     * as will fit */
  	    len = max - offset;
  	}
  	/* mung uio structure to be right for this transfer */
  	afsio_copy(auio, &tuio, tvec);
  	trimlen = len;
  	afsio_trim(&tuio, trimlen);
! 	tuio.afsio_offset = offset;
  #if defined(AFS_AIX41_ENV)
  	AFS_GUNLOCK();
  	code =
--- 525,542 ----
  	     * as will fit */
  	    len = max - offset;
  	}
+ 
+ #ifdef  AFS_DARWIN80_ENV
+ 	trimlen = len;
+ 	tuiop = afsio_darwin_partialcopy(auio, trimlen);
+ #else
  	/* mung uio structure to be right for this transfer */
  	afsio_copy(auio, &tuio, tvec);
  	trimlen = len;
  	afsio_trim(&tuio, trimlen);
! #endif
! 	AFS_UIO_SETOFFSET(tuiop, offset);
! 
  #if defined(AFS_AIX41_ENV)
  	AFS_GUNLOCK();
  	code =
***************
*** 563,568 ****
--- 596,605 ----
  	AFS_GUNLOCK();
  	code = osi_rdwr(tfile, &tuio, UIO_WRITE);
  	AFS_GLOCK();
+ #elif defined(AFS_DARWIN80_ENV)
+ 	AFS_GUNLOCK();
+ 	code = VNOP_WRITE(tfile->vnode, tuiop, 0, afs_osi_ctxtp);
+ 	AFS_GLOCK();
  #elif defined(AFS_DARWIN_ENV)
  	AFS_GUNLOCK();
  	VOP_LOCK(tfile->vnode, LK_EXCLUSIVE, current_proc());
***************
*** 600,606 ****
  	    break;
  	}
  	/* otherwise we've written some, fixup length, etc and continue with next seg */
! 	len = len - tuio.afsio_resid;	/* compute amount really transferred */
  	tlen = len;
  	afsio_skip(auio, tlen);	/* advance auio over data written */
  	/* compute new file size */
--- 637,643 ----
  	    break;
  	}
  	/* otherwise we've written some, fixup length, etc and continue with next seg */
! 	len = len - AFS_UIO_RESID(tuiop);	/* compute amount really transferred */
  	tlen = len;
  	afsio_skip(auio, tlen);	/* advance auio over data written */
  	/* compute new file size */
***************
*** 651,657 ****
--- 688,698 ----
  	avc->vc_error = error;
      if (!noLock)
  	ReleaseWriteLock(&avc->lock);
+ #ifdef AFS_DARWIN80_ENV
+     uio_free(tuiop);
+ #else
      osi_FreeSmallSpace(tvec);
+ #endif
  #ifndef	AFS_VM_RDWR_ENV
      /*
       * If write is implemented via VM, afs_fsync() is called from the high-level
Index: openafs/src/afsd/afsd.c
diff -c openafs/src/afsd/afsd.c:1.43.2.10.4.1 openafs/src/afsd/afsd.c:1.43.2.15
*** openafs/src/afsd/afsd.c:1.43.2.10.4.1	Thu Oct 13 17:01:49 2005
--- openafs/src/afsd/afsd.c	Sat Oct 15 11:23:39 2005
***************
*** 47,53 ****
    *                system problems, which can only be ameliorated by changing
    *                NINODE (or equivalent) and rebuilding the kernel.
    *		   This option is now disabled.
!   *	-logfile   Place where to put the logfile (default in <cache>/etc/AFSLog.
    *	-waitclose make close calls always synchronous (slows em down, tho)
    *	-files_per_subdir [n]	number of files per cache subdir. (def=2048)
    *	-shutdown  Shutdown afs daemons
--- 47,54 ----
    *                system problems, which can only be ameliorated by changing
    *                NINODE (or equivalent) and rebuilding the kernel.
    *		   This option is now disabled.
!   *	-logfile   [OBSOLETE] Place where to put the logfile (default in
!   *                <cache>/etc/AFSLog.
    *	-waitclose make close calls always synchronous (slows em down, tho)
    *	-files_per_subdir [n]	number of files per cache subdir. (def=2048)
    *	-shutdown  Shutdown afs daemons
***************
*** 57,63 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/afsd/afsd.c,v 1.43.2.10.4.1 2005/10/13 21:01:49 shadow Exp $");
  
  #define VFS 1
  
--- 58,64 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/afsd/afsd.c,v 1.43.2.15 2005/10/15 15:23:39 shadow Exp $");
  
  #define VFS 1
  
***************
*** 155,160 ****
--- 156,164 ----
  #include <sys/resource.h>
  #endif
  #ifdef AFS_DARWIN_ENV
+ #ifdef AFS_DARWIN80_ENV
+ #include <sys/ioctl.h>
+ #endif
  #include <mach/mach.h>
  /* Symbols from the DiskArbitration framework */
  kern_return_t DiskArbStart(mach_port_t *);
***************
*** 185,191 ****
  
  
  #define CACHEINFOFILE   "cacheinfo"
- #define	AFSLOGFILE	"AFSLog"
  #define	DCACHEFILE	"CacheItems"
  #define	VOLINFOFILE	"VolumeItems"
  #define CELLINFOFILE	"CellItems"
--- 189,194 ----
***************
*** 230,243 ****
  afs_int32 enable_rxbind = 0;
  afs_int32 afs_shutdown = 0;
  afs_int32 cacheBlocks;		/*Num blocks in the cache */
! afs_int32 cacheFiles = 1000;	/*Optimal # of files in workstation cache */
! afs_int32 cacheStatEntries = 300;	/*Number of stat cache entries */
  char cacheBaseDir[1024];	/*Where the workstation AFS cache lives */
  char confDir[1024];		/*Where the workstation AFS configuration lives */
  char fullpn_DCacheFile[1024];	/*Full pathname of DCACHEFILE */
  char fullpn_VolInfoFile[1024];	/*Full pathname of VOLINFOFILE */
  char fullpn_CellInfoFile[1024];	/*Full pathanem of CELLINFOFILE */
- char fullpn_AFSLogFile[1024];	/*Full pathname of AFSLOGFILE */
  char fullpn_CacheInfo[1024];	/*Full pathname of CACHEINFO */
  char fullpn_VFile[1024];	/*Full pathname of data cache files */
  char *vFilePtr;			/*Ptr to the number part of above pathname */
--- 233,245 ----
  afs_int32 enable_rxbind = 0;
  afs_int32 afs_shutdown = 0;
  afs_int32 cacheBlocks;		/*Num blocks in the cache */
! afs_int32 cacheFiles;	/*Optimal # of files in workstation cache */
! afs_int32 cacheStatEntries;	/*Number of stat cache entries */
  char cacheBaseDir[1024];	/*Where the workstation AFS cache lives */
  char confDir[1024];		/*Where the workstation AFS configuration lives */
  char fullpn_DCacheFile[1024];	/*Full pathname of DCACHEFILE */
  char fullpn_VolInfoFile[1024];	/*Full pathname of VOLINFOFILE */
  char fullpn_CellInfoFile[1024];	/*Full pathanem of CELLINFOFILE */
  char fullpn_CacheInfo[1024];	/*Full pathname of CACHEINFO */
  char fullpn_VFile[1024];	/*Full pathname of data cache files */
  char *vFilePtr;			/*Ptr to the number part of above pathname */
***************
*** 246,251 ****
--- 248,254 ----
  int sawCacheBlocks = 0;
  int sawDCacheSize = 0;
  int sawBiod = 0;
+ int sawCacheStatEntries = 0;
  char cacheMountDir[1024];	/*Mount directory for AFS */
  char rootVolume[64] = "root.afs";	/*AFS root volume name */
  afs_int32 cacheSetTime = FALSE;	/*Keep checking time to avoid drift? */
***************
*** 260,267 ****
  static int nFilesPerDir = 2048;	/* # files per cache dir */
  static int nDaemons = 2;	/* Number of background daemons */
  static int chunkSize = 0;	/* 2^chunkSize bytes per chunk */
! static int dCacheSize = 300;	/* # of dcache entries */
! static int vCacheSize = 50;	/* # of volume cache entries */
  static int rootVolSet = 0;	/*True if root volume name explicitly set */
  int addrNum;			/*Cell server address index being printed */
  static int cacheFlags = 0;	/*Flags to cache manager */
--- 263,270 ----
  static int nFilesPerDir = 2048;	/* # files per cache dir */
  static int nDaemons = 2;	/* Number of background daemons */
  static int chunkSize = 0;	/* 2^chunkSize bytes per chunk */
! static int dCacheSize;		/* # of dcache entries */
! static int vCacheSize = 200;	/* # of volume cache entries */
  static int rootVolSet = 0;	/*True if root volume name explicitly set */
  int addrNum;			/*Cell server address index being printed */
  static int cacheFlags = 0;	/*Flags to cache manager */
***************
*** 459,465 ****
  	totalblks /= (1024 / bsize);
      }
  
!     mint = totalblks - ((totalblks * 5) / 100);
      if (cs > mint) {
  	printf
  	    ("Cache size (%d) must be less than 95%% of partition size (which is %d). Lower cache size\n",
--- 462,468 ----
  	totalblks /= (1024 / bsize);
      }
  
!     mint = totalblks / 100 * 95;
      if (cs > mint) {
  	printf
  	    ("Cache size (%d) must be less than 95%% of partition size (which is %d). Lower cache size\n",
***************
*** 587,593 ****
      /* Build the new cache subdirectory */
      sprintf(dir, "%s/D%d", basename, dirNum);
  
!     if (afsd_verbose)
  	printf("%s: Creating cache subdir '%s'\n", rn, dir);
  
      if ((ret = mkdir(dir, 0700)) != 0) {
--- 590,596 ----
      /* Build the new cache subdirectory */
      sprintf(dir, "%s/D%d", basename, dirNum);
  
!     if (afsd_debug)
  	printf("%s: Creating cache subdir '%s'\n", rn, dir);
  
      if ((ret = mkdir(dir, 0700)) != 0) {
***************
*** 657,663 ****
      int cfd;			/*File descriptor to AFS cache file */
      int closeResult;		/*Result of close() */
  
!     if (afsd_verbose)
  	printf("%s: Creating cache file '%s'\n", rn, fname);
      cfd = open(fname, createAndTrunc, ownerRWmode);
      if (cfd <= 0) {
--- 660,666 ----
      int cfd;			/*File descriptor to AFS cache file */
      int closeResult;		/*Result of close() */
  
!     if (afsd_debug)
  	printf("%s: Creating cache file '%s'\n", rn, fname);
      cfd = open(fname, createAndTrunc, ownerRWmode);
      if (cfd <= 0) {
***************
*** 689,701 ****
  CreateFileIfMissing(char *fullpn, int missing)
  {
      if (missing) {
- 	if (afsd_verbose)
- 	    printf("CreateFileIfMissing: Creating '%s'\n", fullpn);
  	if (CreateCacheFile(fullpn, NULL))
  	    printf("CreateFileIfMissing: Can't create '%s'\n", fullpn);
      }
  }
  
  /*-----------------------------------------------------------------------------
    * SweepAFSCache
    *
--- 692,717 ----
  CreateFileIfMissing(char *fullpn, int missing)
  {
      if (missing) {
  	if (CreateCacheFile(fullpn, NULL))
  	    printf("CreateFileIfMissing: Can't create '%s'\n", fullpn);
      }
  }
  
+ static void
+ UnlinkUnwantedFile(char *rn, char *fullpn_FileToDelete, char *fileToDelete)
+ {
+     if (unlink(fullpn_FileToDelete)) {
+ 	if ((errno == EISDIR || errno == EPERM) && *fileToDelete == 'D') {
+ 	    if (rmdir(fullpn_FileToDelete)) {
+ 		printf("%s: Can't rmdir '%s', errno is %d\n", rn,
+ 		       fullpn_FileToDelete, errno);
+ 	    }
+ 	} else
+ 	    printf("%s: Can't unlink '%s', errno is %d\n", rn,
+ 		   fullpn_FileToDelete, errno);
+     }
+ }
+ 
  /*-----------------------------------------------------------------------------
    * SweepAFSCache
    *
***************
*** 902,917 ****
  	    sprintf(fileToDelete, "%s", currp->d_name);
  	    if (afsd_verbose)
  		printf("%s: Deleting '%s'\n", rn, fullpn_FileToDelete);
! 	    if (unlink(fullpn_FileToDelete)) {
! 		if (errno == EISDIR && *fileToDelete == 'D') {
! 		    if (rmdir(fullpn_FileToDelete)) {
! 			printf("%s: Can't rmdir '%s', errno is %d\n", rn,
! 			       fullpn_FileToDelete, errno);
! 		    }
! 		} else
! 		    printf("%s: Can't unlink '%s', errno is %d\n", rn,
! 			   fullpn_FileToDelete, errno);
! 	    }
  	}
      }
  
--- 918,924 ----
  	    sprintf(fileToDelete, "%s", currp->d_name);
  	    if (afsd_verbose)
  		printf("%s: Deleting '%s'\n", rn, fullpn_FileToDelete);
! 	    UnlinkUnwantedFile(rn, fullpn_FileToDelete, fileToDelete);
  	}
      }
  
***************
*** 1021,1036 ****
  	/* Remove any directories >= maxDir -- they should be empty */
  	for (; highDir >= maxDir; highDir--) {
  	    sprintf(fileToDelete, "D%d", highDir);
! 	    if (unlink(fullpn_FileToDelete)) {
! 		if (errno == EISDIR && *fileToDelete == 'D') {
! 		    if (rmdir(fullpn_FileToDelete)) {
! 			printf("%s: Can't rmdir '%s', errno is %d\n", rn,
! 			       fullpn_FileToDelete, errno);
! 		    }
! 		} else
! 		    printf("%s: Can't unlink '%s', errno is %d\n", rn,
! 			   fullpn_FileToDelete, errno);
! 	    }
  	}
      }
  
--- 1028,1034 ----
  	/* Remove any directories >= maxDir -- they should be empty */
  	for (; highDir >= maxDir; highDir--) {
  	    sprintf(fileToDelete, "D%d", highDir);
! 	    UnlinkUnwantedFile(rn, fullpn_FileToDelete, fileToDelete);
  	}
      }
  
***************
*** 1192,1204 ****
  }
  
  static
! ConfigCell(aci, arock, adir)
!      register struct afsconf_cell *aci;
!      char *arock;
!      struct afsconf_dir *adir;
  {
!     register int isHomeCell;
!     register int i, code;
      afs_int32 cellFlags = 0;
      afs_int32 hosts[MAXHOSTSPERCELL];
  
--- 1190,1199 ----
  }
  
  static
! ConfigCell(struct afsconf_cell *aci, char *arock, struct afsconf_dir *adir)
  {
!     int isHomeCell;
!     int i, code;
      afs_int32 cellFlags = 0;
      afs_int32 hosts[MAXHOSTSPERCELL];
  
***************
*** 1226,1235 ****
  }
  
  static
! ConfigCellAlias(aca, arock, adir)
!      register struct afsconf_cellalias *aca;
!      char *arock;
!      struct afsconf_dir *adir;
  {
      /* push the alias into the kernel */
      call_syscall(AFSOP_ADDCELLALIAS, aca->aliasName, aca->realName);
--- 1221,1228 ----
  }
  
  static
! ConfigCellAlias(struct afsconf_cellalias *aca,
! 		char *arock, struct afsconf_dir *adir)
  {
      /* push the alias into the kernel */
      call_syscall(AFSOP_ADDCELLALIAS, aca->aliasName, aca->realName);
***************
*** 1310,1322 ****
  #endif
  #endif
  
! mainproc(as, arock)
!      struct cmd_syndesc *as;
!      char *arock;
  {
      static char rn[] = "afsd";	/*Name of this routine */
!     register afs_int32 code;	/*Result of fork() */
!     register int i;
      int currVFile;		/*Current AFS cache file number passed in */
      int mountFlags;		/*Flags passed to mount() */
      int lookupResult;		/*Result of GetLocalCellName() */
--- 1303,1313 ----
  #endif
  #endif
  
! mainproc(struct cmd_syndesc *as, char *arock)
  {
      static char rn[] = "afsd";	/*Name of this routine */
!     afs_int32 code;		/*Result of fork() */
!     int i;
      int currVFile;		/*Current AFS cache file number passed in */
      int mountFlags;		/*Flags passed to mount() */
      int lookupResult;		/*Result of GetLocalCellName() */
***************
*** 1359,1372 ****
      if (as->parms[3].items) {
  	/* -stat */
  	cacheStatEntries = atoi(as->parms[3].items->data);
      }
      if (as->parms[4].items) {
  	/* -memcache */
  	cacheBaseDir[0] = '\0';
  	sawCacheBaseDir = 1;
  	cacheFlags |= AFSCALL_INIT_MEMCACHE;
- 	if (chunkSize == 0)
- 	    chunkSize = 13;
      }
      if (as->parms[5].items) {
  	/* -cachedir */
--- 1350,1362 ----
      if (as->parms[3].items) {
  	/* -stat */
  	cacheStatEntries = atoi(as->parms[3].items->data);
+ 	sawCacheStatEntries = 1;
      }
      if (as->parms[4].items) {
  	/* -memcache */
  	cacheBaseDir[0] = '\0';
  	sawCacheBaseDir = 1;
  	cacheFlags |= AFSCALL_INIT_MEMCACHE;
      }
      if (as->parms[5].items) {
  	/* -cachedir */
***************
*** 1442,1451 ****
  	strcpy(confDir, as->parms[17].items->data);
      }
      sprintf(fullpn_CacheInfo, "%s/%s", confDir, CACHEINFOFILE);
-     sprintf(fullpn_AFSLogFile, "%s/%s", confDir, AFSLOGFILE);
      if (as->parms[18].items) {
  	/* -logfile */
! 	strcpy(fullpn_AFSLogFile, as->parms[18].items->data);
      }
      if (as->parms[19].items) {
  	/* -waitclose */
--- 1432,1440 ----
  	strcpy(confDir, as->parms[17].items->data);
      }
      sprintf(fullpn_CacheInfo, "%s/%s", confDir, CACHEINFOFILE);
      if (as->parms[18].items) {
  	/* -logfile */
!         printf("afsd: Ignoring obsolete -logfile flag\n");
      }
      if (as->parms[19].items) {
  	/* -waitclose */
***************
*** 1562,1579 ****
  	exit(1);
      }
  
-     if ((logfd = fopen(fullpn_AFSLogFile, "r+")) == 0) {
- 	if (afsd_verbose)
- 	    printf("%s: Creating '%s'\n", rn, fullpn_AFSLogFile);
- 	if (CreateCacheFile(fullpn_AFSLogFile, NULL)) {
- 	    printf
- 		("%s: Can't create '%s' (You may want to use the -logfile option)\n",
- 		 rn, fullpn_AFSLogFile);
- 	    exit(1);
- 	}
-     } else
- 	fclose(logfd);
- 
      /* do some random computations in memcache case to get things to work
       * reasonably no matter which parameters you set.
       */
--- 1551,1556 ----
***************
*** 1581,1587 ****
--- 1558,1570 ----
  	/* memory cache: size described either as blocks or dcache entries, but
  	 * not both.
  	 */
+ 	if (filesSet) {
+ 	    fprintf(stderr, "%s: -files ignored with -memcache\n", rn);
+ 	}
  	if (sawDCacheSize) {
+ 	    if (chunkSize == 0) {
+ 		chunkSize = 13;	/* 8k default chunksize for memcache */
+ 	    }
  	    if (sawCacheBlocks) {
  		printf
  		    ("%s: can't set cache blocks and dcache size simultaneously when diskless.\n",
***************
*** 1589,1606 ****
  		exit(1);
  	    }
  	    /* compute the cache size based on # of chunks times the chunk size */
! 	    i = (chunkSize == 0 ? 13 : chunkSize);
! 	    i = (1 << i);	/* bytes per chunk */
  	    cacheBlocks = i * dCacheSize;
  	    sawCacheBlocks = 1;	/* so that ParseCacheInfoFile doesn't overwrite */
  	} else {
  	    /* compute the dcache size from overall cache size and chunk size */
! 	    i = (chunkSize == 0 ? 13 : chunkSize);
! 	    /* dCacheSize = (cacheBlocks << 10) / (1<<i); */
! 	    if (i > 10) {
! 		dCacheSize = (cacheBlocks >> (i - 10));
! 	    } else if (i < 10) {
! 		dCacheSize = (cacheBlocks << (10 - i));
  	    } else {
  		dCacheSize = cacheBlocks;
  	    }
--- 1572,1597 ----
  		exit(1);
  	    }
  	    /* compute the cache size based on # of chunks times the chunk size */
! 	    i = (1 << chunkSize);	/* bytes per chunk */
  	    cacheBlocks = i * dCacheSize;
  	    sawCacheBlocks = 1;	/* so that ParseCacheInfoFile doesn't overwrite */
  	} else {
+ 	    if (chunkSize == 0) {
+ 		/* Try to autotune the memcache chunksize based on size
+ 		 * of memcache. This is done on the assumption that approx
+ 		 * 1024 chunks is suitable, it's a balance between enough
+ 		 * chunks to be useful and ramping up nicely when using larger
+ 		 * memcache to improve bulk read/write performance
+ 		 */
+ 		for (i = 14;
+ 		     i <= 21 && (1 << i) / 1024 < (cacheBlocks / 1024); i++);
+ 		chunkSize = i - 1;
+ 	    }
  	    /* compute the dcache size from overall cache size and chunk size */
! 	    if (chunkSize > 10) {
! 		dCacheSize = (cacheBlocks >> (chunkSize - 10));
! 	    } else if (chunkSize < 10) {
! 		dCacheSize = (cacheBlocks << (10 - chunkSize));
  	    } else {
  		dCacheSize = cacheBlocks;
  	    }
***************
*** 1608,1615 ****
  	     * by ParseCacheInfoFile.
  	     */
  	}
! 	/* kernel computes # of dcache entries as min of cacheFiles and dCacheSize,
! 	 * so we now make them equal.
  	 */
  	cacheFiles = dCacheSize;
      } else {
--- 1599,1609 ----
  	     * by ParseCacheInfoFile.
  	     */
  	}
! 	if (afsd_verbose)
! 	    printf("%s: chunkSize autotuned to %d\n", rn, chunkSize);
! 
! 	/* kernel computes # of dcache entries as min of cacheFiles and
! 	 * dCacheSize, so we now make them equal.
  	 */
  	cacheFiles = dCacheSize;
      } else {
***************
*** 1618,1660 ****
  	 * but only if -files isn't given on the command line.
  	 * Don't let # files be so small as to prevent full utilization 
  	 * of the cache unless user has explicitly asked for it.
- 	 * average V-file is ~10K, according to tentative empirical studies.
  	 */
  	if (!filesSet) {
! 	    cacheFiles = cacheBlocks / 10;
! 	    if (cacheFiles < 100)
! 		cacheFiles = 100;
  	    /* Always allow more files than chunks.  Presume average V-file 
  	     * is ~67% of a chunk...  (another guess, perhaps Honeyman will
  	     * have a grad student write a paper).  i is KILOBYTES.
  	     */
! 	    i = 1 << (chunkSize ==
! 		      0 ? 6 : (chunkSize < 10 ? 0 : chunkSize - 10));
  	    cacheFiles = max(cacheFiles, 1.5 * (cacheBlocks / i));
  	    /* never permit more files than blocks, while leaving space for
  	     * VolumeInfo and CacheItems files.  VolumeInfo is usually 20K,
  	     * CacheItems is 50 Bytes / file (== 1K/20)
  	     */
- #define VOLINFOSZ 20
  #define CACHEITMSZ (cacheFiles / 20)
! #ifdef AFS_AIX_ENV
! 	    cacheFiles =
! 		min(cacheFiles, (cacheBlocks - VOLINFOSZ - CACHEITMSZ) / 4);
! #else
! 	    cacheFiles =
! 		min(cacheFiles, cacheBlocks - VOLINFOSZ - CACHEITMSZ);
! #endif
  	    if (cacheFiles < 100)
  		fprintf(stderr, "%s: WARNING: cache probably too small!\n",
  			rn);
  	}
  	if (!sawDCacheSize) {
! 	    if ((cacheFiles / 2) > dCacheSize)
! 		dCacheSize = cacheFiles / 2;
! 	    if (dCacheSize > 2000)
  		dCacheSize = 2000;
  	}
      }
  
      /*
       * Create and zero the inode table for the desired cache files.
--- 1612,1698 ----
  	 * but only if -files isn't given on the command line.
  	 * Don't let # files be so small as to prevent full utilization 
  	 * of the cache unless user has explicitly asked for it.
  	 */
+ 	if (chunkSize == 0) {
+ 	    /* Set chunksize to 256kB - 1MB depending on cache size */
+ 	    if (cacheBlocks < 500000) {
+ 		chunkSize = 18;
+ 	    } else if (cacheBlocks < 1000000) {
+ 		chunkSize = 19;
+ 	    } else {
+ 		chunkSize = 20;
+ 	    }
+ 	}
  	if (!filesSet) {
! 	    cacheFiles = cacheBlocks / 32;	/* Assume 32k avg filesize */
! 
! 	    cacheFiles = max(cacheFiles, 1000);
! 
  	    /* Always allow more files than chunks.  Presume average V-file 
  	     * is ~67% of a chunk...  (another guess, perhaps Honeyman will
  	     * have a grad student write a paper).  i is KILOBYTES.
  	     */
! 	    i = 1 << (chunkSize < 10 ? 0 : chunkSize - 10);
  	    cacheFiles = max(cacheFiles, 1.5 * (cacheBlocks / i));
+ 
  	    /* never permit more files than blocks, while leaving space for
  	     * VolumeInfo and CacheItems files.  VolumeInfo is usually 20K,
  	     * CacheItems is 50 Bytes / file (== 1K/20)
  	     */
  #define CACHEITMSZ (cacheFiles / 20)
! #define VOLINFOSZ 50		/* 40kB has been seen, be conservative */
! #define CELLINFOSZ 4		/* Assuming disk block size is 4k ... */
! #define INFOSZ (VOLINFOSZ+CELLINFOSZ+CACHEITMSZ)
! 
! 	    /* Sanity check: If the obtained number of disk cache files
! 	     * is larger than the number of available (4k) disk blocks, we're
! 	     * doing something wrong. Fail hard so we can fix the bug instead
! 	     * of silently hiding it like before */
! 
! 	    if (cacheFiles > (cacheBlocks - INFOSZ) / 4) {
! 		fprintf(stderr,
! 			"%s: ASSERT: cacheFiles %d  diskblocks %d\n",
! 			rn, cacheFiles, (cacheBlocks - INFOSZ) / 4);
! 		exit(1);
! 	    }
  	    if (cacheFiles < 100)
  		fprintf(stderr, "%s: WARNING: cache probably too small!\n",
  			rn);
+ 
+ 	    if (afsd_verbose)
+ 		printf("%s: cacheFiles autotuned to %d\n", rn, cacheFiles);
  	}
+ 	/* Sanity check chunkSize */
+ 	i = max(cacheBlocks / 1000, cacheBlocks / cacheFiles);
+ 	chunkSize = min(chunkSize, i);
+ 	chunkSize = max(chunkSize, 2);
+ 	if (afsd_verbose)
+ 	    printf("%s: chunkSize autotuned to %d\n", rn, chunkSize);
+ 
  	if (!sawDCacheSize) {
! 	    dCacheSize = cacheFiles / 2;
! 	    if (dCacheSize > 10000) {
! 		dCacheSize = 10000;
! 	    }
! 	    if (dCacheSize < 2000) {
  		dCacheSize = 2000;
+ 	    }
+ 	    if (afsd_verbose)
+ 		printf("%s: dCacheSize autotuned to %d\n", rn, dCacheSize);
  	}
      }
+     if (!sawCacheStatEntries) {
+ 	if (chunkSize <= 13) {
+ 	    cacheStatEntries = dCacheSize / 4;
+ 	} else if (chunkSize >= 16) {
+ 	    cacheStatEntries = dCacheSize * 1.5;
+ 	} else {
+ 	    cacheStatEntries = dCacheSize;
+ 	}
+ 	if (afsd_verbose)
+ 	    printf("%s: cacheStatEntries autotuned to %d\n", rn,
+ 		   cacheStatEntries);
+     }
  
      /*
       * Create and zero the inode table for the desired cache files.
***************
*** 1793,1800 ****
  #endif
  
      code = call_syscall(AFSOP_BASIC_INIT, 1);
!     if (code)
  	printf("%s: Error %d in basic initialization.\n", rn, code);
  
      /*
       * Tell the kernel some basic information about the workstation's cache.
--- 1831,1840 ----
  #endif
  
      code = call_syscall(AFSOP_BASIC_INIT, 1);
!     if (code) {
  	printf("%s: Error %d in basic initialization.\n", rn, code);
+         exit(1);
+     }
  
      /*
       * Tell the kernel some basic information about the workstation's cache.
***************
*** 1982,2002 ****
  	call_syscall(AFSOP_VOLUMEINFO, fullpn_VolInfoFile);
  
      /*
-      * Pass the kernel the name of the afs logging file holding the volume
-      * information.
-      */
-     if (afsd_debug)
- 	printf("%s: Calling AFSOP_AFSLOG: volume info file is '%s'\n", rn,
- 	       fullpn_AFSLogFile);
- #if defined(AFS_SGI_ENV)
-     /* permit explicit -logfile argument to enable logging on memcache systems */
-     if (!(cacheFlags & AFSCALL_INIT_MEMCACHE) || as->parms[18].items)
- #else
-     if (!(cacheFlags & AFSCALL_INIT_MEMCACHE))	/* ... nor this ... */
- #endif
- 	call_syscall(AFSOP_AFSLOG, fullpn_AFSLogFile);
- 
-     /*
       * Give the kernel the names of the AFS files cached on the workstation's
       * disk.
       */
--- 2022,2027 ----
***************
*** 2108,2116 ****
  
  
  
! main(argc, argv)
!      int argc;
!      char **argv;
  {
      struct cmd_syndesc *ts;
  
--- 2133,2139 ----
  
  
  
! main(int argc, char **argv)
  {
      struct cmd_syndesc *ts;
  
***************
*** 2182,2188 ****
  		"Prefer backup volumes for mointpoints in backup volumes");
      cmd_AddParm(ts, "-rxbind", CMD_FLAG, CMD_OPTIONAL, "Bind the Rx socket (one interface only)");
      cmd_AddParm(ts, "-settime", CMD_FLAG, CMD_OPTIONAL,
!                "don't set the time");
      cmd_AddParm(ts, "-rxpck", CMD_SINGLE, CMD_OPTIONAL, "set rx_extraPackets to this value");
      return (cmd_Dispatch(argc, argv));
  }
--- 2205,2211 ----
  		"Prefer backup volumes for mointpoints in backup volumes");
      cmd_AddParm(ts, "-rxbind", CMD_FLAG, CMD_OPTIONAL, "Bind the Rx socket (one interface only)");
      cmd_AddParm(ts, "-settime", CMD_FLAG, CMD_OPTIONAL,
!                "set the time");
      cmd_AddParm(ts, "-rxpck", CMD_SINGLE, CMD_OPTIONAL, "set rx_extraPackets to this value");
      return (cmd_Dispatch(argc, argv));
  }
***************
*** 2307,2315 ****
--- 2330,2358 ----
      }
      else
  #endif
+ #ifdef AFS_DARWIN80_ENV
+     struct afssysargs syscall_data;
+     int fd = open(SYSCALL_DEV_FNAME,O_RDWR);
+     syscall_data.syscall = AFSCALL_CALL;
+     syscall_data.param1 = param1;
+     syscall_data.param2 = param2;
+     syscall_data.param3 = param3;
+     syscall_data.param4 = param4;
+     syscall_data.param5 = param5;
+     syscall_data.param6 = param6;
+     if(fd >= 0) {
+        error = ioctl(fd, VIOC_SYSCALL, &syscall_data);
+        close(fd);
+     } else {
+        error = -1;
+     }
+     if (!error)
+       error=syscall_data.retval;
+ #else
      error =
  	syscall(AFS_SYSCALL, AFSCALL_CALL, param1, param2, param3, param4,
  		param5, param6, param7);
+ #endif
  
      if (afsd_verbose)
  	printf("SScall(%d, %d, %d)=%d ", AFS_SYSCALL, AFSCALL_CALL, param1,
***************
*** 2378,2392 ****
      return (error);
  }
  
! vmountdata(vmtp, obj, stub, host, hostsname, info, args)
!      struct vmount *vmtp;
!      char *obj, *stub, *host, *hostsname, *info, *args;
  {
!     register struct data {
  	short vmt_off;
  	short vmt_size;
      } *vdp, *vdprev;
!     register int size;
  
      vdp = (struct data *)vmtp->vmt_data;
      vdp->vmt_off = sizeof(struct vmount);
--- 2421,2434 ----
      return (error);
  }
  
! vmountdata(struct vmount * vmtp, char *obj, char *stub, char *host,
! 	   char *hostsname, char *info, char *args)
  {
!     struct data {
  	short vmt_off;
  	short vmt_size;
      } *vdp, *vdprev;
!     int size;
  
      vdp = (struct data *)vmtp->vmt_data;
      vdp->vmt_off = sizeof(struct vmount);
Index: openafs/src/afsmonitor/afsmonitor.c
diff -c openafs/src/afsmonitor/afsmonitor.c:1.18.2.1 openafs/src/afsmonitor/afsmonitor.c:1.18.2.2
*** openafs/src/afsmonitor/afsmonitor.c:1.18.2.1	Sun Apr  3 14:15:42 2005
--- openafs/src/afsmonitor/afsmonitor.c	Thu Oct 13 13:55:33 2005
***************
*** 19,25 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/afsmonitor/afsmonitor.c,v 1.18.2.1 2005/04/03 18:15:42 shadow Exp $");
  
  #include <stdio.h>
  #include <math.h>
--- 19,25 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/afsmonitor/afsmonitor.c,v 1.18.2.2 2005/10/13 17:55:33 shadow Exp $");
  
  #include <stdio.h>
  #include <math.h>
***************
*** 272,278 ****
  
  
  
! #if !defined(AFS_FBSD_ENV) && !defined(AFS_DARWIN70_ENV) && !defined(AFS_NBSD20_ENV)
  /*	
          strcasestr(): Return first occurence of pattern s2 in s1, case 
  	insensitive. 
--- 272,278 ----
  
  
  
! #ifndef HAVE_STRCASESTR
  /*	
          strcasestr(): Return first occurence of pattern s2 in s1, case 
  	insensitive. 
Index: openafs/src/auth/cellconfig.c
diff -c openafs/src/auth/cellconfig.c:1.40.2.2 openafs/src/auth/cellconfig.c:1.40.2.4
*** openafs/src/auth/cellconfig.c:1.40.2.2	Sun Apr  3 14:15:43 2005
--- openafs/src/auth/cellconfig.c	Sat Oct 15 10:55:39 2005
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/auth/cellconfig.c,v 1.40.2.2 2005/04/03 18:15:43 shadow Exp $");
  
  #include <afs/stds.h>
  #include <afs/pthread_glock.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/auth/cellconfig.c,v 1.40.2.4 2005/10/15 14:55:39 shadow Exp $");
  
  #include <afs/stds.h>
  #include <afs/pthread_glock.h>
***************
*** 740,745 ****
--- 740,747 ----
      size_t len;
      unsigned char answer[1024];
      unsigned char *p;
+     char *dotcellname;
+     int cellnamelength;
      char realCellName[256];
      char host[256];
      int server_num = 0;
***************
*** 749,757 ****
       * replaced with a more fine-grained lock just for the resolver
       * operations.
       */
!     LOCK_GLOBAL_MUTEX;
!     len = res_search(acellName, C_IN, T_AFSDB, answer, sizeof(answer));
!     UNLOCK_GLOBAL_MUTEX;
      if (len < 0)
  	return AFSCONF_NOTFOUND;
  
--- 751,775 ----
       * replaced with a more fine-grained lock just for the resolver
       * operations.
       */
! 
!     if ( ! strchr(acellName,'.') ) {
!        cellnamelength=strlen(acellName);
!        dotcellname=malloc(cellnamelength+2);
!        memcpy(dotcellname,acellName,cellnamelength);
!        dotcellname[cellnamelength]='.';
!        dotcellname[cellnamelength+1]=0;
!        LOCK_GLOBAL_MUTEX;
! 	    len = res_search(dotcellname, C_IN, T_AFSDB, answer, sizeof(answer));
!        if ( len < 0 ) {
!           len = res_search(acellName, C_IN, T_AFSDB, answer, sizeof(answer));
!        }
!        UNLOCK_GLOBAL_MUTEX;
!        free(dotcellname);
!     } else {
!        LOCK_GLOBAL_MUTEX;
! 	    len = res_search(acellName, C_IN, T_AFSDB, answer, sizeof(answer));
!        UNLOCK_GLOBAL_MUTEX;
!     }
      if (len < 0)
  	return AFSCONF_NOTFOUND;
  
***************
*** 1107,1112 ****
--- 1125,1136 ----
  	return 0;
      }
  
+     if (code < sizeof(afs_int32) + (tstr->nkeys*sizeof(struct afsconf_key))) {
+ 	tstr->nkeys = 0;
+ 	UNLOCK_GLOBAL_MUTEX;
+ 	return 0;
+     }
+ 
      /* convert key structure to host order */
      tstr->nkeys = ntohl(tstr->nkeys);
      for (fd = 0; fd < tstr->nkeys; fd++)
Index: openafs/src/cf/osconf.m4
diff -c openafs/src/cf/osconf.m4:1.51.2.16 openafs/src/cf/osconf.m4:1.51.2.19
*** openafs/src/cf/osconf.m4:1.51.2.16	Wed Apr 27 23:07:30 2005
--- openafs/src/cf/osconf.m4	Fri Oct 21 00:48:43 2005
***************
*** 393,398 ****
--- 393,399 ----
  		LEX="lex -l"
  		REGEX_OBJ="regex.o"
  		XCFLAGS="-traditional-cpp"
+ 		SHLIB_LINKER="${MT_CC} -dynamiclib"
  		;;
  
  	ppc_darwin_13)
***************
*** 401,406 ****
--- 402,408 ----
  		LWP_OPTMZ="-O2"
  		REGEX_OBJ="regex.o"
  		XCFLAGS="-no-cpp-precomp"
+ 		SHLIB_LINKER="${MT_CC} -dynamiclib"
  		;;
  
  	ppc_darwin_14)
***************
*** 409,414 ****
--- 411,417 ----
  		LWP_OPTMZ="-O2"
  		REGEX_OBJ="regex.o"
  		XCFLAGS="-no-cpp-precomp"
+ 		SHLIB_LINKER="${MT_CC} -dynamiclib"
  		;;
  
  	ppc_darwin_60)
***************
*** 418,423 ****
--- 421,427 ----
  		REGEX_OBJ="regex.o"
  		XCFLAGS="-no-cpp-precomp"
  		TXLIBS="-lncurses"
+ 		SHLIB_LINKER="${MT_CC} -dynamiclib"
  		;;
  
  	ppc_darwin_70)
***************
*** 433,439 ****
  		EXTRA_VLIBOBJS="fstab.o"
  		;;
  
! 	ppc_darwin_80)
  		AFSD_LDFLAGS="-F/System/Library/PrivateFrameworks -framework DiskArbitration"
  		LEX="lex -l"
  		MT_CFLAGS='-DAFS_PTHREAD_ENV -D_REENTRANT ${XCFLAGS}'
--- 437,443 ----
  		EXTRA_VLIBOBJS="fstab.o"
  		;;
  
! 	*_darwin_80)
  		AFSD_LDFLAGS="-F/System/Library/PrivateFrameworks -framework DiskArbitration"
  		LEX="lex -l"
  		MT_CFLAGS='-DAFS_PTHREAD_ENV -D_REENTRANT ${XCFLAGS}'
***************
*** 444,449 ****
--- 448,455 ----
  		XCFLAGS="-no-cpp-precomp"
  		TXLIBS="-lncurses"
  		EXTRA_VLIBOBJS="fstab.o"
+ 		SHLIB_LINKER="${MT_CC} -dynamiclib"
+ 		SHLIB_LINKER="${MT_CC} -dynamiclib"
  		;;
  
  	ppc_linux*)
***************
*** 556,562 ****
  
  	s390x_linux24|s390x_linux26)
  		CC="gcc"
! 		CCOBJ="gcc"
  		LD="ld"
  		KERN_OPTMZ=-O2
  		LEX="flex -l"
--- 562,568 ----
  
  	s390x_linux24|s390x_linux26)
  		CC="gcc"
! 		CCOBJ="gcc -fPIC"
  		LD="ld"
  		KERN_OPTMZ=-O2
  		LEX="flex -l"
Index: openafs/src/config/NTMakefile.amd64_w2k
diff -c openafs/src/config/NTMakefile.amd64_w2k:1.1.2.20.2.4 openafs/src/config/NTMakefile.amd64_w2k:1.1.2.22
*** openafs/src/config/NTMakefile.amd64_w2k:1.1.2.20.2.4	Wed Oct 19 16:15:22 2005
--- openafs/src/config/NTMakefile.amd64_w2k	Sat Oct  8 09:42:04 2005
***************
*** 80,86 ****
  #define used in WinNT/2000 installation and program version display
  AFSPRODUCT_VER_MAJOR=1
  AFSPRODUCT_VER_MINOR=4
! AFSPRODUCT_VER_PATCH=0008
  AFSPRODUCT_VER_BUILD=0
  
  AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH)
--- 80,86 ----
  #define used in WinNT/2000 installation and program version display
  AFSPRODUCT_VER_MAJOR=1
  AFSPRODUCT_VER_MINOR=4
! AFSPRODUCT_VER_PATCH=0050
  AFSPRODUCT_VER_BUILD=0
  
  AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH)
Index: openafs/src/config/NTMakefile.i386_nt40
diff -c openafs/src/config/NTMakefile.i386_nt40:1.46.2.35.2.4 openafs/src/config/NTMakefile.i386_nt40:1.46.2.37
*** openafs/src/config/NTMakefile.i386_nt40:1.46.2.35.2.4	Wed Oct 19 16:15:22 2005
--- openafs/src/config/NTMakefile.i386_nt40	Sat Oct  8 09:42:04 2005
***************
*** 80,86 ****
  #define used in WinNT/2000 installation and program version display
  AFSPRODUCT_VER_MAJOR=1
  AFSPRODUCT_VER_MINOR=4
! AFSPRODUCT_VER_PATCH=0008
  AFSPRODUCT_VER_BUILD=0
  
  AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH)
--- 80,86 ----
  #define used in WinNT/2000 installation and program version display
  AFSPRODUCT_VER_MAJOR=1
  AFSPRODUCT_VER_MINOR=4
! AFSPRODUCT_VER_PATCH=0050
  AFSPRODUCT_VER_BUILD=0
  
  AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH)
Index: openafs/src/config/NTMakefile.i386_w2k
diff -c openafs/src/config/NTMakefile.i386_w2k:1.1.2.21.2.4 openafs/src/config/NTMakefile.i386_w2k:1.1.2.23
*** openafs/src/config/NTMakefile.i386_w2k:1.1.2.21.2.4	Wed Oct 19 16:15:22 2005
--- openafs/src/config/NTMakefile.i386_w2k	Sat Oct  8 09:42:04 2005
***************
*** 79,85 ****
  
  #define used in WinNT/2000 installation and program version display
  AFSPRODUCT_VER_MINOR=4
! AFSPRODUCT_VER_PATCH=0008
  AFSPRODUCT_VER_BUILD=0
  
  AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH)
--- 79,85 ----
  
  #define used in WinNT/2000 installation and program version display
  AFSPRODUCT_VER_MINOR=4
! AFSPRODUCT_VER_PATCH=0050
  AFSPRODUCT_VER_BUILD=0
  
  AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH)
Index: openafs/src/config/afs_args.h
diff -c openafs/src/config/afs_args.h:1.13.2.6 openafs/src/config/afs_args.h:1.13.2.7
*** openafs/src/config/afs_args.h:1.13.2.6	Tue Jun 21 16:13:54 2005
--- openafs/src/config/afs_args.h	Wed Oct  5 01:58:34 2005
***************
*** 204,208 ****
--- 204,223 ----
   
  #endif
  
+ #ifdef AFS_DARWIN80_ENV
+ struct afssysargs {
+      unsigned long syscall;
+      unsigned long param1;
+      unsigned long param2;
+      unsigned long param3;
+      unsigned long param4;
+      unsigned long param5;
+      unsigned long param6;
+      unsigned long retval;
+ };
+ #define VIOC_SYSCALL_TYPE 'C' 
+ #define VIOC_SYSCALL _IOWR(VIOC_SYSCALL_TYPE,1,struct afssysargs)
+ #define SYSCALL_DEV_FNAME "/dev/openafs_ioctl"
+ #endif
  
  #endif /* _AFS_ARGS_H_ */
Index: openafs/src/config/afs_sysnames.h
diff -c openafs/src/config/afs_sysnames.h:1.50.2.16 openafs/src/config/afs_sysnames.h:1.50.2.20
*** openafs/src/config/afs_sysnames.h:1.50.2.16	Mon May 23 17:17:41 2005
--- openafs/src/config/afs_sysnames.h	Fri Oct 21 00:48:48 2005
***************
*** 58,63 ****
--- 58,65 ----
  #define SYS_NAME_ID_ppc_darwin_14        505
  #define SYS_NAME_ID_ppc_darwin_60        506
  #define SYS_NAME_ID_ppc_darwin_70        507
+ #define SYS_NAME_ID_ppc_darwin_80        508
+ #define SYS_NAME_ID_x86_darwin_80        509
  
  #define SYS_NAME_ID_next_mach20		 601
  #define SYS_NAME_ID_next_mach30		 602
***************
*** 206,211 ****
--- 208,214 ----
  #define SYS_NAME_ID_macppc_nbsd20	2524
  #define SYS_NAME_ID_i386_nbsd21		2525
  #define SYS_NAME_ID_i386_nbsd30		2526
+ #define SYS_NAME_ID_amd64_nbsd20	2527
  
  #define SYS_NAME_ID_i386_obsd31		2600
  #define SYS_NAME_ID_i386_obsd32		2601
***************
*** 214,219 ****
--- 217,223 ----
  #define SYS_NAME_ID_i386_obsd35		2604
  #define SYS_NAME_ID_i386_obsd36		2605
  #define SYS_NAME_ID_i386_obsd37		2606
+ #define SYS_NAME_ID_i386_obsd38		2607
  
  #define SYS_NAME_ID_amd64_linux2        2700
  #define SYS_NAME_ID_amd64_linux22       2701
Index: openafs/src/config/param.amd64_nbsd20.h
diff -c /dev/null openafs/src/config/param.amd64_nbsd20.h:1.1.2.2
*** /dev/null	Sat Oct 22 02:14:52 2005
--- openafs/src/config/param.amd64_nbsd20.h	Sat Oct 15 10:17:51 2005
***************
*** 0 ****
--- 1,21 ----
+ #ifndef AFS_AMD64_PARAM_H
+ #define AFS_AMD64_PARAM_H
+ 
+ #define AFS_X86_XBSD_ENV 1
+ #define AFS_X86_ENV 1
+ #define AFSLITTLE_ENDIAN 1
+ 
+ #define SYS_NAME       "amd64_nbsd20"
+ #define SYS_NAME_ID    SYS_NAME_ID_amd64_nbsd20
+ 
+ #define AFS_64BITPOINTER_ENV  1
+ #ifndef UKERNEL
+ /* This section for kernel libafs compiles only */
+ 
+ #else /* !defined(UKERNEL) */
+ 
+ /* This section for user space compiles only */
+ 
+ #endif /* !defined(UKERNEL) */
+ 
+ #endif /* AFS_AMD64_PARAM_H */
Index: openafs/src/config/param.i386_obsd38.h
diff -c /dev/null openafs/src/config/param.i386_obsd38.h:1.1.2.2
*** /dev/null	Sat Oct 22 02:14:52 2005
--- openafs/src/config/param.i386_obsd38.h	Thu Oct 13 13:55:35 2005
***************
*** 0 ****
--- 1,66 ----
+ /*
+  * Jim Rees, University of Michigan CITI
+  */
+ 
+ #ifndef	AFS_PARAM_H
+ #define	AFS_PARAM_H
+ 
+ #ifndef IGNORE_STDS_H
+ #include <sys/param.h>
+ #endif
+ 
+ #define SYS_NAME		"i386_obsd38"
+ #define SYS_NAME_ID		SYS_NAME_ID_i386_obsd38
+ 
+ #define AFS_XBSD_ENV		1	/* {Free,Open,Net}BSD */
+ #define AFS_X86_XBSD_ENV	1
+ 
+ #define AFS_NAMEI_ENV		1	/* User space interface to file system */
+ #define AFS_64BIT_ENV		1
+ #define AFS_64BIT_CLIENT	1
+ #define AFS_64BIT_IOPS_ENV	1	/* Needed for NAMEI */
+ #define AFS_OBSD_ENV		1
+ #define AFS_OBSD34_ENV		1
+ #define AFS_OBSD35_ENV		1
+ #define AFS_OBSD36_ENV		1
+ #define AFS_OBSD37_ENV		1
+ #define AFS_OBSD38_ENV		1
+ #define AFS_NONFSTRANS		1
+ #define AFS_VM_RDWR_ENV		1
+ #define AFS_VFS_ENV		1
+ #define AFS_VFSINCL_ENV		1
+ 
+ #define FTRUNC O_TRUNC
+ 
+ #define AFS_SYSCALL		208
+ #define AFS_MOUNT_AFS		"afs"
+ 
+ #define RXK_LISTENER_ENV	1
+ #define AFS_GCPAGS	        0	/* if nonzero, garbage collect PAGs */
+ #define AFS_USE_GETTIMEOFDAY    1	/* use gettimeofday to implement rx clock */
+ 
+ #define AFSLITTLE_ENDIAN	1
+ 
+ #ifndef IGNORE_STDS_H
+ #include <afs/afs_sysnames.h>
+ #endif
+ 
+ /* Extra kernel definitions (from kdefs file) */
+ #ifdef _KERNEL
+ #define AFS_GLOBAL_SUNLOCK	1
+ #define	AFS_SHORTGID		0	/* are group id's short? */
+ 
+ #if	!defined(ASSEMBLER) && !defined(__LANGUAGE_ASSEMBLY__)
+ enum vcexcl { NONEXCL, EXCL };
+ 
+ #ifndef MIN
+ #define MIN(A,B) ((A) < (B) ? (A) : (B))
+ #endif
+ #ifndef MAX
+ #define MAX(A,B) ((A) > (B) ? (A) : (B))
+ #endif
+ 
+ #endif /* ! ASSEMBLER & ! __LANGUAGE_ASSEMBLY__ */
+ #endif /* _KERNEL */
+ 
+ #endif /* AFS_PARAM_H */
Index: openafs/src/config/param.ppc_darwin_80.h
diff -c openafs/src/config/param.ppc_darwin_80.h:1.1.2.1 openafs/src/config/param.ppc_darwin_80.h:1.1.2.2
*** openafs/src/config/param.ppc_darwin_80.h:1.1.2.1	Tue Apr 19 12:03:06 2005
--- openafs/src/config/param.ppc_darwin_80.h	Wed Oct  5 01:58:34 2005
***************
*** 39,45 ****
  #define AFSBIG_ENDIAN   1
  #define AFS_HAVE_FFS    1	/* Use system's ffs. */
  
! #define AFS_GCPAGS                1	/* if nonzero, garbage collect PAGs */
  #define RXK_LISTENER_ENV         1
  
  #ifdef KERNEL
--- 39,45 ----
  #define AFSBIG_ENDIAN   1
  #define AFS_HAVE_FFS    1	/* Use system's ffs. */
  
! #define AFS_GCPAGS               0
  #define RXK_LISTENER_ENV         1
  
  #ifdef KERNEL
***************
*** 57,64 ****
  #define AFS_UIOUSER     UIO_USERSPACE
  #define AFS_CLBYTES     CLBYTES
  #define osi_GetTime(x)  microtime(x)
! #define AFS_KALLOC(x)   kalloc(x)
! #define AFS_KFREE(x,y)  kfree(x,y)
  #define v_count         v_usecount
  #define v_vfsp          v_mount
  #define vfs_bsize       mnt_stat.f_bsize
--- 57,64 ----
  #define AFS_UIOUSER     UIO_USERSPACE
  #define AFS_CLBYTES     CLBYTES
  #define osi_GetTime(x)  microtime(x)
! #define AFS_KALLOC(x)   _MALLOC(x, M_TEMP, M_WAITOK)
! #define AFS_KFREE(x,y)  _FREE(x,M_TEMP)
  #define v_count         v_usecount
  #define v_vfsp          v_mount
  #define vfs_bsize       mnt_stat.f_bsize
***************
*** 66,75 ****
  #define va_nodeid       va_fileid
  #define vfs_vnodecovered mnt_vnodecovered
  #define direct          dirent
- #define vnode_t         struct vnode
  
- //#define VN_RELE(vp)     vrele(((struct vnode *)(vp)))
- //#define VN_HOLD(vp)     VREF(((struct vnode *)(vp)))
  #define BIND_8_COMPAT
  
  #endif
--- 66,72 ----
Index: openafs/src/config/param.sun4x_510.h
diff -c openafs/src/config/param.sun4x_510.h:1.2.2.3 openafs/src/config/param.sun4x_510.h:1.2.2.5
*** openafs/src/config/param.sun4x_510.h:1.2.2.3	Sun Apr  3 14:15:48 2005
--- openafs/src/config/param.sun4x_510.h	Thu Oct 13 11:16:58 2005
***************
*** 24,36 ****
  #define AFS_BOZONLOCK_ENV       1
  
  #define AFS_64BIT_ENV		1	/* Defines afs_int32 as int, not long. */
- /*
-  * Only define on 64 bit kernel, until problems with 32 bit
-  * and large file support are resolved
-  */
- #if defined(__sparcv9)
  #define AFS_64BIT_CLIENT	1	
- #endif
  
  #define AFS_HAVE_FLOCK_SYSID	1
  
--- 24,30 ----
***************
*** 79,85 ****
  /*#define	AFS_USEBUFFERS	1*/
  #define	afsio_iov		uio_iov
  #define	afsio_iovcnt		uio_iovcnt
! #define	afsio_offset		uio_offset
  #define	afsio_seg		uio_segflg
  #define	afsio_fmode		uio_fmode
  #define	afsio_resid		uio_resid
--- 73,79 ----
  /*#define	AFS_USEBUFFERS	1*/
  #define	afsio_iov		uio_iov
  #define	afsio_iovcnt		uio_iovcnt
! #define	afsio_offset		uio_loffset
  #define	afsio_seg		uio_segflg
  #define	afsio_fmode		uio_fmode
  #define	afsio_resid		uio_resid
Index: openafs/src/config/param.sun4x_56.h
diff -c openafs/src/config/param.sun4x_56.h:1.10.2.1 openafs/src/config/param.sun4x_56.h:1.10.2.3
*** openafs/src/config/param.sun4x_56.h:1.10.2.1	Sun Apr  3 14:15:48 2005
--- openafs/src/config/param.sun4x_56.h	Thu Oct 13 11:16:58 2005
***************
*** 13,20 ****
  #ifndef	AFS_PARAM_H
  #define	AFS_PARAM_H
  
- #include <afs/afs_sysnames.h>
- 
  #define AFS_VFS_ENV	1
  /* Used only in vfsck code; is it needed any more???? */
  
--- 13,18 ----
***************
*** 33,43 ****
--- 31,46 ----
  #define RXK_LISTENER_ENV   1
  #define AFS_GCPAGS		1	/* if nonzero, garbage collect PAGs */
  
+ #define AFS_64BIT_ENV		1	/* Defines afs_int32 as int, not long. */
+ #define AFS_64BIT_CLIENT	1
+ 
  #define	AFS_3DISPARES		1	/* Utilize the 3 available disk inode 'spares' */
  #define	AFS_SYSCALL		105
  
  #define AFS_HAVE_FLOCK_SYSID    1
  
+ #include <afs/afs_sysnames.h>
+ 
  /* File system entry (used if mount.h doesn't define MOUNT_AFS */
  #define AFS_MOUNT_AFS	 "afs"
  
***************
*** 69,75 ****
  /*#define	AFS_USEBUFFERS	1*/
  #define	afsio_iov		uio_iov
  #define	afsio_iovcnt	uio_iovcnt
! #define	afsio_offset	uio_offset
  #define	afsio_seg		uio_segflg
  #define	afsio_fmode	uio_fmode
  #define	afsio_resid	uio_resid
--- 72,78 ----
  /*#define	AFS_USEBUFFERS	1*/
  #define	afsio_iov		uio_iov
  #define	afsio_iovcnt	uio_iovcnt
! #define	afsio_offset	uio_loffset
  #define	afsio_seg		uio_segflg
  #define	afsio_fmode	uio_fmode
  #define	afsio_resid	uio_resid
Index: openafs/src/config/param.sun4x_57.h
diff -c openafs/src/config/param.sun4x_57.h:1.9.2.1 openafs/src/config/param.sun4x_57.h:1.9.2.3
*** openafs/src/config/param.sun4x_57.h:1.9.2.1	Sun Apr  3 14:15:48 2005
--- openafs/src/config/param.sun4x_57.h	Thu Oct 13 11:16:58 2005
***************
*** 30,35 ****
--- 30,36 ----
  #define AFS_BOZONLOCK_ENV       1
  
  #define AFS_64BIT_ENV		1	/* Defines afs_int32 as int, not long. */
+ #define AFS_64BIT_CLIENT	1
  
  #define AFS_HAVE_FLOCK_SYSID    1
  
***************
*** 73,79 ****
  /*#define	AFS_USEBUFFERS	1*/
  #define	afsio_iov		uio_iov
  #define	afsio_iovcnt	uio_iovcnt
! #define	afsio_offset	uio_offset
  #define	afsio_seg		uio_segflg
  #define	afsio_fmode	uio_fmode
  #define	afsio_resid	uio_resid
--- 74,80 ----
  /*#define	AFS_USEBUFFERS	1*/
  #define	afsio_iov		uio_iov
  #define	afsio_iovcnt	uio_iovcnt
! #define	afsio_offset	uio_loffset
  #define	afsio_seg		uio_segflg
  #define	afsio_fmode	uio_fmode
  #define	afsio_resid	uio_resid
Index: openafs/src/config/param.sun4x_58.h
diff -c openafs/src/config/param.sun4x_58.h:1.11.2.2 openafs/src/config/param.sun4x_58.h:1.11.2.4
*** openafs/src/config/param.sun4x_58.h:1.11.2.2	Sun Apr  3 14:15:48 2005
--- openafs/src/config/param.sun4x_58.h	Thu Oct 13 11:16:58 2005
***************
*** 22,34 ****
  #define AFS_BOZONLOCK_ENV       1
  
  #define AFS_64BIT_ENV		1	/* Defines afs_int32 as int, not long. */
- /*
-  * Only define on 64 bit kernel, until problems with 32 bit
-  * and large file support are resolved
-  */
- #if defined(__sparcv9)
  #define AFS_64BIT_CLIENT	1	
- #endif
  
  #define AFS_HAVE_FLOCK_SYSID    1
  
--- 22,28 ----
***************
*** 77,83 ****
  /*#define	AFS_USEBUFFERS	1*/
  #define	afsio_iov		uio_iov
  #define	afsio_iovcnt	uio_iovcnt
! #define	afsio_offset	uio_offset
  #define	afsio_seg		uio_segflg
  #define	afsio_fmode	uio_fmode
  #define	afsio_resid	uio_resid
--- 71,77 ----
  /*#define	AFS_USEBUFFERS	1*/
  #define	afsio_iov		uio_iov
  #define	afsio_iovcnt	uio_iovcnt
! #define	afsio_offset	uio_loffset
  #define	afsio_seg		uio_segflg
  #define	afsio_fmode	uio_fmode
  #define	afsio_resid	uio_resid
Index: openafs/src/config/param.sun4x_59.h
diff -c openafs/src/config/param.sun4x_59.h:1.5.2.2 openafs/src/config/param.sun4x_59.h:1.5.2.4
*** openafs/src/config/param.sun4x_59.h:1.5.2.2	Sun Apr  3 14:15:48 2005
--- openafs/src/config/param.sun4x_59.h	Thu Oct 13 11:16:58 2005
***************
*** 23,35 ****
  #define AFS_BOZONLOCK_ENV       1
  
  #define AFS_64BIT_ENV		1	/* Defines afs_int32 as int, not long. */
- /*
-  * Only define on 64 bit kernel, until problems with 32 bit
-  * and large file support are resolved
-  */
- #if defined(__sparcv9)
  #define AFS_64BIT_CLIENT	1	
- #endif
  
  #define AFS_HAVE_FLOCK_SYSID    1
  
--- 23,29 ----
***************
*** 78,84 ****
  /*#define	AFS_USEBUFFERS	1*/
  #define	afsio_iov		uio_iov
  #define	afsio_iovcnt	uio_iovcnt
! #define	afsio_offset	uio_offset
  #define	afsio_seg		uio_segflg
  #define	afsio_fmode	uio_fmode
  #define	afsio_resid	uio_resid
--- 72,78 ----
  /*#define	AFS_USEBUFFERS	1*/
  #define	afsio_iov		uio_iov
  #define	afsio_iovcnt	uio_iovcnt
! #define	afsio_offset	uio_loffset
  #define	afsio_seg		uio_segflg
  #define	afsio_fmode	uio_fmode
  #define	afsio_resid	uio_resid
Index: openafs/src/config/param.sunx86_510.h
diff -c openafs/src/config/param.sunx86_510.h:1.2.2.5 openafs/src/config/param.sunx86_510.h:1.2.2.7
*** openafs/src/config/param.sunx86_510.h:1.2.2.5	Tue Apr 19 12:03:13 2005
--- openafs/src/config/param.sunx86_510.h	Thu Oct 13 11:16:58 2005
***************
*** 34,39 ****
--- 34,40 ----
  #define AFS_X86_ENV		1
  
  #define AFS_64BIT_ENV		1	/* Defines afs_int32 as int, not long. */
+ #define AFS_64BIT_CLIENT	1	
  
  #define AFS_HAVE_FLOCK_SYSID    1
  
***************
*** 82,88 ****
  /*#define	AFS_USEBUFFERS	1*/
  #define	afsio_iov		uio_iov
  #define	afsio_iovcnt		uio_iovcnt
! #define	afsio_offset		uio_offset
  #define	afsio_seg		uio_segflg
  #define	afsio_fmode		uio_fmode
  #define	afsio_resid		uio_resid
--- 83,89 ----
  /*#define	AFS_USEBUFFERS	1*/
  #define	afsio_iov		uio_iov
  #define	afsio_iovcnt		uio_iovcnt
! #define	afsio_offset		uio_loffset
  #define	afsio_seg		uio_segflg
  #define	afsio_fmode		uio_fmode
  #define	afsio_resid		uio_resid
***************
*** 100,106 ****
  #if defined(__amd64)
  #define	AFS_SUN57_64BIT_ENV	1
  #define AFS_64BIT_INO   	1
- #define AFS_64BIT_CLIENT	1	
  #endif
  
  /**
--- 101,106 ----
***************
*** 151,157 ****
  
  #define AFS_64BIT_ENV           1
  
- 
  #include <afs/afs_sysnames.h>
  
  #if 0
--- 151,156 ----
Index: openafs/src/config/param.sunx86_57.h
diff -c openafs/src/config/param.sunx86_57.h:1.4.2.2 openafs/src/config/param.sunx86_57.h:1.4.2.4
*** openafs/src/config/param.sunx86_57.h:1.4.2.2	Tue Apr 19 12:03:13 2005
--- openafs/src/config/param.sunx86_57.h	Thu Oct 13 11:16:58 2005
***************
*** 32,37 ****
--- 32,38 ----
  #define AFS_X86_ENV		1
  
  #define AFS_64BIT_ENV		1	/* Defines afs_int32 as int, not long. */
+ #define AFS_64BIT_CLIENT	1
  
  #define AFS_HAVE_FLOCK_SYSID    1
  
***************
*** 76,82 ****
  /*#define	AFS_USEBUFFERS	1*/
  #define	afsio_iov		uio_iov
  #define	afsio_iovcnt	uio_iovcnt
! #define	afsio_offset	uio_offset
  #define	afsio_seg		uio_segflg
  #define	afsio_fmode	uio_fmode
  #define	afsio_resid	uio_resid
--- 77,83 ----
  /*#define	AFS_USEBUFFERS	1*/
  #define	afsio_iov		uio_iov
  #define	afsio_iovcnt	uio_iovcnt
! #define	afsio_offset	uio_loffset
  #define	afsio_seg		uio_segflg
  #define	afsio_fmode	uio_fmode
  #define	afsio_resid	uio_resid
***************
*** 143,151 ****
  #define AFS_MOUNT_AFS	 1
  
  /* Machine / Operating system information */
! #define sys_sun4x_55	1
! #define SYS_NAME	"sun4x_55"
! #define SYS_NAME_ID	SYS_NAME_ID_sun4x_55
  #define AFSLITTLE_ENDIAN	1
  #define AFS_HAVE_FFS            1	/* Use system's ffs. */
  #define AFS_HAVE_STATVFS      0	/* System doesn't support statvfs */
--- 144,152 ----
  #define AFS_MOUNT_AFS	 1
  
  /* Machine / Operating system information */
! #define sys_sunx86_57	1
! #define SYS_NAME	"sunx86_57"
! #define SYS_NAME_ID	SYS_NAME_ID_sunx86_57
  #define AFSLITTLE_ENDIAN	1
  #define AFS_HAVE_FFS            1	/* Use system's ffs. */
  #define AFS_HAVE_STATVFS      0	/* System doesn't support statvfs */
Index: openafs/src/config/param.sunx86_58.h
diff -c openafs/src/config/param.sunx86_58.h:1.6.2.2 openafs/src/config/param.sunx86_58.h:1.6.2.4
*** openafs/src/config/param.sunx86_58.h:1.6.2.2	Tue Apr 19 12:03:13 2005
--- openafs/src/config/param.sunx86_58.h	Thu Oct 13 11:16:58 2005
***************
*** 33,38 ****
--- 33,39 ----
  #define AFS_X86_ENV		1
  
  #define AFS_64BIT_ENV		1	/* Defines afs_int32 as int, not long. */
+ #define AFS_64BIT_CLIENT	1
  
  #define AFS_HAVE_FLOCK_SYSID    1
  
***************
*** 81,87 ****
  /*#define	AFS_USEBUFFERS	1*/
  #define	afsio_iov		uio_iov
  #define	afsio_iovcnt	uio_iovcnt
! #define	afsio_offset	uio_offset
  #define	afsio_seg		uio_segflg
  #define	afsio_fmode	uio_fmode
  #define	afsio_resid	uio_resid
--- 82,88 ----
  /*#define	AFS_USEBUFFERS	1*/
  #define	afsio_iov		uio_iov
  #define	afsio_iovcnt	uio_iovcnt
! #define	afsio_offset	uio_loffset
  #define	afsio_seg		uio_segflg
  #define	afsio_fmode	uio_fmode
  #define	afsio_resid	uio_resid
***************
*** 148,156 ****
  #define AFS_MOUNT_AFS	 1
  
  /* Machine / Operating system information */
! #define sys_sun4x_55	1
! #define SYS_NAME	"sun4x_55"
! #define SYS_NAME_ID	SYS_NAME_ID_sun4x_55
  #define AFSLITTLE_ENDIAN	1
  #define AFS_HAVE_FFS            1	/* Use system's ffs. */
  #define AFS_HAVE_STATVFS      0	/* System doesn't support statvfs */
--- 149,157 ----
  #define AFS_MOUNT_AFS	 1
  
  /* Machine / Operating system information */
! #define sys_sunx86_58	1
! #define SYS_NAME	"sunx86_58"
! #define SYS_NAME_ID	SYS_NAME_ID_sunx86_58
  #define AFSLITTLE_ENDIAN	1
  #define AFS_HAVE_FFS            1	/* Use system's ffs. */
  #define AFS_HAVE_STATVFS      0	/* System doesn't support statvfs */
Index: openafs/src/config/param.sunx86_59.h
diff -c openafs/src/config/param.sunx86_59.h:1.2.2.2 openafs/src/config/param.sunx86_59.h:1.2.2.4
*** openafs/src/config/param.sunx86_59.h:1.2.2.2	Tue Apr 19 12:03:13 2005
--- openafs/src/config/param.sunx86_59.h	Thu Oct 13 11:16:59 2005
***************
*** 34,39 ****
--- 34,40 ----
  #define AFS_X86_ENV		1
  
  #define AFS_64BIT_ENV		1	/* Defines afs_int32 as int, not long. */
+ #define AFS_64BIT_CLIENT	1
  
  #define AFS_HAVE_FLOCK_SYSID    1
  
***************
*** 82,88 ****
  /*#define	AFS_USEBUFFERS	1*/
  #define	afsio_iov		uio_iov
  #define	afsio_iovcnt	uio_iovcnt
! #define	afsio_offset	uio_offset
  #define	afsio_seg		uio_segflg
  #define	afsio_fmode	uio_fmode
  #define	afsio_resid	uio_resid
--- 83,89 ----
  /*#define	AFS_USEBUFFERS	1*/
  #define	afsio_iov		uio_iov
  #define	afsio_iovcnt	uio_iovcnt
! #define	afsio_offset	uio_loffset
  #define	afsio_seg		uio_segflg
  #define	afsio_fmode	uio_fmode
  #define	afsio_resid	uio_resid
Index: openafs/src/config/param.x86_darwin_80.h
diff -c /dev/null openafs/src/config/param.x86_darwin_80.h:1.1.2.2
*** /dev/null	Sat Oct 22 02:14:53 2005
--- openafs/src/config/param.x86_darwin_80.h	Fri Oct 21 00:48:48 2005
***************
*** 0 ****
--- 1,137 ----
+ #ifndef UKERNEL
+ /* This section for kernel libafs compiles only */
+ 
+ #ifndef AFS_PARAM_H
+ #define AFS_PARAM_H
+ 
+ #define AFS_ENV                 1
+ #define AFS_64BIT_ENV           1	/* Defines afs_int32 as int, not long. */
+ #define AFS_64BIT_CLIENT        1
+ #define AFS_64BIT_IOPS_ENV	1
+ #define AFS_VFSINCL_ENV		1
+ 
+ #include <afs/afs_sysnames.h>
+ 
+ #define AFS_DARWIN_ENV
+ #define AFS_DARWIN13_ENV
+ #define AFS_DARWIN14_ENV
+ #define AFS_DARWIN60_ENV
+ #define AFS_DARWIN70_ENV
+ #define AFS_DARWIN80_ENV
+ #define AFS_NONFSTRANS
+ #define AFS_SYSCALL             230
+ #define AFS_NAMEI_ENV 1
+ #define DARWIN_REFBASE 3
+ 
+ /* File system entry (used if mount.h doesn't define MOUNT_AFS */
+ #define AFS_MOUNT_AFS    "afs"
+ 
+ /* Machine / Operating system information */
+ #define sys_x86_darwin_12   1
+ #define sys_x86_darwin_13   1
+ #define sys_x86_darwin_14   1
+ #define sys_x86_darwin_60   1
+ #define sys_x86_darwin_70   1
+ #define sys_x86_darwin_80   1
+ #define SYS_NAME        "x86_darwin_80"
+ #define SYS_NAME_ID     SYS_NAME_ID_x86_darwin_80
+ #define AFSLITTLE_ENDIAN   1
+ #define AFS_HAVE_FFS    1	/* Use system's ffs. */
+ 
+ #define AFS_GCPAGS               0
+ #define RXK_LISTENER_ENV         1
+ 
+ #ifdef KERNEL
+ #undef MACRO_BEGIN
+ #undef MACRO_END
+ #include <kern/macro_help.h>
+ #define AFS_GLOBAL_SUNLOCK        1
+ #define AFS_VFS34       1	/* What is VFS34??? */
+ #define afsio_iov       uio_iov
+ #define afsio_iovcnt    uio_iovcnt
+ #define afsio_offset    uio_offset
+ #define afsio_seg       uio_segflg
+ #define afsio_resid     uio_resid
+ #define AFS_UIOSYS      UIO_SYSSPACE
+ #define AFS_UIOUSER     UIO_USERSPACE
+ #define AFS_CLBYTES     CLBYTES
+ #define osi_GetTime(x)  microtime(x)
+ #define AFS_KALLOC(x)   _MALLOC(x, M_TEMP, M_WAITOK)
+ #define AFS_KFREE(x,y)  _FREE(x,M_TEMP)
+ #define v_count         v_usecount
+ #define v_vfsp          v_mount
+ #define vfs_bsize       mnt_stat.f_bsize
+ #define vfs_fsid        mnt_stat.f_fsid
+ #define va_nodeid       va_fileid
+ #define vfs_vnodecovered mnt_vnodecovered
+ #define direct          dirent
+ 
+ #define BIND_8_COMPAT
+ 
+ #endif
+ #endif /* AFS_PARAM_H */
+ 
+ #else /* !defined(UKERNEL) */
+ 
+ /* This section for user space compiles only */
+ 
+ #ifndef AFS_PARAM_H
+ #define AFS_PARAM_H
+ 
+ #define AFS_VFSINCL_ENV 1	/* NOBODY uses this.... */
+ #define AFS_ENV                 1
+ #define AFS_64BIT_ENV           1	/* Defines afs_int32 as int, not long. */
+ #define AFS_X86_ENV 1
+ 
+ #include <afs/afs_sysnames.h>
+ #define AFS_USERSPACE_ENV
+ #define AFS_USR_DARWIN_ENV
+ #define AFS_USR_DARWIN13_ENV
+ #define AFS_USR_DARWIN14_ENV
+ #define AFS_USR_DARWIN60_ENV
+ #define AFS_USR_DARWIN70_ENV
+ #define AFS_USR_DARWIN80_ENV
+ #define AFS_NONFSTRANS
+ #define AFS_SYSCALL             230
+ #define DARWIN_REFBASE 0
+ 
+ /* File system entry (used if mount.h doesn't define MOUNT_AFS */
+ #define AFS_MOUNT_AFS    "afs"
+ 
+ /* Machine / Operating system information */
+ #define sys_x86_darwin_12   1
+ #define sys_x86_darwin_13   1
+ #define sys_x86_darwin_14   1
+ #define sys_x86_darwin_60   1
+ #define sys_x86_darwin_70   1
+ #define sys_x86_darwin_80   1
+ #define SYS_NAME        "x86_darwin_80"
+ #define SYS_NAME_ID     SYS_NAME_ID_x86_darwin_80
+ #define AFSLITTLE_ENDIAN   1
+ #define AFS_HAVE_FFS    1	/* Use system's ffs. */
+ 
+ #define AFS_UIOSYS      UIO_SYSSPACE
+ #define AFS_UIOUSER     UIO_USERSPACE
+ 
+ #define AFS_GCPAGS                0	/* if nonzero, garbage collect PAGs */
+ #define RXK_LISTENER_ENV          1
+ 
+ #define AFS_VFS34       1	/* What is VFS34??? */
+ #define afsio_iov       uio_iov
+ #define afsio_iovcnt    uio_iovcnt
+ #define afsio_offset    uio_offset
+ #define afsio_seg       uio_segflg
+ #define afsio_resid     uio_resid
+ #define AFS_UIOSYS      UIO_SYSSPACE
+ #define AFS_UIOUSER     UIO_USERSPACE
+ #define        VATTR_NULL      usr_vattr_null
+ 
+ #define AFS_DIRENT
+ #ifndef CMSERVERPREF
+ #define CMSERVERPREF
+ #endif
+ 
+ #define BIND_8_COMPAT
+ #endif /* AFS_PARAM_H */
+ 
+ #endif /* !defined(UKERNEL) */
Index: openafs/src/des/andrew-conf.h
diff -c openafs/src/des/andrew-conf.h:1.16 openafs/src/des/andrew-conf.h:1.16.2.1
*** openafs/src/des/andrew-conf.h:1.16	Tue Feb  3 01:23:37 2004
--- openafs/src/des/andrew-conf.h	Fri Oct 21 00:48:48 2005
***************
*** 93,100 ****
  #endif /* AFS_PPC_LINUX20_ENV */
  #endif /* AFS_PARISC_LINUX24_ENV */
  #else
! #if defined(AFS_DARWIN_ENV) && defined(AFS_PPC_ENV)
! #include "conf-ppc-darwin.h"
  #else
  Sorry,
      you lose.
--- 93,100 ----
  #endif /* AFS_PPC_LINUX20_ENV */
  #endif /* AFS_PARISC_LINUX24_ENV */
  #else
! #if defined(AFS_DARWIN_ENV)
! #include "conf-darwin.h"
  #else
  Sorry,
      you lose.
Index: openafs/src/des/conf-darwin.h
diff -c /dev/null openafs/src/des/conf-darwin.h:1.1.2.2
*** /dev/null	Sat Oct 22 02:14:53 2005
--- openafs/src/des/conf-darwin.h	Fri Oct 21 00:48:48 2005
***************
*** 0 ****
--- 1,11 ----
+ #define BITS32
+ #define BIG
+ #undef BSDUNIX
+ #if defined(__ppc__)
+ #define MSBFIRST
+ #elif defined(__i386__)
+ #define LSBFIRST
+ #else
+ #error "MSBFIRST or LSBFIRST undefined"
+ #endif
+ #define MUSTALIGN
Index: openafs/src/dir/dir.c
diff -c openafs/src/dir/dir.c:1.21.2.2 openafs/src/dir/dir.c:1.21.2.3
*** openafs/src/dir/dir.c:1.21.2.2	Mon Jul 11 15:27:28 2005
--- openafs/src/dir/dir.c	Wed Oct  5 01:58:37 2005
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/dir/dir.c,v 1.21.2.2 2005/07/11 19:27:28 shadow Exp $");
  
  #ifdef KERNEL
  #if !defined(UKERNEL)
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/dir/dir.c,v 1.21.2.3 2005/10/05 05:58:37 shadow Exp $");
  
  #ifdef KERNEL
  #if !defined(UKERNEL)
***************
*** 32,38 ****
  #include "h/kernel.h"
  #endif
  #endif
! #if	defined(AFS_SUN56_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_FBSD_ENV)
  #include "afs/sysincludes.h"
  #endif
  #if !defined(AFS_SGI64_ENV) && !defined(AFS_DARWIN60_ENV)
--- 32,38 ----
  #include "h/kernel.h"
  #endif
  #endif
! #if	defined(AFS_SUN56_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_FBSD_ENV) || defined(AFS_DARWIN80_ENV)
  #include "afs/sysincludes.h"
  #endif
  #if !defined(AFS_SGI64_ENV) && !defined(AFS_DARWIN60_ENV)
Index: openafs/src/libadmin/vos/afs_vosAdmin.c
diff -c openafs/src/libadmin/vos/afs_vosAdmin.c:1.9.10.2 openafs/src/libadmin/vos/afs_vosAdmin.c:1.9
*** openafs/src/libadmin/vos/afs_vosAdmin.c:1.9.10.2	Thu Oct 13 14:29:41 2005
--- openafs/src/libadmin/vos/afs_vosAdmin.c	Sun Dec  7 17:49:32 2003
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/libadmin/vos/afs_vosAdmin.c,v 1.9.10.2 2005/10/13 18:29:41 shadow Exp $");
  
  #include <afs/stds.h>
  #include <stdio.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/libadmin/vos/afs_vosAdmin.c,v 1.9 2003/12/07 22:49:32 jaltman Exp $");
  
  #include <afs/stds.h>
  #include <stdio.h>
Index: openafs/src/libadmin/vos/vsprocs.c
diff -c openafs/src/libadmin/vos/vsprocs.c:1.11.10.2 openafs/src/libadmin/vos/vsprocs.c:1.11
*** openafs/src/libadmin/vos/vsprocs.c:1.11.10.2	Thu Oct 13 14:29:41 2005
--- openafs/src/libadmin/vos/vsprocs.c	Sat Nov 29 17:08:14 2003
***************
*** 22,28 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/libadmin/vos/vsprocs.c,v 1.11.10.2 2005/10/13 18:29:41 shadow Exp $");
  
  #include "vsprocs.h"
  #include "vosutils.h"
--- 22,28 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/libadmin/vos/vsprocs.c,v 1.11 2003/11/29 22:08:14 jaltman Exp $");
  
  #include "vsprocs.h"
  #include "vosutils.h"
Index: openafs/src/libafs/MakefileProto.DARWIN.in
diff -c openafs/src/libafs/MakefileProto.DARWIN.in:1.21.2.1 openafs/src/libafs/MakefileProto.DARWIN.in:1.21.2.4
*** openafs/src/libafs/MakefileProto.DARWIN.in:1.21.2.1	Tue Apr 19 12:03:07 2005
--- openafs/src/libafs/MakefileProto.DARWIN.in	Fri Oct 21 00:48:50 2005
***************
*** 4,10 ****
  # This software has been released under the terms of the IBM Public
  # License.  For details, see the LICENSE file in the top-level source
  # directory or online at http://www.openafs.org/dl/license10.html
! # $Header: /cvs/openafs/src/libafs/MakefileProto.DARWIN.in,v 1.21.2.1 2005/04/19 16:03:07 shadow Exp $
  # 
  # MakefileProto for Digital Unix systems
  #
--- 4,10 ----
  # This software has been released under the terms of the IBM Public
  # License.  For details, see the LICENSE file in the top-level source
  # directory or online at http://www.openafs.org/dl/license10.html
! # $Header: /cvs/openafs/src/libafs/MakefileProto.DARWIN.in,v 1.21.2.4 2005/10/21 04:48:50 shadow Exp $
  # 
  # MakefileProto for Digital Unix systems
  #
***************
*** 33,38 ****
--- 33,46 ----
  KDEFS=
  DBUG = 
  DEFINES= -D_KERNEL -DKERNEL -DKERNEL_PRIVATE -DDIAGNOSTIC -DUSE_SELECT -DMACH_USER_API -DMACH_KERNEL
+ <x86_darwin_80>
+ KOPTS=-static -g -nostdinc -nostdlib -no-cpp-precomp -fno-builtin -finline -fno-keep-inline-functions -msoft-float -mlong-branch -fsigned-bitfields -arch i386 -Di386 -DI386 -D__I386__ -DPAGE_SIZE_FIXED -march=i686 -mpreferred-stack-boundary=2 -falign-functions=4
+ MODLD=$(CC) $(KOPTS)
+ <ppc_darwin_80>
+ KOPTS=-static -g -nostdinc -nostdlib -no-cpp-precomp -fno-builtin -finline -fno-keep-inline-functions -msoft-float -mlong-branch -fsigned-bitfields -arch ppc -Dppc -DPPC -D__PPC__ -DPAGE_SIZE_FIXED -O2 -mcpu=750 -mmultiple -fschedule-insns
+ MODLD=$(CC) $(KOPTS)
+ <all -ppc_darwin_80 -x86_darwin_80>
+ MODLD=$(LD)
  <ppc_darwin_70>
  KOPTS=-static -fno-common -finline -fno-keep-inline-functions -force_cpusubtype_ALL -msoft-float -mlong-branch 
  <ppc_darwin_60>
***************
*** 41,47 ****
  KOPTS=-no-precomp -static -fno-common -finline -fno-keep-inline-functions -force_cpusubtype_ALL -msoft-float -mlong-branch 
  <all>
  CFLAGS=${KINCLUDES} -I. -I.. -I${TOP_OBJDIR}/src/config $(DEFINES) $(KDEFS) $(KOPTS) ${DBUG} ${OPTMZ}
! KINCLUDES=-I${KROOT}/System/Library/Frameworks/Kernel.Framework/Headers
  
  
  # Name of directory to hold object files and libraries.
--- 49,55 ----
  KOPTS=-no-precomp -static -fno-common -finline -fno-keep-inline-functions -force_cpusubtype_ALL -msoft-float -mlong-branch 
  <all>
  CFLAGS=${KINCLUDES} -I. -I.. -I${TOP_OBJDIR}/src/config $(DEFINES) $(KDEFS) $(KOPTS) ${DBUG} ${OPTMZ}
! KINCLUDES=-I${KROOT}/System/Library/Frameworks/Kernel.framework/Headers
  
  
  # Name of directory to hold object files and libraries.
***************
*** 60,74 ****
  	ln -fs ../Makefile $(KOBJ)/Makefile
  	ln -fs ../Makefile.common $(KOBJ)/Makefile.common
  	ln -fs ../config $(KOBJ)/config
! 	-$(RM) -f  h net netinet rpc ufs nfs  machine sys vm mach kern
! 	-ln -fs $(KROOT)/System/Library/Frameworks/Kernel.framework/Headers/net net
! 	-ln -fs $(KROOT)/System/Library/Frameworks/Kernel.framework/Headers/machine machine
! 	-ln -fs $(KROOT)/System/Library/Frameworks/Kernel.framework/Headers/netinet netinet
! 	-ln -fs $(KROOT)/System/Library/Frameworks/Kernel.framework/Headers/nfs nfs
! 	-ln -fs /usr/include/rpc rpc
! 	-ln -fs $(KROOT)/System/Library/Frameworks/Kernel.framework/Headers/sys sys
! 	-ln -fs $(KROOT)/System/Library/Frameworks/Kernel.framework/Headers/ufs ufs
  	-ln -fs $(KROOT)/System/Library/Frameworks/Kernel.framework/Headers/sys h
  
  
  # Below this line are targets when in the COMMON directory:
--- 68,76 ----
  	ln -fs ../Makefile $(KOBJ)/Makefile
  	ln -fs ../Makefile.common $(KOBJ)/Makefile.common
  	ln -fs ../config $(KOBJ)/config
! 	-$(RM) -f  h rpc
  	-ln -fs $(KROOT)/System/Library/Frameworks/Kernel.framework/Headers/sys h
+ 	-ln -fs /usr/include/rpc rpc
  
  
  # Below this line are targets when in the COMMON directory:
***************
*** 98,104 ****
  
  
  ${LIBAFS}: $(AFSAOBJS) $(AFSNFSOBJS)
! 	$(LD) -r -o ${LIBAFS} ${AFSAOBJS} ${AFSNFSOBJS} -lcc_kext
  
  ${LIBAFSNONFS}:  $(AFSAOBJS) $(AFSNONFSOBJS)
! 	$(LD) -r -o ${LIBAFSNONFS} ${AFSAOBJS} ${AFSNONFSOBJS} -lcc_kext
--- 100,106 ----
  
  
  ${LIBAFS}: $(AFSAOBJS) $(AFSNFSOBJS)
! 	$(MODLD) -r -o ${LIBAFS} ${AFSAOBJS} ${AFSNFSOBJS} -lcc_kext
  
  ${LIBAFSNONFS}:  $(AFSAOBJS) $(AFSNONFSOBJS)
! 	$(MODLD) -r -o ${LIBAFSNONFS} ${AFSAOBJS} ${AFSNONFSOBJS} -lcc_kext
Index: openafs/src/libafs/MakefileProto.LINUX.in
diff -c openafs/src/libafs/MakefileProto.LINUX.in:1.40.2.11 openafs/src/libafs/MakefileProto.LINUX.in:1.40.2.12
*** openafs/src/libafs/MakefileProto.LINUX.in:1.40.2.11	Mon Jul 25 14:32:15 2005
--- openafs/src/libafs/MakefileProto.LINUX.in	Fri Oct 14 17:28:14 2005
***************
*** 140,154 ****
  
  ${COMPDIRS} ${INSTDIRS} ${DESTDIRS}:
  	$(RM) -f h 
! 	ln -fs ${LINUX_KERNEL_PATH}/include/linux h 
  	$(RM) -f linux 
  	ln -fs ${LINUX_KERNEL_PATH}/include/linux linux 
  	$(RM) -f net 
  	ln -fs ${LINUX_KERNEL_PATH}/include/net net 
- 	$(RM) -f netinet 
- 	ln -fs ${LINUX_KERNEL_PATH}/include/linux netinet 
- 	$(RM) -f sys
- 	ln -fs ${LINUX_KERNEL_PATH}/include/linux sys
  	$(RM) -f asm-generic
  	ln -fs ${LINUX_KERNEL_PATH}/include/asm-generic asm-generic
  	$(RM) -f asm
--- 140,160 ----
  
  ${COMPDIRS} ${INSTDIRS} ${DESTDIRS}:
  	$(RM) -f h 
! 	$(RM) -f sys
! 	$(RM) -f netinet 
! 	if [ -d ${LINUX_KERNEL_PATH}/include2 ] ; then                  \
! 	    ln -fs ${LINUX_KERNEL_PATH}/include2/asm/../linux h       ; \
! 	    ln -fs ${LINUX_KERNEL_PATH}/include2/asm/../linux sys     ; \
! 	    ln -fs ${LINUX_KERNEL_PATH}/include2/asm/../linux netinet ; \
! 	else                                                            \
! 	    ln -fs ${LINUX_KERNEL_PATH}/include/linux h               ; \
! 	    ln -fs ${LINUX_KERNEL_PATH}/include/linux sys             ; \
! 	    ln -fs ${LINUX_KERNEL_PATH}/include/linux netinet         ; \
! 	fi
  	$(RM) -f linux 
  	ln -fs ${LINUX_KERNEL_PATH}/include/linux linux 
  	$(RM) -f net 
  	ln -fs ${LINUX_KERNEL_PATH}/include/net net 
  	$(RM) -f asm-generic
  	ln -fs ${LINUX_KERNEL_PATH}/include/asm-generic asm-generic
  	$(RM) -f asm
Index: openafs/src/libafs/afs.ppc_darwin_80.plist.in
diff -c openafs/src/libafs/afs.ppc_darwin_80.plist.in:1.1.2.1.4.1 openafs/src/libafs/afs.ppc_darwin_80.plist.in:1.1.2.3
*** openafs/src/libafs/afs.ppc_darwin_80.plist.in:1.1.2.1.4.1	Thu Oct 20 17:13:05 2005
--- openafs/src/libafs/afs.ppc_darwin_80.plist.in	Sat Oct 22 01:58:45 2005
***************
*** 22,31 ****
  	<string>1.4.0</string>
  	<key>OSBundleLibraries</key>
  	<dict>
! 		<key>com.apple.kernel.bsd</key>
  		<string>8.0.0</string>
! 		<key>com.apple.kernel.mach</key>
  		<string>8.0.0</string>
  	</dict>
  </dict>
  </plist>
--- 22,33 ----
  	<string>1.4.0</string>
  	<key>OSBundleLibraries</key>
  	<dict>
! 		<key>com.apple.kpi.bsd</key>
  		<string>8.0.0</string>
! 		<key>com.apple.kpi.mach</key>
  		<string>8.0.0</string>
+ 		<key>com.apple.kpi.libkern</key>
+ 		<string>8.0</string>
  	</dict>
  </dict>
  </plist>
Index: openafs/src/libafsauthent/Makefile.in
diff -c openafs/src/libafsauthent/Makefile.in:1.9.2.3 openafs/src/libafsauthent/Makefile.in:1.9.2.4
*** openafs/src/libafsauthent/Makefile.in:1.9.2.3	Mon Aug  8 11:39:22 2005
--- openafs/src/libafsauthent/Makefile.in	Sat Oct 15 11:21:16 2005
***************
*** 70,76 ****
  	rmtsys.xdr.o \
  	rmtsys.cs.o \
  	afssyscalls.o \
! 	rmtsysnet.o
  
  PTSERVEROBJS = \
  	ptclient.o \
--- 70,78 ----
  	rmtsys.xdr.o \
  	rmtsys.cs.o \
  	afssyscalls.o \
! 	rmtsysnet.o \
! 	glue.o \
! 	setpag.o
  
  PTSERVEROBJS = \
  	ptclient.o \
***************
*** 244,249 ****
--- 246,257 ----
  rmtsysnet.o: ${SYS}/rmtsysnet.c
  	${CCRULE}
  
+ glue.o: ${SYS}/glue.c
+ 	${CCRULE}
+ 
+ setpag.o: ${SYS}/setpag.c
+ 	${CCRULE}
+ 
  clean:
  	$(RM) -f *.o *.a libafsauthent*
  
Index: openafs/src/libuafs/MakefileProto.LINUX.in
diff -c openafs/src/libuafs/MakefileProto.LINUX.in:1.10 openafs/src/libuafs/MakefileProto.LINUX.in:1.10.2.1
*** openafs/src/libuafs/MakefileProto.LINUX.in:1.10	Sun Apr 18 02:10:33 2004
--- openafs/src/libuafs/MakefileProto.LINUX.in	Fri Oct 14 22:14:15 2005
***************
*** 17,23 ****
  # System specific build commands and flags
  DEFINES= -D_REENTRANT -DKERNEL -DUKERNEL
  KOPTS=
! CFLAGS=-I. -I.. -I${TOP_OBJDIR}/src/config ${FSINCLUDES} $(DEFINES) $(KOPTS) ${DBG}
  OPTF=-O
  # WEBOPTS = -I../nsapi -DNETSCAPE_NSAPI -DNET_SSL -DXP_UNIX -DMCC_HTTPD
  
--- 17,29 ----
  # System specific build commands and flags
  DEFINES= -D_REENTRANT -DKERNEL -DUKERNEL
  KOPTS=
! SYS_NAME=@AFS_SYSNAME@
! ifeq (${SYS_NAME}, ppc64_linux26)
! CFLAGS=-fPIC
! else
! CFLAGS=
! endif
! CFLAGS+= -I. -I.. -I${TOP_OBJDIR}/src/config ${FSINCLUDES} $(DEFINES) $(KOPTS) ${DBG}
  OPTF=-O
  # WEBOPTS = -I../nsapi -DNETSCAPE_NSAPI -DNET_SSL -DXP_UNIX -DMCC_HTTPD
  
Index: openafs/src/lwp/Makefile.in
diff -c openafs/src/lwp/Makefile.in:1.29.2.6 openafs/src/lwp/Makefile.in:1.29.2.7
*** openafs/src/lwp/Makefile.in:1.29.2.6	Sun Feb 20 20:12:10 2005
--- openafs/src/lwp/Makefile.in	Fri Oct 21 00:48:51 2005
***************
*** 52,59 ****
  		/lib/cpp -P -I${TOP_INCDIR} ${srcdir}/process.s390x.s >process.ss; \
  		${AS} -ahlns process.ss -o process.o >process.lst; \
  		$(RM) process.ss ;; \
! 	*_darwin* ) \
  		$(CC) ${LWP_DBG} ${LWP_OPTMZ} -c ${XCFLAGS} -I${TOP_INCDIR} ${srcdir}/process.s;; \
  	i386_*bsd*) \
  		cp ${srcdir}/process.i386.s process.S ; \
  		${CCOBJ} -DIGNORE_STDS_H -E -I${srcdir} -I${TOP_INCDIR} process.S > process.ss ; \
--- 52,63 ----
  		/lib/cpp -P -I${TOP_INCDIR} ${srcdir}/process.s390x.s >process.ss; \
  		${AS} -ahlns process.ss -o process.o >process.lst; \
  		$(RM) process.ss ;; \
! 	ppc_darwin* ) \
  		$(CC) ${LWP_DBG} ${LWP_OPTMZ} -c ${XCFLAGS} -I${TOP_INCDIR} ${srcdir}/process.s;; \
+ 	x86_darwin*) \
+ 		/usr/bin/cpp -P -I${TOP_INCDIR} -I${srcdir} ${srcdir}/process.i386.s process.ss; \
+ 		${AS} process.ss -o process.o; \
+ 		$(RM) process.ss ;; \
  	i386_*bsd*) \
  		cp ${srcdir}/process.i386.s process.S ; \
  		${CCOBJ} -DIGNORE_STDS_H -E -I${srcdir} -I${TOP_INCDIR} process.S > process.ss ; \
Index: openafs/src/lwp/process.i386.s
diff -c openafs/src/lwp/process.i386.s:1.5.2.1 openafs/src/lwp/process.i386.s:1.5.2.2
*** openafs/src/lwp/process.i386.s:1.5.2.1	Wed Aug 25 03:00:41 2004
--- openafs/src/lwp/process.i386.s	Fri Oct 21 00:48:51 2005
***************
*** 59,67 ****
--- 59,69 ----
  L1:
  	jmp	*f(%ebp)			/* ebx = &f */
  
+ #if !defined(AFS_DARWIN_ENV)
  /* Shouldn't be here....*/
  
  	call	_C_LABEL(abort)
+ #endif
  
  /*
   * returnto(area2)
***************
*** 83,88 ****
--- 85,92 ----
  	popl	%ebp
  	ret
  
+ #if !defined(AFS_DARWIN_ENV)
  /* I see, said the blind man, as he picked up his hammer and saw! */
  	pushl	$1234
  	call	_C_LABEL(abort)
+ #endif
Index: openafs/src/packaging/MacOS/InstallationCheck
diff -c /dev/null openafs/src/packaging/MacOS/InstallationCheck:1.1.4.2
*** /dev/null	Sat Oct 22 02:14:54 2005
--- openafs/src/packaging/MacOS/InstallationCheck	Sat Oct  8 16:54:03 2005
***************
*** 0 ****
--- 1,10 ----
+ #!/bin/sh
+ majorvers=`uname -r | sed 's/\..*//'`
+ echo "InstallationCheck: os release is $majorvers"
+ if [ $majorvers -ne 8 ]; then
+ echo "InstallationCheck: not ok"
+    exit 112
+ fi
+ 
+ echo "InstallationCheck: ok"
+ exit 0
Index: openafs/src/packaging/MacOS/InstallationCheck.strings
diff -c /dev/null openafs/src/packaging/MacOS/InstallationCheck.strings:1.1.4.2
*** /dev/null	Sat Oct 22 02:14:54 2005
--- openafs/src/packaging/MacOS/InstallationCheck.strings	Sat Oct  8 16:54:03 2005
***************
*** 0 ****
--- 1 ----
+ "16" = "This OpenAFS release requires Tiger (10.4)"
Index: openafs/src/packaging/MacOS/OpenAFS.info
diff -c openafs/src/packaging/MacOS/OpenAFS.info:1.1.4.20.2.3 openafs/src/packaging/MacOS/OpenAFS.info:1.1.4.21
*** openafs/src/packaging/MacOS/OpenAFS.info:1.1.4.20.2.3	Thu Oct 20 17:13:09 2005
--- openafs/src/packaging/MacOS/OpenAFS.info	Sat Oct 22 01:58:45 2005
***************
*** 1,5 ****
  Title OpenAFS
! Version 1.4.0
  Description The OpenAFS distributed filesystem. This package installs an almost-ready-to-run client for OpenAFS. see http://www.openafs.org for more information.
  DefaultLocation /
  Diskname (null)
--- 1,5 ----
  Title OpenAFS
! Version 1.4.1-rc1
  Description The OpenAFS distributed filesystem. This package installs an almost-ready-to-run client for OpenAFS. see http://www.openafs.org for more information.
  DefaultLocation /
  Diskname (null)
Index: openafs/src/packaging/MacOS/ReadMe.rtf
diff -c openafs/src/packaging/MacOS/ReadMe.rtf:1.2.2.1 openafs/src/packaging/MacOS/ReadMe.rtf:1.2.2.2
*** openafs/src/packaging/MacOS/ReadMe.rtf:1.2.2.1	Sun Apr  3 15:14:36 2005
--- openafs/src/packaging/MacOS/ReadMe.rtf	Wed Oct  5 01:58:40 2005
***************
*** 1,13 ****
! {\rtf1\mac\ansicpg10000\cocoartf102
  {\fonttbl\f0\fswiss\fcharset77 Helvetica;}
  {\colortbl;\red255\green255\blue255;}
  \margl1440\margr1440\vieww9000\viewh9000\viewkind0
  \pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
  
! \f0\fs20 \cf0 This release of OpenAFS is known to be compatible with MacOS 10.3 through 10.3.8.\
  \
  Select a client cell name by editing /var/db/openafs/etc/ThisCell\
  \
  The included afssettings program is distributed under the Apple Public Source License, version 2.0. See http://www.opensource.apple.com/apsl/2.0.txt or the included file 2.0.txt.\
  \
! Reboot when all of this is done.}
\ No newline at end of file
--- 1,13 ----
! {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf100
  {\fonttbl\f0\fswiss\fcharset77 Helvetica;}
  {\colortbl;\red255\green255\blue255;}
  \margl1440\margr1440\vieww9000\viewh9000\viewkind0
  \pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
  
! \f0\fs20 \cf0 This pre-release of OpenAFS is targeted at MacOS 10.4.1. It is *not* production ready. Use of this release with afs home directories or Library directories is not recommended. (keychain corruption may occur. keychain-using apps may hang). afssettings does not work either. unmount afs manually before rebooting/shutting down, or the shutdown will not complete. \
  \
  Select a client cell name by editing /var/db/openafs/etc/ThisCell\
  \
  The included afssettings program is distributed under the Apple Public Source License, version 2.0. See http://www.opensource.apple.com/apsl/2.0.txt or the included file 2.0.txt.\
  \
! Reboot when all of this is done.}
Index: openafs/src/packaging/MacOS/buildpkg.sh
diff -c openafs/src/packaging/MacOS/buildpkg.sh:1.4.2.1 openafs/src/packaging/MacOS/buildpkg.sh:1.4.2.3
*** openafs/src/packaging/MacOS/buildpkg.sh:1.4.2.1	Sun Apr  3 15:14:36 2005
--- openafs/src/packaging/MacOS/buildpkg.sh	Fri Oct 21 00:59:16 2005
***************
*** 32,38 ****
  fi
  
  if [ -x /usr/bin/curl ]; then
!     /usr/bin/curl -f -O http://www.central.org/dl/cellservdb/CellServDB
  fi
  
  if [ ! -f CellServDB ]; then
--- 32,39 ----
  fi
  
  if [ -x /usr/bin/curl ]; then
! #    /usr/bin/curl -f -O http://www.central.org/dl/cellservdb/CellServDB
!     /usr/bin/curl -f -O http://dl.central.org/dl/cellservdb/CellServDB
  fi
  
  if [ ! -f CellServDB ]; then
***************
*** 82,87 ****
--- 83,90 ----
  chown -R root${SEP}admin $PKGROOT/Library
  chmod -R o-w $PKGROOT/Library
  chmod -R g+w $PKGROOT/Library
+ chown -R root${SEP}wheel $PKGROOT/Library/StartupItems
+ chmod -R og-w $PKGROOT/Library/StartupItems
  chown -R root${SEP}wheel $PKGROOT/Library/OpenAFS/Tools
  chmod -R og-w $PKGROOT/Library/OpenAFS/Tools
  
***************
*** 111,117 ****
  
  mkdir $PKGROOT/usr $PKGROOT/usr/bin $PKGROOT/usr/sbin
  
! BINLIST="fs klog klog.krb pagsh pagsh.krb pts sys tokens tokens.krb unlog unlog.krb"
  
  # Should these be linked into /usr too?
  OTHER_BINLIST="bos cmdebug rxgen translate_et udebug xstat_cm_test xstat_fs_test"
--- 114,120 ----
  
  mkdir $PKGROOT/usr $PKGROOT/usr/bin $PKGROOT/usr/sbin
  
! BINLIST="fs klog klog.krb pagsh pagsh.krb pts sys tokens tokens.krb unlog unlog.krb aklog"
  
  # Should these be linked into /usr too?
  OTHER_BINLIST="bos cmdebug rxgen translate_et udebug xstat_cm_test xstat_fs_test"
***************
*** 131,137 ****
      cp OpenAFS.post_install $PKGRES/postinstall
      cp OpenAFS.pre_upgrade $PKGRES/preupgrade
      cp OpenAFS.post_install $PKGRES/postupgrade
!     chmod a+x $PKGRES/postinstall $PKGRES/postupgrade $PKGRES/preupgrade
  else
      cp OpenAFS.post_install OpenAFS.pre_upgrade $PKGRES
      cp OpenAFS.post_install $PKGRES/OpenAFS.post_upgrade
--- 134,143 ----
      cp OpenAFS.post_install $PKGRES/postinstall
      cp OpenAFS.pre_upgrade $PKGRES/preupgrade
      cp OpenAFS.post_install $PKGRES/postupgrade
!     cp InstallationCheck $PKGRES
!     mkdir $PKGRES/English.lproj
!     cp InstallationCheck $PKGRES/English.lproj
!     chmod a+x $PKGRES/postinstall $PKGRES/postupgrade $PKGRES/preupgrade $PKGRES/InstallationCheck
  else
      cp OpenAFS.post_install OpenAFS.pre_upgrade $PKGRES
      cp OpenAFS.post_install $PKGRES/OpenAFS.post_upgrade
***************
*** 162,167 ****
--- 168,177 ----
  fi
  
  rm -rf pkgroot pkgres
+ mkdir dmg
+ mv OpenAFS.pkg dmg
+ hdiutil create -srcfolder dmg -volname OpenAFS -anyowners OpenAFS.dmg
+ rm -rf dmg
  # Unfortunately, sudo sets $USER to root, so I can't chown the 
  #.pkg dir back to myself
  #chown -R $USER OpenAFS.pkg
Index: openafs/src/rx/rx.c
diff -c openafs/src/rx/rx.c:1.58.2.28.2.1 openafs/src/rx/rx.c:1.58.2.29
*** openafs/src/rx/rx.c:1.58.2.28.2.1	Sat Oct  8 00:01:00 2005
--- openafs/src/rx/rx.c	Sat Oct  8 00:00:07 2005
***************
*** 17,23 ****
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx.c,v 1.58.2.28.2.1 2005/10/08 04:01:00 jaltman Exp $");
  
  #ifdef KERNEL
  #include "afs/sysincludes.h"
--- 17,23 ----
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx.c,v 1.58.2.29 2005/10/08 04:00:07 jaltman Exp $");
  
  #ifdef KERNEL
  #include "afs/sysincludes.h"
Index: openafs/src/rx/rx_kcommon.c
diff -c openafs/src/rx/rx_kcommon.c:1.44.2.7 openafs/src/rx/rx_kcommon.c:1.44.2.9
*** openafs/src/rx/rx_kcommon.c:1.44.2.7	Fri Sep 16 14:15:09 2005
--- openafs/src/rx/rx_kcommon.c	Sat Oct 15 10:24:29 2005
***************
*** 15,21 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_kcommon.c,v 1.44.2.7 2005/09/16 18:15:09 jaltman Exp $");
  
  #include "rx/rx_kcommon.h"
  
--- 15,21 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_kcommon.c,v 1.44.2.9 2005/10/15 14:24:29 shadow Exp $");
  
  #include "rx/rx_kcommon.h"
  
***************
*** 26,33 ****
  #include "afsint.h"
  
  #ifndef RXK_LISTENER_ENV
! int (*rxk_PacketArrivalProc) (register struct rx_packet * ahandle, register struct sockaddr_in * afrom, char *arock, afs_int32 asize);	/* set to packet allocation procedure */
! int (*rxk_GetPacketProc) (char **ahandle, int asize);
  #endif
  
  osi_socket *rxk_NewSocketHost(afs_uint32 ahost, short aport);
--- 26,33 ----
  #include "afsint.h"
  
  #ifndef RXK_LISTENER_ENV
! int (*rxk_PacketArrivalProc) (struct rx_packet * ahandle, struct sockaddr_in * afrom, struct socket *arock, afs_int32 asize);	/* set to packet allocation procedure */
! int (*rxk_GetPacketProc) (struct rx_packet **ahandle, int asize);
  #endif
  
  osi_socket *rxk_NewSocketHost(afs_uint32 ahost, short aport);
***************
*** 45,50 ****
--- 45,55 ----
  static int numMyNetAddrs = 0;
  #endif
  
+ #if defined(AFS_DARWIN80_ENV)
+ #define sobind sock_bind
+ #define soclose sock_close
+ #endif
+ 
  /* add a port to the monitored list, port # is in network order */
  static int
  rxk_AddPort(u_short aport, char *arock)
***************
*** 284,292 ****
  #ifndef RXK_LISTENER_ENV
  /* asize includes the Rx header */
  static int
! MyPacketProc(char **ahandle, int asize)
  {
!     register struct rx_packet *tp;
  
      /* If this is larger than we expected, increase rx_maxReceiveDataSize */
      /* If we can't scrounge enough cbufs, then we have to drop the packet,
--- 289,297 ----
  #ifndef RXK_LISTENER_ENV
  /* asize includes the Rx header */
  static int
! MyPacketProc(struct rx_packet **ahandle, int asize)
  {
!     struct rx_packet *tp;
  
      /* If this is larger than we expected, increase rx_maxReceiveDataSize */
      /* If we can't scrounge enough cbufs, then we have to drop the packet,
***************
*** 323,342 ****
      if (!tp)
  	return -1;
      /* otherwise we have a packet, set appropriate values */
!     *ahandle = (char *)tp;
      return 0;
  }
  
  static int
! MyArrivalProc(register struct rx_packet *ahandle,
! 	      register struct sockaddr_in *afrom, char *arock,
  	      afs_int32 asize)
  {
      /* handle basic rx packet */
      ahandle->length = asize - RX_HEADER_SIZE;
      rxi_DecodePacketHeader(ahandle);
      ahandle =
! 	rxi_ReceivePacket(ahandle, (struct socket *)arock,
  			  afrom->sin_addr.s_addr, afrom->sin_port, NULL,
  			  NULL);
  
--- 328,348 ----
      if (!tp)
  	return -1;
      /* otherwise we have a packet, set appropriate values */
!     *ahandle = tp;
      return 0;
  }
  
  static int
! MyArrivalProc(struct rx_packet *ahandle,
! 	      struct sockaddr_in *afrom,
! 	      struct socket *arock,
  	      afs_int32 asize)
  {
      /* handle basic rx packet */
      ahandle->length = asize - RX_HEADER_SIZE;
      rxi_DecodePacketHeader(ahandle);
      ahandle =
! 	rxi_ReceivePacket(ahandle, arock,
  			  afrom->sin_addr.s_addr, afrom->sin_port, NULL,
  			  NULL);
  
***************
*** 392,398 ****
--- 398,408 ----
  	pp->ifMTU = RX_REMOTE_PACKET_SIZE;
      }
  #else /* AFS_USERSPACE_IP_ADDR */
+ #ifdef AFS_DARWIN80_ENV
+     ifnet_t ifn;
+ #else
      struct ifnet *ifn;
+ #endif
  
  #if !defined(AFS_SGI62_ENV)
      if (numMyNetAddrs == 0)
***************
*** 405,411 ****
  	/* pp->timeout.usec = 0; */
  	pp->ifMTU = MIN(RX_MAX_PACKET_SIZE, rx_MyMaxSendSize);
  #ifdef IFF_POINTOPOINT
! 	if (ifn->if_flags & IFF_POINTOPOINT) {
  	    /* wish we knew the bit rate and the chunk size, sigh. */
  	    pp->timeout.sec = 4;
  	    pp->ifMTU = RX_PP_PACKET_SIZE;
--- 415,421 ----
  	/* pp->timeout.usec = 0; */
  	pp->ifMTU = MIN(RX_MAX_PACKET_SIZE, rx_MyMaxSendSize);
  #ifdef IFF_POINTOPOINT
! 	if (ifnet_flags(ifn) & IFF_POINTOPOINT) {
  	    /* wish we knew the bit rate and the chunk size, sigh. */
  	    pp->timeout.sec = 4;
  	    pp->ifMTU = RX_PP_PACKET_SIZE;
***************
*** 413,420 ****
  #endif /* IFF_POINTOPOINT */
  	/* Diminish the packet size to one based on the MTU given by
  	 * the interface. */
! 	if (ifn->if_mtu > (RX_IPUDP_SIZE + RX_HEADER_SIZE)) {
! 	    rxmtu = ifn->if_mtu - RX_IPUDP_SIZE;
  	    if (rxmtu < pp->ifMTU)
  		pp->ifMTU = rxmtu;
  	}
--- 423,430 ----
  #endif /* IFF_POINTOPOINT */
  	/* Diminish the packet size to one based on the MTU given by
  	 * the interface. */
! 	if (ifnet_mtu(ifn) > (RX_IPUDP_SIZE + RX_HEADER_SIZE)) {
! 	    rxmtu = ifnet_mtu(ifn) - RX_IPUDP_SIZE;
  	    if (rxmtu < pp->ifMTU)
  		pp->ifMTU = rxmtu;
  	}
***************
*** 615,630 ****
      int i = 0;
      int different = 0;
  
-     register struct ifnet *ifn;
      register int rxmtu, maxmtu;
      afs_uint32 addrs[ADDRSPERSITE];
      int mtus[ADDRSPERSITE];
-     struct ifaddr *ifad;	/* ifnet points to a if_addrlist of ifaddrs */
      afs_uint32 ifinaddr;
  
      memset(addrs, 0, sizeof(addrs));
      memset(mtus, 0, sizeof(mtus));
  
  #if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
      TAILQ_FOREACH(ifn, &ifnet, if_link) {
  	if (i >= ADDRSPERSITE)
--- 625,677 ----
      int i = 0;
      int different = 0;
  
      register int rxmtu, maxmtu;
      afs_uint32 addrs[ADDRSPERSITE];
      int mtus[ADDRSPERSITE];
      afs_uint32 ifinaddr;
+ #if defined(AFS_DARWIN80_ENV)
+     errno_t t;
+     int cnt=0;
+     ifaddr_t *ifads, ifad;
+     register ifnet_t ifn;
+     struct sockaddr sout;
+     struct sockaddr_in *sin;
+ #else
+     struct ifaddr *ifad;	/* ifnet points to a if_addrlist of ifaddrs */
+     register struct ifnet *ifn;
+ #endif
  
      memset(addrs, 0, sizeof(addrs));
      memset(mtus, 0, sizeof(mtus));
  
+ #if defined(AFS_DARWIN80_ENV)
+     t = ifnet_get_address_list_family(NULL, &ifads, AF_INET);
+     if (t == 0) {
+ 	rxmtu = ifnet_mtu(ifn) - RX_IPUDP_SIZE;
+ 	while((ifads[cnt] != NULL) && cnt < ADDRSPERSITE) {
+ 	    t = ifaddr_address(ifads[cnt], &sout, sizeof(sout));
+ 	    sin = (struct sockaddr_in *)&sout;
+ 	    ifinaddr = ntohl(sin->sin_addr.s_addr);
+ 	    if (myNetAddrs[i] != ifinaddr) {
+ 		different++;
+ 	    }
+ 	    mtus[i] = rxmtu;
+ 	    rxmtu = rxi_AdjustIfMTU(rxmtu);
+ 	    maxmtu =
+ 		rxmtu * rxi_nRecvFrags +
+ 		((rxi_nRecvFrags - 1) * UDP_HDR_SIZE);
+ 	    maxmtu = rxi_AdjustMaxMTU(rxmtu, maxmtu);
+ 	    addrs[i++] = ifinaddr;
+ 	    if ((ifinaddr != 0x7f000001) && (maxmtu > rx_maxReceiveSize)) {
+ 		rx_maxReceiveSize = MIN(RX_MAX_PACKET_SIZE, maxmtu);
+ 		rx_maxReceiveSize =
+ 		    MIN(rx_maxReceiveSize, rx_maxReceiveSizeUser);
+ 	    }
+ 	    cnt++;
+ 	}
+ 	ifnet_free_address_list(ifads);
+     }
+ #else
  #if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
      TAILQ_FOREACH(ifn, &ifnet, if_link) {
  	if (i >= ADDRSPERSITE)
***************
*** 670,675 ****
--- 717,723 ----
  	    }
  	}
      }
+ #endif
  
      rx_maxJumboRecvSize =
  	RX_HEADER_SIZE + rxi_nDgramPackets * RX_JUMBOBUFFERSIZE +
***************
*** 688,706 ****
  
  #if defined(AFS_DARWIN60_ENV) || defined(AFS_XBSD_ENV)
  /* Returns ifnet which best matches address */
  struct ifnet *
  rxi_FindIfnet(afs_uint32 addr, afs_uint32 * maskp)
  {
!     struct sockaddr_in s;
      struct ifaddr *ifad;
  
      s.sin_family = AF_INET;
      s.sin_addr.s_addr = addr;
      ifad = ifa_ifwithnet((struct sockaddr *)&s);
  
      if (ifad && maskp)
  	*maskp = ((struct sockaddr_in *)ifad->ifa_netmask)->sin_addr.s_addr;
      return (ifad ? ifad->ifa_ifp : NULL);
  }
  
  #else /* DARWIN60 || XBSD */
--- 736,774 ----
  
  #if defined(AFS_DARWIN60_ENV) || defined(AFS_XBSD_ENV)
  /* Returns ifnet which best matches address */
+ #ifdef AFS_DARWIN80_ENV
+ ifnet_t
+ #else
  struct ifnet *
+ #endif
  rxi_FindIfnet(afs_uint32 addr, afs_uint32 * maskp)
  {
!     struct sockaddr_in s, sr;
! #ifdef AFS_DARWIN80_ENV
!     ifaddr_t ifad;
! #else
      struct ifaddr *ifad;
+ #endif
  
      s.sin_family = AF_INET;
      s.sin_addr.s_addr = addr;
+ #ifdef AFS_DARWIN80_ENV
+     ifad = ifaddr_withnet((struct sockaddr *)&s);
+ #else
      ifad = ifa_ifwithnet((struct sockaddr *)&s);
+ #endif
  
+ #ifdef AFS_DARWIN80_ENV
+     if (ifad && maskp) {
+ 	ifaddr_netmask(ifad, (struct sockaddr *)&sr, sizeof(sr));
+ 	*maskp = sr.sin_addr.s_addr;
+     }
+     return (ifad ? ifaddr_ifnet(ifad) : NULL);
+ #else
      if (ifad && maskp)
  	*maskp = ((struct sockaddr_in *)ifad->ifa_netmask)->sin_addr.s_addr;
      return (ifad ? ifad->ifa_ifp : NULL);
+ #endif
  }
  
  #else /* DARWIN60 || XBSD */
***************
*** 765,771 ****
--- 833,843 ----
  rxk_NewSocketHost(afs_uint32 ahost, short aport)
  {
      register afs_int32 code;
+ #ifdef AFS_DARWIN80_ENV
+     socket_t newSocket;
+ #else
      struct socket *newSocket;
+ #endif
  #if (!defined(AFS_HPUX1122_ENV) && !defined(AFS_FBSD50_ENV))
      struct mbuf *nam;
  #endif
***************
*** 814,819 ****
--- 886,893 ----
  		    afs_osi_credp, curthread);
  #elif defined(AFS_FBSD40_ENV)
      code = socreate(AF_INET, &newSocket, SOCK_DGRAM, IPPROTO_UDP, curproc);
+ #elif defined(AFS_DARWIN80_ENV)
+     code = sock_socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP, NULL, NULL, &newSocket);
  #else
      code = socreate(AF_INET, &newSocket, SOCK_DGRAM, 0);
  #endif /* AFS_HPUX102_ENV */
***************
*** 849,860 ****
--- 923,952 ----
  
      freeb(bindnam);
  #else /* AFS_HPUX110_ENV */
+ #if defined(AFS_DARWIN80_ENV)
+     { 
+        int buflen = 50000;
+        int i,code2;
+        for (i=0;i<2;i++) {
+            code = sock_setsockopt(newSocket, SOL_SOCKET, SO_SNDBUF,
+                                   &buflen, sizeof(buflen));
+            code2 = sock_setsockopt(newSocket, SOL_SOCKET, SO_RCVBUF,
+                                   &buflen, sizeof(buflen));
+            if (!code && !code2)
+                break;
+            if (i == 2)
+ 	      osi_Panic("osi_NewSocket: last attempt to reserve 32K failed!\n");
+            buflen = 32766;
+        }
+     }
+ #else
      code = soreserve(newSocket, 50000, 50000);
      if (code) {
  	code = soreserve(newSocket, 32766, 32766);
  	if (code)
  	    osi_Panic("osi_NewSocket: last attempt to reserve 32K failed!\n");
      }
+ #endif
  #if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
  #if defined(AFS_FBSD50_ENV)
      code = sobind(newSocket, (struct sockaddr *)&myaddr, curthread);
***************
*** 1133,1145 ****
  #ifdef AFS_XBSD_ENV
      rxk_ListenerPid = curproc->p_pid;
  #endif /* AFS_FBSD_ENV */
! #if defined(AFS_DARWIN_ENV)
      rxk_ListenerPid = current_proc()->p_pid;
  #endif
  #if defined(RX_ENABLE_LOCKS) && !defined(AFS_SUN5_ENV)
      AFS_GUNLOCK();
  #endif /* RX_ENABLE_LOCKS && !AFS_SUN5_ENV */
- 
      while (afs_termState != AFSOP_STOP_RXK_LISTENER) {
  	if (rxp) {
  	    rxi_RestoreDataBufs(rxp);
--- 1225,1238 ----
  #ifdef AFS_XBSD_ENV
      rxk_ListenerPid = curproc->p_pid;
  #endif /* AFS_FBSD_ENV */
! #ifdef AFS_DARWIN80_ENV
!     rxk_ListenerPid = proc_selfpid();
! #elif defined(AFS_DARWIN_ENV)
      rxk_ListenerPid = current_proc()->p_pid;
  #endif
  #if defined(RX_ENABLE_LOCKS) && !defined(AFS_SUN5_ENV)
      AFS_GUNLOCK();
  #endif /* RX_ENABLE_LOCKS && !AFS_SUN5_ENV */
      while (afs_termState != AFSOP_STOP_RXK_LISTENER) {
  	if (rxp) {
  	    rxi_RestoreDataBufs(rxp);
Index: openafs/src/rx/rx_kcommon.h
diff -c openafs/src/rx/rx_kcommon.h:1.27.2.3 openafs/src/rx/rx_kcommon.h:1.27.2.4
*** openafs/src/rx/rx_kcommon.h:1.27.2.3	Mon Jul 11 15:13:48 2005
--- openafs/src/rx/rx_kcommon.h	Wed Oct  5 01:58:42 2005
***************
*** 155,160 ****
--- 155,172 ----
  extern struct domain inetdomain;
  #endif /* AFS_XBSD_ENV */
  
+ #ifndef AFS_DARWIN80_ENV
+ #define ifaddr_address_family(x) (x)->ifa_addr->sa_family
+ #define ifaddr_address(x, y, z) memcpy(y, (x)->ifa_addr, z)
+ #define ifaddr_netmask(x, y, z) memcpy(y, (x)->ifa_netmask, z)
+ #define ifaddr_dstaddress(x, y, z) memcpy(y, (x)->ifa_dstaddr, z)
+ #define ifaddr_ifnet(x) (x?(x)->ifa_ifp:0)
+ #define ifnet_flags(x) (x?(x)->if_flags:0)
+ #define ifnet_metric(x) (x?(x)->if_data.ifi_metric:0)
+ /*#define ifnet_mtu(x) (x)->if_mtu*/
+ #define ifaddr_withnet(x) ifa_ifwithnet(x)
+ #endif
+ 
  #endif /* _RX_KCOMMON_H_ */
  
  #endif
Index: openafs/src/rx/rx_kernel.h
diff -c openafs/src/rx/rx_kernel.h:1.13 openafs/src/rx/rx_kernel.h:1.13.2.1
*** openafs/src/rx/rx_kernel.h:1.13	Tue Jul 15 19:16:09 2003
--- openafs/src/rx/rx_kernel.h	Wed Oct  5 01:58:42 2005
***************
*** 41,46 ****
--- 41,53 ----
  #define	osi_YieldIfPossible()
  #define	osi_WakeupAndYieldIfPossible(x)	    rx_Wakeup(x)
  
+ #ifndef AFS_DARWIN80_ENV
+ #define ifnet_mtu(x) (x)->if_mtu
+ #define AFS_IFNET_T struct ifnet *
+ #else
+ #define AFS_IFNET_T ifnet_t
+ #endif
+ 
  #include "afs/longc_procs.h"
  
  #endif /* __RX_KERNEL_INCL_ */
Index: openafs/src/rx/rx_packet.c
diff -c openafs/src/rx/rx_packet.c:1.35.2.17 openafs/src/rx/rx_packet.c:1.35.2.18
*** openafs/src/rx/rx_packet.c:1.35.2.17	Thu Sep 15 22:28:50 2005
--- openafs/src/rx/rx_packet.c	Wed Oct  5 01:58:42 2005
***************
*** 15,21 ****
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_packet.c,v 1.35.2.17 2005/09/16 02:28:50 jaltman Exp $");
  
  #ifdef KERNEL
  #if defined(UKERNEL)
--- 15,21 ----
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_packet.c,v 1.35.2.18 2005/10/05 05:58:42 shadow Exp $");
  
  #ifdef KERNEL
  #if defined(UKERNEL)
***************
*** 1551,1557 ****
  #define m_cpytoc(a, b, c, d)  cpytoc(a, b, c, d)
  #define m_cpytoiovec(a, b, c, d, e) cpytoiovec(a, b, c, d, e)
  #else
! #if !defined(AFS_LINUX20_ENV)
  static int
  m_cpytoiovec(struct mbuf *m, int off, int len, struct iovec iovs[], int niovs)
  {
--- 1551,1557 ----
  #define m_cpytoc(a, b, c, d)  cpytoc(a, b, c, d)
  #define m_cpytoiovec(a, b, c, d, e) cpytoiovec(a, b, c, d, e)
  #else
! #if !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN80_ENV)
  static int
  m_cpytoiovec(struct mbuf *m, int off, int len, struct iovec iovs[], int niovs)
  {
***************
*** 1607,1613 ****
  #endif /* LINUX */
  #endif /* AFS_SUN5_ENV */
  
! #if !defined(AFS_LINUX20_ENV)
  int
  rx_mb_to_packet(amb, free, hdr_len, data_len, phandle)
  #if defined(AFS_SUN5_ENV) || defined(AFS_HPUX110_ENV)
--- 1607,1613 ----
  #endif /* LINUX */
  #endif /* AFS_SUN5_ENV */
  
! #if !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN80_ENV)
  int
  rx_mb_to_packet(amb, free, hdr_len, data_len, phandle)
  #if defined(AFS_SUN5_ENV) || defined(AFS_HPUX110_ENV)
Index: openafs/src/rx/rx_prototypes.h
diff -c openafs/src/rx/rx_prototypes.h:1.14.2.10 openafs/src/rx/rx_prototypes.h:1.14.2.12
*** openafs/src/rx/rx_prototypes.h:1.14.2.10	Sun May 29 23:41:45 2005
--- openafs/src/rx/rx_prototypes.h	Sat Oct 15 10:24:30 2005
***************
*** 309,318 ****
  
  
  /* rx_kcommon.c */
! extern int (*rxk_PacketArrivalProc) (register struct rx_packet * ahandle,
! 				     register struct sockaddr_in * afrom,
! 				     char *arock, afs_int32 asize);
! extern int (*rxk_GetPacketProc) (char **ahandle, int asize);
  extern afs_int32 afs_termState;
  extern int rxk_initDone;
  
--- 309,319 ----
  
  
  /* rx_kcommon.c */
! extern int (*rxk_PacketArrivalProc) (struct rx_packet * ahandle,
! 				     struct sockaddr_in * afrom,
! 				     struct socket *arock,
! 				     afs_int32 asize);
! extern int (*rxk_GetPacketProc) (struct rx_packet **ahandle, int asize);
  extern afs_int32 afs_termState;
  extern int rxk_initDone;
  
***************
*** 348,353 ****
--- 349,358 ----
  extern void rxk_Listener(void);
  #ifndef UKERNEL
  extern void afs_rxevent_daemon(void);
+ #endif
+ #if defined(AFS_DARWIN80_ENV) && defined(KERNEL)
+ extern ifnet_t rxi_FindIfnet(afs_uint32 addr, afs_uint32 * maskp);
+ #else
  extern struct ifnet *rxi_FindIfnet(afs_uint32 addr, afs_uint32 * maskp);
  #endif
  extern void osi_StopListener(void);
Index: openafs/src/rx/xdr.c
diff -c openafs/src/rx/xdr.c:1.9.2.1 openafs/src/rx/xdr.c:1.9.2.2
*** openafs/src/rx/xdr.c:1.9.2.1	Tue Dec  7 01:10:06 2004
--- openafs/src/rx/xdr.c	Wed Oct  5 01:58:42 2005
***************
*** 35,41 ****
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/xdr.c,v 1.9.2.1 2004/12/07 06:10:06 shadow Exp $");
  
  /*
   * xdr.c, Generic XDR routines implementation.
--- 35,41 ----
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/xdr.c,v 1.9.2.2 2005/10/05 05:58:42 shadow Exp $");
  
  /*
   * xdr.c, Generic XDR routines implementation.
***************
*** 58,63 ****
--- 58,64 ----
  #include <stdio.h>
  #endif
  #include "xdr.h"
+ #include "rx.h"
  
  /*
   * constants specific to the xdr "protocol"
Index: openafs/src/rx/xdr_prototypes.h
diff -c openafs/src/rx/xdr_prototypes.h:1.4 openafs/src/rx/xdr_prototypes.h:1.4.2.1
*** openafs/src/rx/xdr_prototypes.h:1.4	Tue Jul 15 19:16:12 2003
--- openafs/src/rx/xdr_prototypes.h	Wed Oct  5 01:58:42 2005
***************
*** 10,22 ****
  #ifndef	_XDR_PROTOTYPES_H
  #define _XDR_PROTOTYPES_H
  
! /* I don't like this, but some of these defs depend on rx.h */
! #if defined(KERNEL) && defined(UKERNEL)
! #include "afs/sysincludes.h"
! #include "rx/rx.h"
! #else
! #include "rx/rx.h"
! #endif
  
  /* xdr_afsuuid.c */
  extern int xdr_afsUUID(XDR * xdrs, afsUUID * objp);
--- 10,16 ----
  #ifndef	_XDR_PROTOTYPES_H
  #define _XDR_PROTOTYPES_H
  
! struct rx_call;
  
  /* xdr_afsuuid.c */
  extern int xdr_afsUUID(XDR * xdrs, afsUUID * objp);
Index: openafs/src/rx/AIX/rx_kmutex.h
diff -c openafs/src/rx/AIX/rx_kmutex.h:1.6.2.1 openafs/src/rx/AIX/rx_kmutex.h:1.6.2.2
*** openafs/src/rx/AIX/rx_kmutex.h:1.6.2.1	Wed Apr 13 22:31:45 2005
--- openafs/src/rx/AIX/rx_kmutex.h	Sat Oct 15 10:24:31 2005
***************
*** 45,51 ****
  #define CV_BROADCAST(_cv)	e_wakeup(_cv)
  typedef simple_lock_data afs_kmutex_t;
  typedef tid_t afs_kcondvar_t;
- #define	osi_rxWakeup(cv)	e_wakeup(cv)
  
  
  #define	LOCK_INIT(a, b)		lock_alloc((void*)(a), LOCK_ALLOC_PIN, 1, 1), \
--- 45,50 ----
Index: openafs/src/rx/AIX/rx_knet.c
diff -c openafs/src/rx/AIX/rx_knet.c:1.11.2.1 openafs/src/rx/AIX/rx_knet.c:1.11.2.2
*** openafs/src/rx/AIX/rx_knet.c:1.11.2.1	Wed Aug 25 03:16:16 2004
--- openafs/src/rx/AIX/rx_knet.c	Sat Oct 15 10:24:31 2005
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/AIX/rx_knet.c,v 1.11.2.1 2004/08/25 07:16:16 shadow Exp $");
  
  #ifdef AFS_AIX41_ENV
  #include "rx/rx_kcommon.h"
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/AIX/rx_knet.c,v 1.11.2.2 2005/10/15 14:24:31 shadow Exp $");
  
  #ifdef AFS_AIX41_ENV
  #include "rx/rx_kcommon.h"
***************
*** 19,33 ****
  static struct protosw parent_proto;	/* udp proto switch */
  
  static void
! rxk_input(am, hlen)
!      register struct mbuf *am;
  {
!     register unsigned short *tsp;
      int hdr;
      struct udphdr *tu;
!     register struct ip *ti;
      struct udpiphdr *tvu;
!     register int i;
      char *phandle;
      long code;
      struct sockaddr_in taddr;
--- 19,32 ----
  static struct protosw parent_proto;	/* udp proto switch */
  
  static void
! rxk_input(struct mbuf *am, int hlen)
  {
!     unsigned short *tsp;
      int hdr;
      struct udphdr *tu;
!     struct ip *ti;
      struct udpiphdr *tvu;
!     int i;
      char *phandle;
      long code;
      struct sockaddr_in taddr;
***************
*** 80,87 ****
  static struct arpcom rxk_bogosity;
  
  /* rxk_kpork -	send pkt over to netwerk kporc for processing */
! rxk_kpork(m)
!      register struct mbuf *m;
  {
      find_input_type(0xdead, m, &rxk_bogosity, 0);
  }
--- 79,85 ----
  static struct arpcom rxk_bogosity;
  
  /* rxk_kpork -	send pkt over to netwerk kporc for processing */
! rxk_kpork(struct mbuf *m)
  {
      find_input_type(0xdead, m, &rxk_bogosity, 0);
  }
***************
*** 108,115 ****
  ip_stripoptions(struct mbuf *m, STRIP_ARG2_TYPE mopt)
  {
      struct ip *ip = mtod(m, struct ip *);
!     register int i;
!     register caddr_t opts;
      int olen;
  
      olen = (ip->ip_hl << 2) - sizeof(struct ip);
--- 106,113 ----
  ip_stripoptions(struct mbuf *m, STRIP_ARG2_TYPE mopt)
  {
      struct ip *ip = mtod(m, struct ip *);
!     int i;
!     caddr_t opts;
      int olen;
  
      olen = (ip->ip_hl << 2) - sizeof(struct ip);
***************
*** 123,138 ****
  }
  
  /* rxk_RX_input -	RX pkt input process */
! rxk_RX_input(am)
!      register struct mbuf *am;
  {
!     register unsigned short *tsp;
      int hdr;
      struct udphdr *tu;
!     register struct ip *ti;
      struct udpiphdr *tvu;
!     register int i;
!     char *phandle;
      long code;
      struct sockaddr_in taddr;
      int tlen;
--- 121,135 ----
  }
  
  /* rxk_RX_input -	RX pkt input process */
! rxk_RX_input(struct mbuf *am)
  {
!     unsigned short *tsp;
      int hdr;
      struct udphdr *tu;
!     struct ip *ti;
      struct udpiphdr *tvu;
!     int i;
!     struct rx_packet *phandle;
      long code;
      struct sockaddr_in taddr;
      int tlen;
***************
*** 245,251 ****
  static
  rxk_isr()
  {
!     register struct mbuf *m;
      IFQ_LOCK_DECL();		/* silly macro has trailing ';'.  Sigh. */
      while (1) {
  	IF_DEQUEUE(&rxk_q, m);
--- 242,248 ----
  static
  rxk_isr()
  {
!     struct mbuf *m;
      IFQ_LOCK_DECL();		/* silly macro has trailing ';'.  Sigh. */
      while (1) {
  	IF_DEQUEUE(&rxk_q, m);
***************
*** 263,269 ****
  static void
  rxk_fasttimo(void)
  {
!     int (*tproc) ();
      struct clock temp;
  
      /* do rx fasttimo processing here */
--- 260,266 ----
  static void
  rxk_fasttimo(void)
  {
!     void (*tproc) (void);
      struct clock temp;
  
      /* do rx fasttimo processing here */
***************
*** 276,282 ****
  void
  rxk_init(void)
  {
!     register struct protosw *pr;
      extern struct protosw *pffindproto();
  
      if (!rxk_initDone && (pr = pffindproto(AF_INET, IPPROTO_UDP, SOCK_DGRAM))) {
--- 273,279 ----
  void
  rxk_init(void)
  {
!     struct protosw *pr;
      extern struct protosw *pffindproto();
  
      if (!rxk_initDone && (pr = pffindproto(AF_INET, IPPROTO_UDP, SOCK_DGRAM))) {
***************
*** 307,314 ****
  void
  shutdown_rxkernel(void)
  {
!     register struct protosw *pr;
!     register int i;
      extern struct protosw *pffindproto();
  
      if (rxk_initDone && (pr = pffindproto(AF_INET, IPPROTO_UDP, SOCK_DGRAM))) {
--- 304,311 ----
  void
  shutdown_rxkernel(void)
  {
!     struct protosw *pr;
!     int i;
      extern struct protosw *pffindproto();
  
      if (rxk_initDone && (pr = pffindproto(AF_INET, IPPROTO_UDP, SOCK_DGRAM))) {
***************
*** 347,356 ****
  osi_NetSend(osi_socket asocket, struct sockaddr_in *addr, struct iovec *dvec,
  	    int nvec, afs_int32 asize, int istack)
  {
!     register struct mbuf *tm, *um;
!     register afs_int32 code;
      struct mbuf *top = 0;
!     register struct mbuf *m, **mp;
      int len, mlen;
      char *tdata;
      caddr_t tpa;
--- 344,353 ----
  osi_NetSend(osi_socket asocket, struct sockaddr_in *addr, struct iovec *dvec,
  	    int nvec, afs_int32 asize, int istack)
  {
!     struct mbuf *tm, *um;
!     afs_int32 code;
      struct mbuf *top = 0;
!     struct mbuf *m, **mp;
      int len, mlen;
      char *tdata;
      caddr_t tpa;
Index: openafs/src/rx/DARWIN/rx_kmutex.c
diff -c openafs/src/rx/DARWIN/rx_kmutex.c:1.3 openafs/src/rx/DARWIN/rx_kmutex.c:1.3.2.1
*** openafs/src/rx/DARWIN/rx_kmutex.c:1.3	Tue Jul 15 19:16:14 2003
--- openafs/src/rx/DARWIN/rx_kmutex.c	Wed Oct  5 01:58:43 2005
***************
*** 17,24 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/DARWIN/rx_kmutex.c,v 1.3 2003/07/15 23:16:14 shadow Exp $");
  
  /*
   * Currently everything is implemented in rx_kmutex.h
   */
--- 17,52 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/DARWIN/rx_kmutex.c,v 1.3.2.1 2005/10/05 05:58:43 shadow Exp $");
  
+ #ifndef AFS_DARWIN80_ENV
  /*
   * Currently everything is implemented in rx_kmutex.h
   */
+ #else
+ #include <afs/sysincludes.h>    /* Standard vendor system headers */
+ #include <afsincludes.h>        /* Afs-based standard headers */
+ #include <afs/afs_stats.h>      /* statistics */
+ #include <sys/malloc.h>
+ #include <sys/namei.h>
+ #include <sys/ubc.h>
+ #if defined(AFS_DARWIN70_ENV)
+ #include <vfs/vfs_support.h>
+ #endif /* defined(AFS_DARWIN70_ENV) */
+ 
+ lck_grp_t * openafs_lck_grp;
+ static lck_grp_attr_t * openafs_lck_grp_attr;
+ void rx_kmutex_setup(void) {
+     openafs_lck_grp_attr= lck_grp_attr_alloc_init();
+     lck_grp_attr_setstat(openafs_lck_grp_attr);
+     
+     openafs_lck_grp = lck_grp_alloc_init("openafs",  openafs_lck_grp_attr);
+     lck_grp_attr_free(openafs_lck_grp_attr);
+     
+ }
+  
+ void rx_kmutex_finish(void) {
+     lck_grp_free(openafs_lck_grp);
+ }
+ 
+ #endif
Index: openafs/src/rx/DARWIN/rx_kmutex.h
diff -c openafs/src/rx/DARWIN/rx_kmutex.h:1.4 openafs/src/rx/DARWIN/rx_kmutex.h:1.4.2.1
*** openafs/src/rx/DARWIN/rx_kmutex.h:1.4	Tue Jul 15 19:16:14 2003
--- openafs/src/rx/DARWIN/rx_kmutex.h	Wed Oct  5 01:58:43 2005
***************
*** 16,22 ****
--- 16,26 ----
  #ifndef _RX_KMUTEX_H_
  #define _RX_KMUTEX_H_
  
+ #ifdef AFS_DARWIN80_ENV
+ #include <kern/locks.h>
+ #else
  #include <sys/lock.h>
+ #endif
  #include <kern/thread.h>
  #include <sys/vm.h>
  
***************
*** 32,61 ****
   * 
   * XXX in darwin, both mach and bsd facilities are available. Should really
   * stick to one or the other (but mach locks don't have a _try.....)
   */
  #define CV_INIT(cv,a,b,c)
  #define CV_DESTROY(cv)
  #ifdef AFS_DARWIN14_ENV
! #define CV_WAIT(cv, lck)    { \
  	                        int isGlockOwner = ISAFS_GLOCK(); \
  	                        if (isGlockOwner) AFS_GUNLOCK();  \
  	                        MUTEX_EXIT(lck);        \
! 	                        sleep(cv, PVFS);                \
  	                        if (isGlockOwner) AFS_GLOCK();  \
  	                        MUTEX_ENTER(lck); \
! 	                    }
  
! #define CV_TIMEDWAIT(cv,lck,t)  { \
  	                        int isGlockOwner = ISAFS_GLOCK(); \
  	                        if (isGlockOwner) AFS_GUNLOCK();  \
  	                        MUTEX_EXIT(lck);        \
! 	                        tsleep(cv,PVFS, "afs_CV_TIMEDWAIT",t);  \
  	                        if (isGlockOwner) AFS_GLOCK();  \
  	                        MUTEX_ENTER(lck);       \
!                             }
  
! #define CV_SIGNAL(cv)           wakeup_one(cv)
! #define CV_BROADCAST(cv)        wakeup(cv)
  #else
  #define CV_WAIT(cv, lck)    { \
  	                        int isGlockOwner = ISAFS_GLOCK(); \
--- 36,83 ----
   * 
   * XXX in darwin, both mach and bsd facilities are available. Should really
   * stick to one or the other (but mach locks don't have a _try.....)
+  *
+  * in darwin 8.0, the bsd lock facility is no longer available, and only one
+  * sleep variant is available. Still no lock_try, but we can work around that.
+  * We can't pass the mutex into msleep, even if we didn't need the two mutex 
+  * hack for lock_try emulation, since msleep won't fixup the owner variable
+  * and we'll panic.
   */
  #define CV_INIT(cv,a,b,c)
  #define CV_DESTROY(cv)
  #ifdef AFS_DARWIN14_ENV
! #ifdef AFS_DARWIN80_ENV
! #define VFSSLEEP(cv) msleep(cv, NULL, PVFS, "afs_CV_WAIT", NULL)
! #define VFSTSLEEP(cv,t) do { \
!    struct timespec ts; \
!    ts.ts_sec = t; \
!    ts.ts_nsec = 0; \
!    msleep(cv, NULL, PVFS, "afs_CV_TIMEDWAIT", &ts); \
! } while(0)
! #else
! #define VFSSLEEP(cv) sleep(cv, PVFS)
! #define VFSTSLEEP(cv, t) tsleep(cv,PVFS, "afs_CV_TIMEDWAIT",t)
! #endif
! #define CV_WAIT(cv, lck)    do { \
  	                        int isGlockOwner = ISAFS_GLOCK(); \
  	                        if (isGlockOwner) AFS_GUNLOCK();  \
  	                        MUTEX_EXIT(lck);        \
! 	                        VFSSLEEP(cv);                \
  	                        if (isGlockOwner) AFS_GLOCK();  \
  	                        MUTEX_ENTER(lck); \
! 	                    } while(0)
  
! #define CV_TIMEDWAIT(cv,lck,t)  do { \
  	                        int isGlockOwner = ISAFS_GLOCK(); \
  	                        if (isGlockOwner) AFS_GUNLOCK();  \
  	                        MUTEX_EXIT(lck);        \
! 	                        VFSTSLEEP(cv,t);  \
  	                        if (isGlockOwner) AFS_GLOCK();  \
  	                        MUTEX_ENTER(lck);       \
!                             } while(0)
  
! #define CV_SIGNAL(cv)           wakeup_one((void *)(cv))
! #define CV_BROADCAST(cv)        wakeup((void *)(cv))
  #else
  #define CV_WAIT(cv, lck)    { \
  	                        int isGlockOwner = ISAFS_GLOCK(); \
***************
*** 82,94 ****
  #define CV_BROADCAST(cv)        thread_wakeup((event_t)(cv))
  #endif
  
  typedef struct {
!     struct lock__bsd__ lock;
      thread_t owner;
  } afs_kmutex_t;
  typedef int afs_kcondvar_t;
  
! #define osi_rxWakeup(cv)        thread_wakeup((event_t)(cv))
  
  #define LOCK_INIT(a,b) \
      do { \
--- 104,189 ----
  #define CV_BROADCAST(cv)        thread_wakeup((event_t)(cv))
  #endif
  
+ #ifdef AFS_DARWIN80_ENV
  typedef struct {
!     lck_mtx_t *meta;
!     int waiters; /* also includes anyone holding the lock */
!     lck_mtx_t *lock;
      thread_t owner;
  } afs_kmutex_t;
  typedef int afs_kcondvar_t;
  
! extern lck_grp_t * openafs_lck_grp;
! 
! #define MUTEX_SETUP() rx_kmutex_setup()
! #define MUTEX_FINISH() rx_kmutex_finish()
! #define LOCKINIT(a) \
!     do { \
!         lck_attr_t *openafs_lck_attr = lck_attr_alloc_init(); \
!         (a) = lck_mtx_alloc_init(openafs_lck_grp, openafs_lck_attr); \
!         lck_attr_free(openafs_lck_attr); \
!     } while(0)
! #define MUTEX_INIT(a,b,c,d) \
!     do { \
!         lck_attr_t *openafs_lck_attr = lck_attr_alloc_init(); \
!         (a)->meta = lck_mtx_alloc_init(openafs_lck_grp, openafs_lck_attr); \
!         (a)->lock = lck_mtx_alloc_init(openafs_lck_grp, openafs_lck_attr); \
!         lck_attr_free(openafs_lck_attr); \
! 	(a)->waiters = 0; \
! 	(a)->owner = (thread_t)0; \
!     } while(0)
! #define MUTEX_DESTROY(a) \
!     do { \
!         lck_mtx_destroy((a)->lock, openafs_lck_grp); \
!         lck_mtx_destroy((a)->meta, openafs_lck_grp); \
! 	(a)->owner = (thread_t)-1; \
!     } while(0)
! #define MUTEX_ENTER(a) \
!     do { \
! 	lck_mtx_lock((a)->meta); \
! 	(a)->waiters++; \
! 	lck_mtx_unlock((a)->meta); \
! 	lck_mtx_lock((a)->lock); \
! 	osi_Assert((a)->owner == (thread_t)0); \
! 	(a)->owner = current_thread(); \
!     } while(0)
! 
! /* acquire main lock before releasing meta lock, so we don't race */
! #define MUTEX_TRYENTER(a) ({ \
!     int _ret; \
!     lck_mtx_lock((a)->meta); \
!     if ((a)->waiters) { \
!        lck_mtx_unlock((a)->meta); \
!        _ret = 0; \
!     } else { \
!        (a)->waiters++; \
!        lck_mtx_lock((a)->lock); \
!        lck_mtx_unlock((a)->meta); \
!        osi_Assert((a)->owner == (thread_t)0); \
!        (a)->owner = current_thread(); \
!        _ret = 1; \
!     } \
!     _ret; \
! })
! 
! #define MUTEX_EXIT(a) \
!     do { \
! 	osi_Assert((a)->owner == current_thread()); \
! 	(a)->owner = (thread_t)0; \
! 	lck_mtx_unlock((a)->lock); \
! 	lck_mtx_lock((a)->meta); \
! 	(a)->waiters--; \
! 	lck_mtx_unlock((a)->meta); \
!     } while(0)
! 
! #undef MUTEX_ISMINE
! #define MUTEX_ISMINE(a) (((afs_kmutex_t *)(a))->owner == current_thread())
! #else
! typedef struct {
!     struct lock__bsd__ lock;
!     thread_t owner;
! } afs_kmutex_t;
! typedef int afs_kcondvar_t;
  
  #define LOCK_INIT(a,b) \
      do { \
***************
*** 112,119 ****
      } while(0);
  #define MUTEX_TRYENTER(a) \
      ( lockmgr(&(a)->lock, LK_EXCLUSIVE|LK_NOWAIT, 0, current_proc()) ? 0 : ((a)->owner = current_thread(), 1) )
- #define xMUTEX_TRYENTER(a) \
-     ( osi_Assert((a)->owner == (thread_t)0), (a)->owner = current_thread(), 1)
  #define MUTEX_EXIT(a) \
      do { \
  	osi_Assert((a)->owner == current_thread()); \
--- 207,212 ----
***************
*** 123,128 ****
--- 216,222 ----
  
  #undef MUTEX_ISMINE
  #define MUTEX_ISMINE(a) (((afs_kmutex_t *)(a))->owner == current_thread())
+ #endif
  
  #undef osirx_AssertMine
  extern void osirx_AssertMine(afs_kmutex_t * lockaddr, char *msg);
Index: openafs/src/rx/DARWIN/rx_knet.c
diff -c openafs/src/rx/DARWIN/rx_knet.c:1.10 openafs/src/rx/DARWIN/rx_knet.c:1.10.2.1
*** openafs/src/rx/DARWIN/rx_knet.c:1.10	Tue Jul 15 19:16:14 2003
--- openafs/src/rx/DARWIN/rx_knet.c	Wed Oct  5 01:58:43 2005
***************
*** 11,30 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/DARWIN/rx_knet.c,v 1.10 2003/07/15 23:16:14 shadow Exp $");
  
  #include "rx/rx_kcommon.h"
  
  int
  osi_NetReceive(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec,
  	       int nvecs, int *alength)
  {
      struct socket *asocket = (struct socket *)so;
      struct uio u;
      int i;
      struct iovec iov[RX_MAXIOVECS];
      struct sockaddr *sa = NULL;
      int code;
  
      int haveGlock = ISAFS_GLOCK();
      /*AFS_STATCNT(osi_NetReceive); */
--- 11,43 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/DARWIN/rx_knet.c,v 1.10.2.1 2005/10/05 05:58:43 shadow Exp $");
  
  #include "rx/rx_kcommon.h"
  
+ #ifdef AFS_DARWIN80_ENV
+ #define soclose sock_close
+ #endif
+  
  int
  osi_NetReceive(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec,
  	       int nvecs, int *alength)
  {
+ #ifdef AFS_DARWIN80_ENV
+     socket_t asocket = (socket_t)so;
+     struct msghdr msg;
+     struct sockaddr_storage ss;
+     int rlen;
+     mbuf_t m;
+ #else
      struct socket *asocket = (struct socket *)so;
      struct uio u;
+ #endif
      int i;
      struct iovec iov[RX_MAXIOVECS];
      struct sockaddr *sa = NULL;
      int code;
+     size_t resid;
  
      int haveGlock = ISAFS_GLOCK();
      /*AFS_STATCNT(osi_NetReceive); */
***************
*** 34,39 ****
--- 47,105 ----
  
      for (i = 0; i < nvecs; i++)
  	iov[i] = dvec[i];
+     if (haveGlock)
+ 	AFS_GUNLOCK();
+ #if defined(KERNEL_FUNNEL)
+     thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL);
+ #endif
+ #ifdef AFS_DARWIN80_ENV
+ #if 1
+     resid = *alength;
+     memset(&msg, 0, sizeof(struct msghdr));
+     msg.msg_name = &ss;
+     msg.msg_namelen = sizeof(struct sockaddr_storage);
+     sa =(struct sockaddr *) &ss;
+     code = sock_receivembuf(asocket, &msg, &m, 0, alength);
+     if (!code) {
+         size_t offset=0,sz;
+         resid = *alength;
+         for (i=0;i<nvecs && resid;i++) {
+             sz=MIN(resid, iov[i].iov_len);
+             code = mbuf_copydata(m, offset, sz, iov[i].iov_base);
+             if (code)
+                 break;
+             resid-=sz;
+             offset+=sz;
+         }
+     }
+     mbuf_freem(m);
+ #else
+     resid = *alength;
+     printf("Want to read %d bytes...", resid);
+     for (i=0; i < nvecs && resid; i++) {
+        if (resid < iov[i].iov_len)
+           iov[0].iov_len = resid;
+        resid -= iov[i].iov_len;
+     }
+     printf("Using %d/%d iovs\n", i, nvecs);
+     nvecs = i;
+     rlen = 0;
+     memset(&msg, 0, sizeof(struct msghdr));
+     msg.msg_name = &ss;
+     msg.msg_namelen = sizeof(struct sockaddr_storage);
+     msg.msg_iov = &iov[0];
+     msg.msg_iovlen = nvecs;
+     sa =(struct sockaddr_in *) &ss;
+     code = sock_receive(asocket, &msg, 0, &rlen);
+     resid = *alength;
+     if (resid != rlen)
+     printf("recieved %d bytes\n", rlen);
+     if (resid > rlen)
+        resid -= rlen;
+     else
+        resid = 0;
+ #endif
+ #else
  
      u.uio_iov = &iov[0];
      u.uio_iovcnt = nvecs;
***************
*** 42,55 ****
      u.uio_segflg = UIO_SYSSPACE;
      u.uio_rw = UIO_READ;
      u.uio_procp = NULL;
- 
-     if (haveGlock)
- 	AFS_GUNLOCK();
- #if defined(AFS_DARWIN_ENV) && defined(KERNEL_FUNNEL)
-     thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL);
- #endif
      code = soreceive(asocket, &sa, &u, NULL, NULL, NULL);
! #if defined(AFS_DARWIN_ENV) && defined(KERNEL_FUNNEL)
      thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);
  #endif
      if (haveGlock)
--- 108,118 ----
      u.uio_segflg = UIO_SYSSPACE;
      u.uio_rw = UIO_READ;
      u.uio_procp = NULL;
      code = soreceive(asocket, &sa, &u, NULL, NULL, NULL);
!     resid = u.uio_resid;
! #endif
! 
! #if defined(KERNEL_FUNNEL)
      thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);
  #endif
      if (haveGlock)
***************
*** 57,63 ****
  
      if (code)
  	return code;
!     *alength -= u.uio_resid;
      if (sa) {
  	if (sa->sa_family == AF_INET) {
  	    if (addr)
--- 120,126 ----
  
      if (code)
  	return code;
!     *alength -= resid;
      if (sa) {
  	if (sa->sa_family == AF_INET) {
  	    if (addr)
***************
*** 75,100 ****
  {
      struct proc *p;
  
! #if defined(AFS_DARWIN_ENV) && defined(KERNEL_FUNNEL)
      thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL);
  #endif
      soclose(rx_socket);
! #if defined(AFS_DARWIN_ENV) && defined(KERNEL_FUNNEL)
      thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);
  #endif
      p = pfind(rxk_ListenerPid);
      if (p)
  	psignal(p, SIGUSR1);
  }
  
  int
! osi_NetSend(osi_socket asocket, struct sockaddr_in *addr, struct iovec *dvec,
  	    int nvecs, afs_int32 alength, int istack)
  {
      register afs_int32 code;
      int i;
      struct iovec iov[RX_MAXIOVECS];
-     struct uio u;
      int haveGlock = ISAFS_GLOCK();
  
      AFS_STATCNT(osi_NetSend);
--- 138,174 ----
  {
      struct proc *p;
  
! #if defined(KERNEL_FUNNEL)
      thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL);
  #endif
      soclose(rx_socket);
! #if defined(KERNEL_FUNNEL)
      thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);
  #endif
+ #ifdef AFS_DARWIN80_ENV
+     proc_signal(rxk_ListenerPid, SIGUSR1);
+ #else
      p = pfind(rxk_ListenerPid);
      if (p)
  	psignal(p, SIGUSR1);
+ #endif
  }
  
  int
! osi_NetSend(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec,
  	    int nvecs, afs_int32 alength, int istack)
  {
+ #ifdef AFS_DARWIN80_ENV
+     socket_t asocket = (socket_t)so;
+     struct msghdr msg;
+     size_t slen;
+ #else
+     struct socket *asocket = (struct socket *)so;
+     struct uio u;
+ #endif
      register afs_int32 code;
      int i;
      struct iovec iov[RX_MAXIOVECS];
      int haveGlock = ISAFS_GLOCK();
  
      AFS_STATCNT(osi_NetSend);
***************
*** 104,109 ****
--- 178,198 ----
      for (i = 0; i < nvecs; i++)
  	iov[i] = dvec[i];
  
+     addr->sin_len = sizeof(struct sockaddr_in);
+ 
+     if (haveGlock)
+ 	AFS_GUNLOCK();
+ #if defined(KERNEL_FUNNEL)
+     thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL);
+ #endif
+ #ifdef AFS_DARWIN80_ENV
+     memset(&msg, 0, sizeof(struct msghdr));
+     msg.msg_name = addr;
+     msg.msg_namelen = ((struct sockaddr *)addr)->sa_len;
+     msg.msg_iov = &iov[0];
+     msg.msg_iovlen = nvecs;
+     code = sock_send(asocket, &msg, 0, &slen);
+ #else
      u.uio_iov = &iov[0];
      u.uio_iovcnt = nvecs;
      u.uio_offset = 0;
***************
*** 111,126 ****
      u.uio_segflg = UIO_SYSSPACE;
      u.uio_rw = UIO_WRITE;
      u.uio_procp = NULL;
- 
-     addr->sin_len = sizeof(struct sockaddr_in);
- 
-     if (haveGlock)
- 	AFS_GUNLOCK();
- #if defined(AFS_DARWIN_ENV) && defined(KERNEL_FUNNEL)
-     thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL);
- #endif
      code = sosend(asocket, (struct sockaddr *)addr, &u, NULL, NULL, 0);
! #if defined(AFS_DARWIN_ENV) && defined(KERNEL_FUNNEL)
      thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);
  #endif
      if (haveGlock)
--- 200,209 ----
      u.uio_segflg = UIO_SYSSPACE;
      u.uio_rw = UIO_WRITE;
      u.uio_procp = NULL;
      code = sosend(asocket, (struct sockaddr *)addr, &u, NULL, NULL, 0);
! #endif
! 
! #if defined(KERNEL_FUNNEL)
      thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);
  #endif
      if (haveGlock)
Index: openafs/src/rx/UKERNEL/rx_kcommon.h
diff -c openafs/src/rx/UKERNEL/rx_kcommon.h:1.4 openafs/src/rx/UKERNEL/rx_kcommon.h:1.4.2.1
*** openafs/src/rx/UKERNEL/rx_kcommon.h:1.4	Tue Oct 15 23:59:02 2002
--- openafs/src/rx/UKERNEL/rx_kcommon.h	Wed Oct  5 01:58:45 2005
***************
*** 36,39 ****
--- 36,41 ----
  extern rxk_ports_t rxk_ports;
  extern rxk_portRocks_t rxk_portRocks;
  
+ #define ifnet_flags(x) (x?(x)->if_flags:0)
+ 
  #endif /* _RX_KCOMMON_H_ */
Index: openafs/src/rxgen/rpc_hout.c
diff -c openafs/src/rxgen/rpc_hout.c:1.7.10.2 openafs/src/rxgen/rpc_hout.c:1.7.2.2
*** openafs/src/rxgen/rpc_hout.c:1.7.10.2	Sat Oct 15 17:53:58 2005
--- openafs/src/rxgen/rpc_hout.c	Sat Oct 15 17:52:31 2005
***************
*** 36,42 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rxgen/rpc_hout.c,v 1.7.10.2 2005/10/15 21:53:58 jaltman Exp $");
  
  #include <stdio.h>
  #include <string.h>
--- 36,42 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rxgen/rpc_hout.c,v 1.7.2.2 2005/10/15 21:52:31 jaltman Exp $");
  
  #include <stdio.h>
  #include <string.h>
Index: openafs/src/rxgen/rpc_parse.c
diff -c openafs/src/rxgen/rpc_parse.c:1.18.10.1 openafs/src/rxgen/rpc_parse.c:1.18.2.1
*** openafs/src/rxgen/rpc_parse.c:1.18.10.1	Fri Oct 14 21:21:21 2005
--- openafs/src/rxgen/rpc_parse.c	Fri Oct 14 21:20:03 2005
***************
*** 36,42 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rxgen/rpc_parse.c,v 1.18.10.1 2005/10/15 01:21:21 shadow Exp $");
  
  #include <stdlib.h>
  #include <stdio.h>
--- 36,42 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rxgen/rpc_parse.c,v 1.18.2.1 2005/10/15 01:20:03 shadow Exp $");
  
  #include <stdlib.h>
  #include <stdio.h>
Index: openafs/src/shlibafsauthent/Makefile.in
diff -c openafs/src/shlibafsauthent/Makefile.in:1.9.2.3 openafs/src/shlibafsauthent/Makefile.in:1.9.2.5
*** openafs/src/shlibafsauthent/Makefile.in:1.9.2.3	Mon Aug  8 11:39:23 2005
--- openafs/src/shlibafsauthent/Makefile.in	Sat Oct 15 11:21:17 2005
***************
*** 75,81 ****
  	rmtsys.xdr.o \
  	rmtsys.cs.o \
  	afssyscalls.o \
! 	rmtsysnet.o
  
  PTSERVEROBJS = \
  	ptclient.o \
--- 75,83 ----
  	rmtsys.xdr.o \
  	rmtsys.cs.o \
  	afssyscalls.o \
! 	rmtsysnet.o \
! 	glue.o \
! 	setpag.o
  
  PTSERVEROBJS = \
  	ptclient.o \
***************
*** 99,118 ****
  
  ${DEST}/lib/${LIBAFSAUTHENT}: ${LIBAFSAUTHENT}
  	${INSTALL} ${LIBAFSAUTHENT} ${DEST}/lib/${LIBAFSAUTHENT}
- 
- ${DEST}/lib/libafsauthent.${SHLIB_SUFFIX}: ${DEST}/lib/${LIBAFSAUTHENT}
  	-ln -f -s ${LIBAFSAUTHENT} ${DEST}/lib/libafsauthent.${SHLIB_SUFFIX}
  
! all: ${TOP_LIBDIR}/${LIBAFSAUTHENT} ${TOP_LIBDIR}/libafsauthent.${SHLIB_SUFFIX}
  
! install: ${DESTDIR}${libdir}/${LIBAFSAUTHENT} ${DESTDIR}${libdir}/libafsauthent.${SHLIB_SUFFIX}
  
  ${LIBAFSAUTHENT}: ${LIBOBJS}
  	case ${SYS_NAME} in \
  	rs_aix4*) \
  		${SHLIB_LINKER} -o ${LIBAFSAUTHENT} ${LIBOBJS} -L${TOP_LIBDIR} -bE:afsauthent.exp -lafsrpc ${MT_LIBS};; \
  	sun*_5*) \
! 		${SHLIB_LINKER} -h ${LIBAFSAUTHENT} -o ${LIBAFSAUTHENT} ${LIBOBJS} -L${TOP_LIBDIR} -lafsrpc ${MT_LIBS};; \
  	*) \
  		${SHLIB_LINKER} -o ${LIBAFSAUTHENT} ${LIBOBJS} -L${TOP_LIBDIR} -lafsrpc ${MT_LIBS};; \
  	esac
--- 101,121 ----
  
  ${DEST}/lib/${LIBAFSAUTHENT}: ${LIBAFSAUTHENT}
  	${INSTALL} ${LIBAFSAUTHENT} ${DEST}/lib/${LIBAFSAUTHENT}
  	-ln -f -s ${LIBAFSAUTHENT} ${DEST}/lib/libafsauthent.${SHLIB_SUFFIX}
+ 	-ln -f -s ${LIBAFSAUTHENT} ${DEST}/lib/libafsauthent.${SHLIB_SUFFIX}.${LIBAFSAUTHENTMAJOR}
  
! all: ${TOP_LIBDIR}/${LIBAFSAUTHENT}
  
! install: ${DESTDIR}${libdir}/${LIBAFSAUTHENT}
  
  ${LIBAFSAUTHENT}: ${LIBOBJS}
  	case ${SYS_NAME} in \
  	rs_aix4*) \
  		${SHLIB_LINKER} -o ${LIBAFSAUTHENT} ${LIBOBJS} -L${TOP_LIBDIR} -bE:afsauthent.exp -lafsrpc ${MT_LIBS};; \
  	sun*_5*) \
! 		${SHLIB_LINKER} -h libafsauthent.${SHLIB_SUFFIX}.${LIBAFSAUTHENTMAJOR} -o ${LIBAFSAUTHENT} ${LIBOBJS} -L${TOP_LIBDIR} -lafsrpc ${MT_LIBS};; \
! 	*_linux*) \
! 		${SHLIB_LINKER} -Wl,-h,libafsauthent.${SHLIB_SUFFIX}.${LIBAFSAUTHENTMAJOR} -Wl,--version-script=mapfile -o ${LIBAFSAUTHENT} ${LIBOBJS} -L${TOP_LIBDIR} -lafsrpc ${MT_LIBS};; \
  	*) \
  		${SHLIB_LINKER} -o ${LIBAFSAUTHENT} ${LIBOBJS} -L${TOP_LIBDIR} -lafsrpc ${MT_LIBS};; \
  	esac
***************
*** 259,279 ****
  rmtsysnet.o: ${SYS}/rmtsysnet.c
  	${CCRULE}
  
  clean:
  	$(RM) -f *.o *.a libafsauthent*
  
  ${DESTDIR}${libdir}/${LIBAFSAUTHENT}: ${LIBAFSAUTHENT}
  	${INSTALL} ${LIBAFSAUTHENT} ${DESTDIR}${libdir}/${LIBAFSAUTHENT}
- 
- ${DESTDIR}${libdir}/libafsauthent.${SHLIB_SUFFIX}: ${DESTDIR}${libdir}/${LIBAFSAUTHENT}
  	-ln -f -s ${LIBAFSAUTHENT} ${DESTDIR}${libdir}/libafsauthent.${SHLIB_SUFFIX}
  
  ${TOP_LIBDIR}/${LIBAFSAUTHENT}: ${LIBAFSAUTHENT}
  	${INSTALL} ${LIBAFSAUTHENT} ${TOP_LIBDIR}/${LIBAFSAUTHENT}
- 
- ${TOP_LIBDIR}/libafsauthent.${SHLIB_SUFFIX}: ${TOP_LIBDIR}/${LIBAFSAUTHENT}
  	-ln -f -s ${LIBAFSAUTHENT} ${TOP_LIBDIR}/libafsauthent.${SHLIB_SUFFIX}
  
! dest: ${DEST}/lib/${LIBAFSAUTHENT} ${DEST}/lib/libafsauthent.${SHLIB_SUFFIX}
! 
! 
--- 262,284 ----
  rmtsysnet.o: ${SYS}/rmtsysnet.c
  	${CCRULE}
  
+ glue.o: ${SYS}/glue.c
+ 	${CCRULE}
+ 
+ setpag.o: ${SYS}/setpag.c
+ 	${CCRULE}
+ 
  clean:
  	$(RM) -f *.o *.a libafsauthent*
  
  ${DESTDIR}${libdir}/${LIBAFSAUTHENT}: ${LIBAFSAUTHENT}
  	${INSTALL} ${LIBAFSAUTHENT} ${DESTDIR}${libdir}/${LIBAFSAUTHENT}
  	-ln -f -s ${LIBAFSAUTHENT} ${DESTDIR}${libdir}/libafsauthent.${SHLIB_SUFFIX}
+ 	-ln -f -s ${LIBAFSAUTHENT} ${DESTDIR}${libdir}/libafsauthent.${SHLIB_SUFFIX}.${LIBFASAUTHENTMAJOR}
  
  ${TOP_LIBDIR}/${LIBAFSAUTHENT}: ${LIBAFSAUTHENT}
  	${INSTALL} ${LIBAFSAUTHENT} ${TOP_LIBDIR}/${LIBAFSAUTHENT}
  	-ln -f -s ${LIBAFSAUTHENT} ${TOP_LIBDIR}/libafsauthent.${SHLIB_SUFFIX}
+ 	-ln -f -s ${LIBAFSAUTHENT} ${TOP_LIBDIR}/libafsauthent.${SHLIB_SUFFIX}.${LIBAFSAUTHENTMAJOR}
  
! dest: ${DEST}/lib/${LIBAFSAUTHENT}
Index: openafs/src/shlibafsrpc/Makefile.in
diff -c openafs/src/shlibafsrpc/Makefile.in:1.15.2.5 openafs/src/shlibafsrpc/Makefile.in:1.15.2.6
*** openafs/src/shlibafsrpc/Makefile.in:1.15.2.5	Fri Sep  2 19:38:54 2005
--- openafs/src/shlibafsrpc/Makefile.in	Sat Oct 15 11:09:00 2005
***************
*** 132,153 ****
  
  LIBAFSRPC = libafsrpc.${SHLIB_SUFFIX}.${LIBAFSRPCMAJOR}.${LIBAFSRPCMINOR}
  
! all: ${TOP_LIBDIR}/${LIBAFSRPC} ${TOP_LIBDIR}/libafsrpc.${SHLIB_SUFFIX}
  
! install: ${DESTDIR}${libdir}/${LIBAFSRPC} ${DESTDIR}${libdir}/libafsrpc.${SHLIB_SUFFIX}
  
  ${DEST}/lib/${LIBAFSRPC}: ${LIBAFSRPC}
  	${INSTALL} ${LIBAFSRPC} ${DEST}/lib/${LIBAFSRPC}
- 
- ${DEST}/lib/libafsrpc.${SHLIB_SUFFIX}: ${DEST}/lib/${LIBAFSRPC}
  	-ln -f -s ${LIBAFSRPC} ${DEST}/lib/libafsrpc.${SHLIB_SUFFIX}
  
  ${LIBAFSRPC}: ${LIBOBJS}
  	case ${SYS_NAME} in \
  	rs_aix4* | rs_aix5*) \
  		${SHLIB_LINKER} -o ${LIBAFSRPC} ${LIBOBJS} -bE:${srcdir}/afsrpc.exp ${MT_LIBS};; \
  	sun*_5*) \
! 		${SHLIB_LINKER} -h ${LIBAFSRPC} -o ${LIBAFSRPC} ${LIBOBJS} ${MT_LIBS};; \
  	*) \
  		${SHLIB_LINKER} -o ${LIBAFSRPC} ${LIBOBJS} ${MT_LIBS};; \
  	esac
--- 132,154 ----
  
  LIBAFSRPC = libafsrpc.${SHLIB_SUFFIX}.${LIBAFSRPCMAJOR}.${LIBAFSRPCMINOR}
  
! all: ${TOP_LIBDIR}/${LIBAFSRPC}
  
! install: ${DESTDIR}${libdir}/${LIBAFSRPC}
  
  ${DEST}/lib/${LIBAFSRPC}: ${LIBAFSRPC}
  	${INSTALL} ${LIBAFSRPC} ${DEST}/lib/${LIBAFSRPC}
  	-ln -f -s ${LIBAFSRPC} ${DEST}/lib/libafsrpc.${SHLIB_SUFFIX}
+ 	-ln -f -s ${LIBAFSRPC} ${DEST}/lib/libafsrpc.${SHLIB_SUFFIX}.${LIBAFSRPCMAJOR}
  
  ${LIBAFSRPC}: ${LIBOBJS}
  	case ${SYS_NAME} in \
  	rs_aix4* | rs_aix5*) \
  		${SHLIB_LINKER} -o ${LIBAFSRPC} ${LIBOBJS} -bE:${srcdir}/afsrpc.exp ${MT_LIBS};; \
  	sun*_5*) \
! 		${SHLIB_LINKER} -h libafsrpc.${SHLIB_SUFFIX}.${LIBAFSRPCMAJOR} -o ${LIBAFSRPC} ${LIBOBJS} ${MT_LIBS};; \
! 	*_linux*) \
! 		${SHLIB_LINKER} -Wl,-h,libafsrpc.${SHLIB_SUFFIX}.${LIBAFSRPCMAJOR} -Wl,--version-script=mapfile -o ${LIBAFSRPC} ${LIBOBJS} ${MT_LIBS};; \
  	*) \
  		${SHLIB_LINKER} -o ${LIBAFSRPC} ${LIBOBJS} ${MT_LIBS};; \
  	esac
***************
*** 279,285 ****
  #
  #   $ what /opt/langtools/bin/pxdb32
  #   /opt/langtools/bin/pxdb32:
! #           HP92453-02 A.10.0A HP-UX SYMBOLIC DEBUGGER (PXDB) $Revision: 1.15.2.5 $
  #
  # The problem occurs when -g and -O are both used when compiling des.c.
  # The simplest way to work around the problem is to leave out either -g or -O.
--- 280,286 ----
  #
  #   $ what /opt/langtools/bin/pxdb32
  #   /opt/langtools/bin/pxdb32:
! #           HP92453-02 A.10.0A HP-UX SYMBOLIC DEBUGGER (PXDB) $Revision: 1.15.2.6 $
  #
  # The problem occurs when -g and -O are both used when compiling des.c.
  # The simplest way to work around the problem is to leave out either -g or -O.
***************
*** 410,424 ****
  
  ${DESTDIR}${libdir}/${LIBAFSRPC}: ${LIBAFSRPC}
  	${INSTALL} ${LIBAFSRPC} ${DESTDIR}${libdir}/${LIBAFSRPC}
- 
- ${DESTDIR}${libdir}/libafsrpc.${SHLIB_SUFFIX}: ${DESTDIR}${libdir}/${LIBAFSRPC}
  	-ln -f -s ${LIBAFSRPC} ${DESTDIR}${libdir}/libafsrpc.${SHLIB_SUFFIX}
  
  ${TOP_LIBDIR}/${LIBAFSRPC}: ${LIBAFSRPC}
  	${INSTALL} ${LIBAFSRPC} ${TOP_LIBDIR}/${LIBAFSRPC}
- 
- ${TOP_LIBDIR}/libafsrpc.${SHLIB_SUFFIX}: ${TOP_LIBDIR}/${LIBAFSRPC}
  	-ln -f -s ${LIBAFSRPC} ${TOP_LIBDIR}/libafsrpc.${SHLIB_SUFFIX}
  
! dest: ${DEST}/lib/${LIBAFSRPC} ${DEST}/lib/libafsrpc.${SHLIB_SUFFIX}
  
--- 411,423 ----
  
  ${DESTDIR}${libdir}/${LIBAFSRPC}: ${LIBAFSRPC}
  	${INSTALL} ${LIBAFSRPC} ${DESTDIR}${libdir}/${LIBAFSRPC}
  	-ln -f -s ${LIBAFSRPC} ${DESTDIR}${libdir}/libafsrpc.${SHLIB_SUFFIX}
+ 	-ln -f -s ${LIBAFSRPC} ${DESTDIR}${libdir}/libafsrpc.${SHLIB_SUFFIX}.${LIBAFSRPCMAJOR}
  
  ${TOP_LIBDIR}/${LIBAFSRPC}: ${LIBAFSRPC}
  	${INSTALL} ${LIBAFSRPC} ${TOP_LIBDIR}/${LIBAFSRPC}
  	-ln -f -s ${LIBAFSRPC} ${TOP_LIBDIR}/libafsrpc.${SHLIB_SUFFIX}
+ 	-ln -f -s ${LIBAFSRPC} ${TOP_LIBDIR}/libafsrpc.${SHLIB_SUFFIX}.${LIBAFSRPCMAJOR}
  
! dest: ${DEST}/lib/${LIBAFSRPC}
  
Index: openafs/src/sys/.cvsignore
diff -c openafs/src/sys/.cvsignore:1.2 openafs/src/sys/.cvsignore:1.2.2.1
*** openafs/src/sys/.cvsignore:1.2	Mon Jun 21 15:48:03 2004
--- openafs/src/sys/.cvsignore	Sat Oct 15 11:21:19 2005
***************
*** 1,7 ****
--- 1,9 ----
  AFS_component_version_number.c
  Makefile
+ libafssetpag.*
  pagsh
  pagsh.krb
+ picobj
  rmtsys.cs.c
  rmtsys.h
  rmtsys.ss.c
Index: openafs/src/sys/Makefile.in
diff -c openafs/src/sys/Makefile.in:1.27.2.4 openafs/src/sys/Makefile.in:1.27.2.6
*** openafs/src/sys/Makefile.in:1.27.2.4	Sun Feb 20 20:12:10 2005
--- openafs/src/sys/Makefile.in	Mon Oct 17 15:12:06 2005
***************
*** 1,3 ****
--- 1,8 ----
+ # API version. When something changes, increment as appropriate. 
+ # Ignore at your own risk.
+ LIBAFSSETPAGMAJOR=1
+ LIBAFSSETPAGMINOR=0
+ 
  # Copyright 2000, International Business Machines Corporation and others.
  # All Rights Reserved.
  # 
***************
*** 14,22 ****
  SFLAGS=-P -I${TOP_INCDIR}
  LIBS=libsys.a ${TOP_LIBDIR}/librx.a libsys.a ${TOP_LIBDIR}/liblwp.a ${TOP_LIBDIR}/util.a ${XLIBS}
  
! OBJECTS= afssyscalls.o syscall.o
  RMTOBJS=rmtsysnet.o rmtsysc.o rmtsys.cs.o rmtsys.xdr.o rmtsys.ss.o rmtsyss.o 
  
  all: \
  	rmtsysd \
  	pagsh \
--- 19,30 ----
  SFLAGS=-P -I${TOP_INCDIR}
  LIBS=libsys.a ${TOP_LIBDIR}/librx.a libsys.a ${TOP_LIBDIR}/liblwp.a ${TOP_LIBDIR}/util.a ${XLIBS}
  
! OBJECTS= afssyscalls.o setpag.o glue.o syscall.o
! SHLIBOBJS = picobj/setpag.o picobj/glue.o syscall.o
  RMTOBJS=rmtsysnet.o rmtsysc.o rmtsys.cs.o rmtsys.xdr.o rmtsys.ss.o rmtsyss.o 
  
+ LIBAFSSETPAG = libafssetpag.${SHLIB_SUFFIX}.${LIBAFSSETPAGMAJOR}.${LIBAFSSETPAGMINOR}
+ 
  all: \
  	rmtsysd \
  	pagsh \
***************
*** 26,31 ****
--- 34,40 ----
  	${TOP_INCDIR}/afs/xfsattrs.h \
  	${TOP_LIBDIR}/afs.exp \
  	${TOP_LIBDIR}/libsys.a \
+ 	${TOP_LIBDIR}/${LIBAFSSETPAG} \
  	${KERNELDIR}/afs \
  	${KERNELDIR}/afs/xfsattrs.h \
  	${UKERNELDIR}/afs \
***************
*** 41,46 ****
--- 50,71 ----
  			$(AR) crv $@ afsl.exp;;         \
  	esac
  
+ ${LIBAFSSETPAG}: ${SHLIBOBJS}
+ 	case ${SYS_NAME} in \
+ 	*_linux*) \
+ 	    ${SHLIB_LINKER} -Wl,-h,libafssetpag.so.${LIBAFSSETPAGMAJOR} \
+ 	        -o ${LIBAFSSETPAG} -Wl,--version-script=mapfile \
+ 	        ${SHLIBOBJS};; \
+ 	rs_aix4*) \
+ 	    ${SHLIB_LINKER} -o ${LIBAFSSETPAG} ${SHLIBOBJS} \
+ 	        -bE:afssetpag.exp;; \
+ 	sun*_5*) \
+ 	    ${SHLIB_LINKER} -h libafssetpag.so.${LIBAFSSETPAGMAJOR} \
+ 	        -o ${LIBAFSSETPAG} ${SHLIBOBJS};; \
+ 	*) \
+ 	    ${SHLIB_LINKER} -o ${LIBAFSSETPAG} ${SHLIBOBJS};; \
+ 	esac
+ 
  tests:	pagsh pagsh.krb fixit iinc idec icreate iopen istat rmtsysd
  
  syscall.o: syscall.s
***************
*** 68,73 ****
--- 93,118 ----
  afssyscalls.o: afssyscalls.c afssyscalls.h
  	${CCOBJ} ${CFLAGS} -c ${srcdir}/afssyscalls.c
  
+ glue.o: glue.c afssyscalls.h
+ 	${CCOBJ} ${CFLAGS} -c ${srcdir}/glue.c
+ 
+ setpag.o: setpag.c afssyscalls.h
+ 	${CCOBJ} ${CFLAGS} -c ${srcdir}/setpag.c
+ 
+ picobj: afssyscalls.h
+ 	mkdir -p picobj
+ 	cp ${srcdir}/afssyscalls.h picobj/afssyscalls.h
+ 
+ picobj/glue.o: picobj glue.c afssyscalls.h
+ 	rm -f picobj/glue.c
+ 	cp ${srcdir}/glue.c picobj/glue.c
+ 	cd picobj && ${CCOBJ} ${CFLAGS} ${SHLIB_CFLAGS} -c glue.c
+ 
+ picobj/setpag.o: picobj setpag.c afssyscalls.h
+ 	rm -f picobj/setpag.c
+ 	cp ${srcdir}/setpag.c picobj/setpag.c
+ 	cd picobj && ${CCOBJ} ${CFLAGS} ${SHLIB_CFLAGS} -c setpag.c
+ 
  rmtsysnet.o rmtsysc.o rmtsyss.o rmtsysd.o: rmtsys.h
  rmtsysd: AFS_component_version_number.o afs.exp afsl.exp
  
***************
*** 129,134 ****
--- 174,185 ----
  		$(CC) -o xfsinode ${CFLAGS} ${srcdir}/xfsinode.c ${LIBS}
  	esac
  
+ ${TOP_LIBDIR}/${LIBAFSSETPAG}: ${LIBAFSSETPAG}
+ 	${INSTALL} ${LIBAFSSETPAG} ${TOP_LIBDIR}/${LIBAFSSETPAG}
+ 	-ln -f -s ${LIBAFSSETPAG} ${TOP_LIBDIR}/libafssetpag.${SHLIB_SUFFIX}
+ 	-ln -f -s ${LIBAFSSETPAG} ${TOP_LIBDIR}/libafssetpag.${SHLIB_SUFFIX}.${LIBAFSSETPAGMAJOR}
+  
+ 
  afs.exp: ${srcdir}/afs4.exp ${srcdir}/afs5.exp
  	case ${SYS_NAME} in \
  		rs_aix5* ) \
***************
*** 198,203 ****
--- 249,255 ----
  
  install: \
  	${DESTDIR}${libdir}/afs/libsys.a \
+ 	${DESTDIR}${libdir}/${LIBAFSSETPAG} \
  	${DESTDIR}${sbindir}/rmtsysd \
  	${DESTDIR}${includedir}/afs/afssyscalls.h \
  	${DESTDIR}${bindir}/pagsh \
***************
*** 208,213 ****
--- 260,272 ----
  ${DESTDIR}${libdir}/afs/libsys.a: libsys.a
  	${INSTALL} $? $@
  
+ ${DESTDIR}${libdir}/${LIBAFSSETPAG}: ${LIBAFSSETPAG}
+ 	${INSTALL} ${LIBAFSSETPAG} ${DESTDIR}${libdir}/${LIBAFSSETPAG}
+ 	-ln -f -s ${LIBAFSSETPAG} \
+ 	    ${DESTDIR}${libdir}/libafssetpag.${SHLIB_SUFFIX}
+ 	-ln -f -s ${LIBAFSSETPAG} \
+ 	    ${DESTDIR}${libdir}/libafssetpag.${SHLIB_SUFFIX}.${LIBAFSSETPAGMAJOR}
+ 
  ${DESTDIR}${sbindir}/rmtsysd: rmtsysd
  	${INSTALL} -s $? $@
  
***************
*** 231,236 ****
--- 290,296 ----
  
  dest: \
  	${DEST}/lib/afs/libsys.a \
+ 	${TOP_LIBDIR}/${LIBAFSSETPAG} \
  	${DEST}/etc/rmtsysd \
  	${DEST}/bin/pagsh \
  	${DEST}/bin/pagsh.krb \
***************
*** 271,274 ****
  	$(RM) -f *.o libsys.a xfsinode iinc idec icreate iopen istat core \
  	rmtsysc rmtsyss *.o rmtsys.ss.c rmtsys.cs.c rmtsys.xdr.c rmtsys.h \
  	rmtsysd AFS_component_version_number.c pagsh pagsh.krb \
! 	afs.exp afsl.exp
--- 331,335 ----
  	$(RM) -f *.o libsys.a xfsinode iinc idec icreate iopen istat core \
  	rmtsysc rmtsyss *.o rmtsys.ss.c rmtsys.cs.c rmtsys.xdr.c rmtsys.h \
  	rmtsysd AFS_component_version_number.c pagsh pagsh.krb \
! 	afs.exp afsl.exp libafssetpag.*
! 	$(RM) -rf picobj
Index: openafs/src/sys/afs5.exp
diff -c openafs/src/sys/afs5.exp:1.1 openafs/src/sys/afs5.exp:1.1.2.1
*** openafs/src/sys/afs5.exp:1.1	Tue Jul  1 14:37:33 2003
--- openafs/src/sys/afs5.exp	Sat Oct 15 10:24:33 2005
***************
*** 3,9 ****
  * $Locker:  $
  *
  *
! * Exports for the AFS kernel extension for AIX 3.1
  *
  icreate		syscall
  syscall		syscall
--- 3,9 ----
  * $Locker:  $
  *
  *
! * Exports for the AFS kernel extension for AIX 5
  *
  icreate		syscall
  syscall		syscall
***************
*** 54,60 ****
  * afs_marinerPort
  afs_mariner
  cacheInfoModTime
- freeVCList
  afs_freeDCList
  afs_freeDCCount
  afs_freeDSList
--- 54,59 ----
Index: openafs/src/sys/afssetpag.exp
diff -c /dev/null openafs/src/sys/afssetpag.exp:1.1.2.2
*** /dev/null	Sat Oct 22 02:14:54 2005
--- openafs/src/sys/afssetpag.exp	Sat Oct 15 11:21:19 2005
***************
*** 0 ****
--- 1 ----
+ lsetpag
Index: openafs/src/sys/afssyscalls.c
diff -c openafs/src/sys/afssyscalls.c:1.10 openafs/src/sys/afssyscalls.c:1.10.2.2
*** openafs/src/sys/afssyscalls.c:1.10	Thu Jul  8 01:35:26 2004
--- openafs/src/sys/afssyscalls.c	Sat Oct 15 11:21:19 2005
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/sys/afssyscalls.c,v 1.10 2004/07/08 05:35:26 shadow Exp $");
  
  #include <signal.h>
  #include <sys/errno.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/sys/afssyscalls.c,v 1.10.2.2 2005/10/15 15:21:19 shadow Exp $");
  
  #include <signal.h>
  #include <sys/errno.h>
***************
*** 59,65 ****
  #pragma weak xiinc = iinc
  #pragma weak xidec = idec
  #pragma weak xiopen = iopen
- #pragma weak xlsetpag = lsetpag
  #pragma weak xlpioctl = lpioctl
  #ifdef notdef
  #pragma weak xiread = iread
--- 59,64 ----
***************
*** 206,217 ****
  #endif /* notdef */
  
  int
- lsetpag(void)
- {
-     return (syscall(AFS_SETPAG));
- }
- 
- int
  lpioctl(char *path, int cmd, char *cmarg, int follow)
  {
      return (syscall(AFS_PIOCTL, path, cmd, cmarg, follow));
--- 205,210 ----
***************
*** 314,326 ****
  
  #endif /* AFS_NAMEI_ENV */
  
! #ifdef AFS_LINUX20_ENV
! int proc_afs_syscall(long syscall, long param1, long param2, long param3, 
! 		     long param4, int *rval) {
!   struct afsprocdata syscall_data;
!   int fd = open(PROC_SYSCALL_FNAME, O_RDWR);
!   if(fd < 0)
!       fd = open(PROC_SYSCALL_ARLA_FNAME, O_RDWR);
    if(fd < 0)
      return -1;
  
--- 307,318 ----
  
  #endif /* AFS_NAMEI_ENV */
  
! #if defined(AFS_DARWIN80_ENV)
! int ioctl_afs_syscall(long syscall, long param1, long param2, long param3, 
! 		     long param4, long param5, long param6, int *rval) {
!   struct afssysargs syscall_data;
!   int code;
!   int fd = open(SYSCALL_DEV_FNAME, O_RDWR);
    if(fd < 0)
      return -1;
  
***************
*** 329,370 ****
    syscall_data.param2 = param2;
    syscall_data.param3 = param3;
    syscall_data.param4 = param4;
  
!   *rval = ioctl(fd, VIOC_SYSCALL, &syscall_data);
  
    close(fd);
! 
    return 0;
  }
  #endif
  
  int
- lsetpag(void)
- {
-     int errcode, rval;
- 
- #ifdef AFS_LINUX20_ENV
-     rval = proc_afs_syscall(AFSCALL_SETPAG,0,0,0,0,&errcode);
-     
-     if(rval)
-       errcode = syscall(AFS_SYSCALL, AFSCALL_SETPAG);
- #else
-     errcode = syscall(AFS_SYSCALL, AFSCALL_SETPAG);
- #endif
-     
-     return (errcode);
- }
- 
- int
  lpioctl(char *path, int cmd, char *cmarg, int follow)
  {
      int errcode, rval;
  
! #ifdef AFS_LINUX20_ENV
      rval = proc_afs_syscall(AFSCALL_PIOCTL, (long)path, cmd, (long)cmarg, follow, &errcode);
  
      if(rval)
      errcode = syscall(AFS_SYSCALL, AFSCALL_PIOCTL, path, cmd, cmarg, follow);
  #else
      errcode = syscall(AFS_SYSCALL, AFSCALL_PIOCTL, path, cmd, cmarg, follow);
  #endif
--- 321,352 ----
    syscall_data.param2 = param2;
    syscall_data.param3 = param3;
    syscall_data.param4 = param4;
+   syscall_data.param5 = param5;
+   syscall_data.param6 = param6;
  
!   code = ioctl(fd, VIOC_SYSCALL, &syscall_data);
  
    close(fd);
!   if (code)
!      return code;
!   *rval=syscall_data.retval;
    return 0;
  }
  #endif
  
  int
  lpioctl(char *path, int cmd, char *cmarg, int follow)
  {
      int errcode, rval;
  
! #if defined(AFS_LINUX20_ENV)
      rval = proc_afs_syscall(AFSCALL_PIOCTL, (long)path, cmd, (long)cmarg, follow, &errcode);
  
      if(rval)
      errcode = syscall(AFS_SYSCALL, AFSCALL_PIOCTL, path, cmd, cmarg, follow);
+ #elif defined(AFS_DARWIN80_ENV)
+     if (ioctl_afs_syscall(AFSCALL_PIOCTL,(long)path,cmd,(long)cmarg,follow,0,0,&errcode))
+         errcode=ENOSYS;
  #else
      errcode = syscall(AFS_SYSCALL, AFSCALL_PIOCTL, path, cmd, cmarg, follow);
  #endif
Index: openafs/src/sys/afssyscalls.h
diff -c openafs/src/sys/afssyscalls.h:1.8.2.1 openafs/src/sys/afssyscalls.h:1.8.2.2
*** openafs/src/sys/afssyscalls.h:1.8.2.1	Mon Aug 15 13:36:16 2005
--- openafs/src/sys/afssyscalls.h	Sat Oct 15 11:21:19 2005
***************
*** 39,44 ****
--- 39,50 ----
  #define AFS_DEBUG_IOPS_LOG(F)
  #endif
  
+ /* Glue layer. */
+ #ifdef AFS_LINUX20_ENV
+ int proc_afs_syscall(long syscall, long param1, long param2, long param3, 
+ 		     long param4, int *rval);
+ #endif
+ 
  /* Declarations for inode system calls. */
  #ifdef AFS_SGI_XFS_IOPS_ENV
  extern uint64_t icreatename64(int dev, char *partname, int p0, int p1, int p2,
Index: openafs/src/sys/glue.c
diff -c /dev/null openafs/src/sys/glue.c:1.1.2.2
*** /dev/null	Sat Oct 22 02:14:54 2005
--- openafs/src/sys/glue.c	Sat Oct 15 11:21:19 2005
***************
*** 0 ****
--- 1,55 ----
+ /*
+  * Copyright 2000, International Business Machines Corporation and others.
+  * All Rights Reserved.
+  * 
+  * This software has been released under the terms of the IBM Public
+  * License.  For details, see the LICENSE file in the top-level source
+  * directory or online at http://www.openafs.org/dl/license10.html
+  *
+  * This file contains any necessary C glue to allow programs to communicate
+  * with the AFS kernel module.  The necessary lower-level glue is defined in
+  * syscall.s.
+  */
+ 
+ #include <afsconfig.h>
+ #include <afs/param.h>
+ 
+ RCSID
+     ("$Header: /cvs/openafs/src/sys/glue.c,v 1.1.2.2 2005/10/15 15:21:19 shadow Exp $");
+ 
+ #include <afs/afs_args.h>
+ #include <sys/file.h>
+ #include <sys/ioctl.h>
+ #if defined(AFS_SUN_ENV) && !defined(AFS_SUN5_ENV)
+ #include <unistd.h>
+ #else
+ #include <stdio.h>
+ #endif
+ #ifdef AFS_SUN5_ENV
+ #include <fcntl.h>
+ #endif
+ #include "afssyscalls.h"
+ 
+ #ifdef AFS_LINUX20_ENV
+ int proc_afs_syscall(long syscall, long param1, long param2, long param3, 
+ 		     long param4, int *rval) {
+   struct afsprocdata syscall_data;
+   int fd = open(PROC_SYSCALL_FNAME, O_RDWR);
+   if(fd < 0)
+       fd = open(PROC_SYSCALL_ARLA_FNAME, O_RDWR);
+   if(fd < 0)
+     return -1;
+ 
+   syscall_data.syscall = syscall;
+   syscall_data.param1 = param1;
+   syscall_data.param2 = param2;
+   syscall_data.param3 = param3;
+   syscall_data.param4 = param4;
+ 
+   *rval = ioctl(fd, VIOC_SYSCALL, &syscall_data);
+ 
+   close(fd);
+ 
+   return 0;
+ }
+ #endif
Index: openafs/src/sys/mapfile
diff -c /dev/null openafs/src/sys/mapfile:1.1.2.2
*** /dev/null	Sat Oct 22 02:14:54 2005
--- openafs/src/sys/mapfile	Mon Oct 17 15:12:06 2005
***************
*** 0 ****
--- 1,10 ----
+ # Export map for libafssetpag, used on Linux and Solaris to restrict
+ # exports from the shared libraries to just the public ABI.  Add symbol
+ # versioning while we're at it, just in case.
+ 
+ AFSSETPAG_1.0 {
+     global:
+         lsetpag;
+     local:
+         *;
+ };
Index: openafs/src/sys/pioctl_nt.c
diff -c openafs/src/sys/pioctl_nt.c:1.18.2.11 openafs/src/sys/pioctl_nt.c:1.18.2.12
*** openafs/src/sys/pioctl_nt.c:1.18.2.11	Fri Sep  2 13:28:36 2005
--- openafs/src/sys/pioctl_nt.c	Sat Oct 15 17:48:28 2005
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/sys/pioctl_nt.c,v 1.18.2.11 2005/09/02 17:28:36 jaltman Exp $");
  
  #include <afs/stds.h>
  #include <windows.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/sys/pioctl_nt.c,v 1.18.2.12 2005/10/15 21:48:28 jaltman Exp $");
  
  #include <afs/stds.h>
  #include <windows.h>
***************
*** 91,97 ****
      case CM_ERROR_TOOMANYBUFS:
  	return EFBIG;		/* hack */
      default:
! 	return ENOTTY;
      }
  }
  
--- 91,100 ----
      case CM_ERROR_TOOMANYBUFS:
  	return EFBIG;		/* hack */
      default:
! 	if (cm_code > 0 && cm_code < EILSEQ)
! 	    return cm_code;
! 	else
! 	    return ENOTTY;
      }
  }
  
Index: openafs/src/sys/setpag.c
diff -c /dev/null openafs/src/sys/setpag.c:1.1.2.2
*** /dev/null	Sat Oct 22 02:14:54 2005
--- openafs/src/sys/setpag.c	Sat Oct 15 11:21:19 2005
***************
*** 0 ****
--- 1,66 ----
+ /*
+  * Copyright 2000, International Business Machines Corporation and others.
+  * All Rights Reserved.
+  * 
+  * This software has been released under the terms of the IBM Public
+  * License.  For details, see the LICENSE file in the top-level source
+  * directory or online at http://www.openafs.org/dl/license10.html
+  *
+  * This file contains the lsetpag system call.  (setpag is handled by the
+  * rmtsys layer and turned into either setpag or a remote call as is
+  * appropriate.)  It is kept separate to allow for the creation of a simple
+  * shared library containing only setpag.
+  */
+ 
+ #include <afsconfig.h>
+ #include <afs/param.h>
+ 
+ RCSID
+     ("$Header: /cvs/openafs/src/sys/setpag.c,v 1.1.2.2 2005/10/15 15:21:19 shadow Exp $");
+ 
+ #include <afs/afs_args.h>
+ #if defined(AFS_SUN_ENV) && !defined(AFS_SUN5_ENV)
+ #include <unistd.h>
+ #else
+ #include <stdio.h>
+ #endif
+ #include "afssyscalls.h"
+ 
+ #ifdef AFS_AIX32_ENV
+ /*
+  * in VRMIX, system calls look just like function calls, so we don't
+  * need to do anything!
+  */
+ 
+ #else
+ #if defined(AFS_SGI_ENV)
+ 
+ #pragma weak xlsetpag = lsetpag
+ 
+ int
+ lsetpag(void)
+ {
+     return (syscall(AFS_SETPAG));
+ }
+ 
+ #else /* AFS_SGI_ENV */
+ 
+ int
+ lsetpag(void)
+ {
+     int errcode, rval;
+ 
+ #ifdef AFS_LINUX20_ENV
+     rval = proc_afs_syscall(AFSCALL_SETPAG,0,0,0,0,&errcode);
+     
+     if(rval)
+       errcode = syscall(AFS_SYSCALL, AFSCALL_SETPAG);
+ #else
+     errcode = syscall(AFS_SYSCALL, AFSCALL_SETPAG);
+ #endif
+     
+     return (errcode);
+ }
+ 
+ #endif /* !AFS_SGI_ENV */
+ #endif /* !AFS_AIX32_ENV */
Index: openafs/src/venus/fstrace.c
diff -c openafs/src/venus/fstrace.c:1.16.2.4 openafs/src/venus/fstrace.c:1.16.2.5
*** openafs/src/venus/fstrace.c:1.16.2.4	Mon Jul 11 15:29:40 2005
--- openafs/src/venus/fstrace.c	Wed Oct  5 01:58:48 2005
***************
*** 14,20 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/venus/fstrace.c,v 1.16.2.4 2005/07/11 19:29:40 shadow Exp $");
  
  #include <stdio.h>
  #include <sys/types.h>
--- 14,20 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/venus/fstrace.c,v 1.16.2.5 2005/10/05 05:58:48 shadow Exp $");
  
  #include <stdio.h>
  #include <sys/types.h>
***************
*** 2156,2161 ****
--- 2156,2165 ----
      __asm__ __volatile__("mov	%o0, %i0; ret; restore");
  #endif
  #else
+ #ifdef AFS_DARWIN80_ENV
+     code = ioctl_afs_syscall(call, parm0, parm1, parm2, parm3, parm4, parm5, &rval);
+     if (!code) code = rval;
+ #else
  #if !defined(AFS_SGI_ENV) && !defined(AFS_AIX32_ENV)
      code = syscall(AFS_SYSCALL, call, parm0, parm1, parm2, parm3, parm4);
  #else
***************
*** 2165,2170 ****
--- 2169,2175 ----
      code = syscall(AFSCALL_ICL, parm0, parm1, parm2, parm3, parm4);
  #endif
  #endif
+ #endif
  #endif /* AFS_LINUX20_ENV */
      return code;
  }
Index: openafs/src/viced/afsfileprocs.c
diff -c openafs/src/viced/afsfileprocs.c:1.81.2.11 openafs/src/viced/afsfileprocs.c:1.81.2.13
*** openafs/src/viced/afsfileprocs.c:1.81.2.11	Sat Aug 13 22:11:38 2005
--- openafs/src/viced/afsfileprocs.c	Thu Oct 20 19:33:00 2005
***************
*** 29,35 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/viced/afsfileprocs.c,v 1.81.2.11 2005/08/14 02:11:38 jaltman Exp $");
  
  #include <stdio.h>
  #include <stdlib.h>
--- 29,35 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/viced/afsfileprocs.c,v 1.81.2.13 2005/10/20 23:33:00 jaltman Exp $");
  
  #include <stdio.h>
  #include <stdlib.h>
***************
*** 3708,3713 ****
--- 3708,3715 ----
      TM_GetTimeOfDay(&opStartTime, 0);
  #endif /* FS_STATS_DETAILED */
  
+     memset(OutFid, 0, sizeof(struct AFSFid));
+ 
      if ((code = CallPreamble(acall, ACTIVECALL, &tcon)))
  	goto Bad_CreateFile;
  
***************
*** 3740,3746 ****
  
      osi_auditU(acall, CreateFileEvent, code, 
                 AUD_ID, t_client ? t_client->ViceId : 0,
!                AUD_FID, DirFid, AUD_STR, Name, AUD_END);
      return code;
  
  }				/*SRXAFS_CreateFile */
--- 3742,3748 ----
  
      osi_auditU(acall, CreateFileEvent, code, 
                 AUD_ID, t_client ? t_client->ViceId : 0,
!                AUD_FID, DirFid, AUD_STR, Name, AUD_FID, OutFid, AUD_END);
      return code;
  
  }				/*SRXAFS_CreateFile */
***************
*** 6759,6772 ****
      TM_GetTimeOfDay(&StartTime, 0);
      ihP = targetptr->handle;
      fdP = IH_OPEN(ihP);
!     if (fdP == NULL)
  	return EIO;
      optSize = sendBufSize;
      tlen = FDH_SIZE(fdP);
      ViceLog(25,
  	    ("FetchData_RXStyle: file size %llu\n", (afs_uintmax_t) tlen));
      if (tlen < 0) {
  	FDH_CLOSE(fdP);
  	return EIO;
      }
      if (Pos > tlen) {
--- 6761,6777 ----
      TM_GetTimeOfDay(&StartTime, 0);
      ihP = targetptr->handle;
      fdP = IH_OPEN(ihP);
!     if (fdP == NULL) {
! 	VTakeOffline(volptr);
  	return EIO;
+     }
      optSize = sendBufSize;
      tlen = FDH_SIZE(fdP);
      ViceLog(25,
  	    ("FetchData_RXStyle: file size %llu\n", (afs_uintmax_t) tlen));
      if (tlen < 0) {
  	FDH_CLOSE(fdP);
+ 	VTakeOffline(volptr);
  	return EIO;
      }
      if (Pos > tlen) {
***************
*** 6804,6809 ****
--- 6809,6815 ----
  	if (errorCode != wlen) {
  	    FDH_CLOSE(fdP);
  	    FreeSendBuffer((struct afs_buffer *)tbuffer);
+ 	    VTakeOffline(volptr);
  	    return EIO;
  	}
  	errorCode = rx_Write(Call, tbuffer, wlen);
***************
*** 6811,6822 ****
--- 6817,6830 ----
  	errorCode = rx_WritevAlloc(Call, tiov, &tnio, RX_MAXIOVECS, wlen);
  	if (errorCode <= 0) {
  	    FDH_CLOSE(fdP);
+ 	    VTakeOffline(volptr);
  	    return EIO;
  	}
  	wlen = errorCode;
  	errorCode = FDH_READV(fdP, tiov, tnio);
  	if (errorCode != wlen) {
  	    FDH_CLOSE(fdP);
+ 	    VTakeOffline(volptr);
  	    return EIO;
  	}
  	errorCode = rx_Writev(Call, tiov, tnio, wlen);
***************
*** 6988,6993 ****
--- 6996,7002 ----
  	    return ENOENT;
  	if (GetLinkCountAndSize(volptr, fdP, &linkCount, &DataLength) < 0) {
  	    FDH_CLOSE(fdP);
+ 	    VTakeOffline(volptr);
  	    return EIO;
  	}
  
Index: openafs/src/viced/viced.c
diff -c openafs/src/viced/viced.c:1.58.2.7 openafs/src/viced/viced.c:1.58.2.8
*** openafs/src/viced/viced.c:1.58.2.7	Mon Jul 11 15:08:50 2005
--- openafs/src/viced/viced.c	Fri Oct 14 23:46:09 2005
***************
*** 20,26 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/viced/viced.c,v 1.58.2.7 2005/07/11 19:08:50 shadow Exp $");
  
  #include <stdio.h>
  #include <stdlib.h>
--- 20,26 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/viced/viced.c,v 1.58.2.8 2005/10/15 03:46:09 shadow Exp $");
  
  #include <stdio.h>
  #include <stdlib.h>
***************
*** 749,754 ****
--- 749,755 ----
      strcat(buffer, "[-realm <Kerberos realm name>] ");
      strcat(buffer, "[-udpsize <size of socket buffer in bytes>] ");
      strcat(buffer, "[-sendsize <size of send buffer in bytes>] ");
+     strcat(buffer, "[-abortthreshold <abort threshold>] ");
  /*   strcat(buffer, "[-enable_peer_stats] "); */
  /*   strcat(buffer, "[-enable_process_stats] "); */
      strcat(buffer, "[-help]\n");
Index: openafs/src/vol/partition.c
diff -c openafs/src/vol/partition.c:1.30.2.1.4.1 openafs/src/vol/partition.c:1.30.2.2
*** openafs/src/vol/partition.c:1.30.2.1.4.1	Mon Oct 17 16:48:29 2005
--- openafs/src/vol/partition.c	Mon Oct 17 16:47:07 2005
***************
*** 21,27 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vol/partition.c,v 1.30.2.1.4.1 2005/10/17 20:48:29 shadow Exp $");
  
  #include <ctype.h>
  #ifdef AFS_NT40_ENV
--- 21,27 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vol/partition.c,v 1.30.2.2 2005/10/17 20:47:07 shadow Exp $");
  
  #include <ctype.h>
  #ifdef AFS_NT40_ENV
