Subject: Ultrix compatibility: patches to mount Ultrix filesystems (readonly)
To: None <port-pmax@sun-lamp.cs.berkeley.edu>
From: Jonathan Stone <jonathan@DSG.Stanford.EDU>
List: port-pmax
Date: 08/16/1994 03:52:49
>The following changes rearrange up block and character special device
>numbers to match Ultrix conventions, change the compatibility code for
>mount() to grok the Ultrix interface instead of SunOS, make some
>gratuitous changes to the default scsi partition table, re-enables
>that default table, and adds some (ugly) debugging printf()s that show
>what's going on during mounts.

Oops. Due to a typo I  accidentally left out the patch to 
compat/ultrix/ultrix_misc.c, which is included below.

The debugging messages here are pretty gross.
What's the protocol for posting patches to this mailing list?
Is it better to share raw improvements, or polish them for
integration into the "official" source tree?

*** compat/ultrix/ultrix_misc.c.DIST	Mon Aug  1 13:22:03 1994
--- compat/ultrix/ultrix_misc.c	Tue Aug 16 03:40:42 1994
***************
*** 292,330 ****
  	int	flags;
  	caddr_t	data;
  };
  sun_mount(p, uap, retval)
  	struct proc *p;
! 	struct sun_mount_args *uap;
  	int *retval;
  {
! 	int oflags = uap->flags, nflags, error;
  	extern char sigcode[], esigcode[];
  	char fsname[MFSNAMELEN];
  
  #define	szsigcode	(esigcode - sigcode)
  
! 	if (oflags & (SUNM_NOSUB | SUNM_SYS5))
! 		return (EINVAL);
! 	if ((oflags & SUNM_NEWTYPE) == 0)
  		return (EINVAL);
- 	nflags = 0;
- 	if (oflags & SUNM_RDONLY)
- 		nflags |= MNT_RDONLY;
- 	if (oflags & SUNM_NOSUID)
- 		nflags |= MNT_NOSUID;
- 	if (oflags & SUNM_REMOUNT)
- 		nflags |= MNT_UPDATE;
- 	uap->flags = nflags;
  
! 	if (error = copyinstr((caddr_t)uap->type, fsname, sizeof fsname, (u_int *)0))
  		return (error);
  
! 	if (strcmp(fsname, "4.2") == 0) {
! 		uap->type = (caddr_t)ALIGN(PS_STRINGS - szsigcode - STACKGAPLEN);
! 		if (error = copyout("ufs", uap->type, sizeof("ufs")))
! 			return (error);
! 	} else if (strcmp(fsname, "nfs") == 0) {
! 		struct sun_nfs_args sna;
  		struct sockaddr_in sain;
  		struct nfs_args na;
  		struct sockaddr sa;
--- 292,391 ----
  	int	flags;
  	caddr_t	data;
  };
+ /*XXX* Ultrix mount(2) not the same as SunOS*/
+ 
+ struct ult_mount_args {
+ 	char	*special;
+ 	char	*dir;
+ 	int	rdonly, type;
+ 	caddr_t data;
+ };
+ 
+ struct	ult_nfs_args {
+ 	struct	sockaddr_in *addr;	/* file server address */
+ 	caddr_t	fh;			/* file handle to be mounted */
+ 	int	flags;			/* flags */
+ 	int	wsize;			/* write size in bytes */
+ 	int	rsize;			/* read size in bytes */
+ 	int	timeo;			/* initial timeout in .1 secs */
+ 	int	retrans;		/* times to retry send */
+ 	char	*hostname;		/* server's hostname */
+ 	char *optstr;			/* string of nfs mount options for kerneel to parse */
+ 	int	gfs_flags;		/* gnode flags (ugh) */
+ 	int	pg_thresh;		/* paging threshold ? */
+ };
+ 
+ struct ult_ufs_args {
+ 	u_long ufs_flags;		/* mount flags?*/
+ 	u_long ufs_pgthresh;		/* minimum file size to page */
+ };
+ 
+ int
  sun_mount(p, uap, retval)
  	struct proc *p;
! 	struct ult_mount_args *uap;
  	int *retval;
  {
! 	int error;
! 	int otype = uap->type;
  	extern char sigcode[], esigcode[];
  	char fsname[MFSNAMELEN];
+ 	char * fstype;
+ 	struct sun_mount_args fixed;
  
  #define	szsigcode	(esigcode - sigcode)
+ 	caddr_t usp = (caddr_t)ALIGN(PS_STRINGS - szsigcode - STACKGAPLEN);
+ #ifdef DEBUG
+ 	printf("ultrix mount\n");
+ #endif
+ 	fixed.flags = 0;
  
! 	/*
! 	 * fix up Ultrix mount codes for UFS and NFS.
! 	 * Other filesystem types (msdos, DEC ods-2) not yet done */
! 	if (otype == 0x1)
! 		fstype = "ufs";
! 	else if (otype == 0x5)
! 		fstype = "nfs";
! 	else
  		return (EINVAL);
  
! 	if (uap->rdonly)
! 		fixed.flags |= MNT_RDONLY;
! 
! 	/* copy string-ified version of mount type in user space */
! 	fixed.type = (char *)usp;
! 	if (error = copyout(fstype, fixed.type, strlen(fstype)+1)) {
! #ifdef DEBUG
! 		printf("(ultrix) mount: copying out %s\n", fstype);
! #endif
  		return (error);
+ 		
+ 	}
+ 	usp += strlen(fstype)+1;
  
! #ifdef later
! 	parse ultrix mount option string and set flags
! #endif
! 	fixed.dir = uap->dir;
! 
! 	if (otype == 0x1) {
! 		struct ufs_args uua;
! 
! 		uua.fspec = uap->special;
! 		bzero(&uua.export, sizeof(uua.export));
! 		fixed.data = usp;
! 
! 		if (error = copyout(&uua, fixed.data, sizeof uua)) {
! #ifdef DEBUG
! 			printf("ult mount: copying out \"%s\" at %x to %x\n",
! 			       uap->special, uap->data);
! #endif
! 			return(error);
! 		}
! 
! 	} else if (otype == 0x5) {
! 		struct ult_nfs_args sna;
  		struct sockaddr_in sain;
  		struct nfs_args na;
  		struct sockaddr sa;
***************
*** 335,342 ****
  			return (error);
  		bcopy(&sain, &sa, sizeof sa);
  		sa.sa_len = sizeof(sain);
! 		uap->data = (caddr_t)ALIGN(PS_STRINGS - szsigcode - STACKGAPLEN);
! 		na.addr = (struct sockaddr *)((int)uap->data + sizeof na);
  		na.sotype = SOCK_DGRAM;
  		na.proto = IPPROTO_UDP;
  		na.fh = (nfsv2fh_t *)sna.fh;
--- 396,403 ----
  			return (error);
  		bcopy(&sain, &sa, sizeof sa);
  		sa.sa_len = sizeof(sain);
! 		fixed.data = usp;
! 		na.addr = (struct sockaddr *)((int)usp + sizeof na);
  		na.sotype = SOCK_DGRAM;
  		na.proto = IPPROTO_UDP;
  		na.fh = (nfsv2fh_t *)sna.fh;
***************
*** 347,357 ****
  		na.retrans = sna.retrans;
  		na.hostname = sna.hostname;
  
  		if (error = copyout(&sa, na.addr, sizeof sa))
  			return (error);
! 		if (error = copyout(&na, uap->data, sizeof na))
  			return (error);
  	}
  	return (mount(p, uap, retval));
  }
  
--- 408,446 ----
  		na.retrans = sna.retrans;
  		na.hostname = sna.hostname;
  
+ 
  		if (error = copyout(&sa, na.addr, sizeof sa))
  			return (error);
! 		if (error = copyout(&na, fixed.data, sizeof na))
  			return (error);
  	}
+ 
+ 	/* juggle fields */
+ 	bcopy(&fixed, uap, sizeof(fixed));
+ 
+ #ifdef DEBUG
+ {
+ 	struct ufs_args tem;
+ 	/*XXX*/
+ 	fsname[0] = 0;
+ 	copyinstr(fixed.type, fsname, sizeof fsname, (u_int*)0);
+ 	printf("mount: \"%s\" ", fsname);
+ 
+ 	fsname[0] = 0;
+ 	error = copyinstr((caddr_t)fixed.dir, fsname, sizeof fsname,
+ 			  (u_int*)0);
+ 	printf("\"%s\", flags 0x%x, 0x%x\n", fsname, fixed.flags);
+ 	if (error) printf("WARNING: copyinstr() failed\n");
+ 
+ 	error = copyin(fixed.data, &tem, sizeof(tem));
+ 	if (error) printf("WARNING: copyin() ufs_args failed\n");
+ 	error = copyinstr((caddr_t)tem.fspec, fsname, sizeof fsname,
+ 			  (u_int*)0);
+ 	if (error) printf("WARNING: copyinstr() fspec failed\n");
+ 	printf("\"%s\"\n", fsname);
+        
+ }
+ #endif
  	return (mount(p, uap, retval));
  }
  

------------------------------------------------------------------------------