Module Name:    src
Committed By:   christos
Date:           Sat Jan 26 00:21:49 UTC 2013

Modified Files:
        src/sys/fs/msdosfs: denode.h direntry.h fat.h msdosfs_conv.c
            msdosfs_fat.c msdosfs_lookup.c msdosfsmount.h

Log Message:
expose more stuff if MAKEFS is defined for the headers, and arrange for
the source file to be compilable from userland.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/fs/msdosfs/denode.h
cvs rdiff -u -r1.5 -r1.6 src/sys/fs/msdosfs/direntry.h
cvs rdiff -u -r1.7 -r1.8 src/sys/fs/msdosfs/fat.h \
    src/sys/fs/msdosfs/msdosfs_conv.c
cvs rdiff -u -r1.23 -r1.24 src/sys/fs/msdosfs/msdosfs_fat.c
cvs rdiff -u -r1.27 -r1.28 src/sys/fs/msdosfs/msdosfs_lookup.c
cvs rdiff -u -r1.17 -r1.18 src/sys/fs/msdosfs/msdosfsmount.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/denode.h
diff -u src/sys/fs/msdosfs/denode.h:1.20 src/sys/fs/msdosfs/denode.h:1.21
--- src/sys/fs/msdosfs/denode.h:1.20	Sun Nov  4 12:57:59 2012
+++ src/sys/fs/msdosfs/denode.h	Fri Jan 25 19:21:49 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: denode.h,v 1.20 2012/11/04 17:57:59 jakllsch Exp $	*/
+/*	$NetBSD: denode.h,v 1.21 2013/01/26 00:21:49 christos Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -231,7 +231,7 @@ struct denode {
 #define	de_forw		de_chain[0]
 #define	de_back		de_chain[1]
 
-#ifdef _KERNEL
+#if defined(_KERNEL) || defined(MAKEFS)
 
 #define	VTODE(vp)	((struct denode *)(vp)->v_data)
 #define	DETOV(de)	((de)->de_vnode)
@@ -287,6 +287,8 @@ int	msdosfs_pathconf	(void *);
 /*
  * Internal service routine prototypes.
  */
+struct componentname;
+struct direntry;
 int msdosfs_update(struct vnode *, const struct timespec *,
 	    const struct timespec *, int);
 int createde(struct denode *, struct denode *,
@@ -312,5 +314,5 @@ int msdosfs_fh_enter(struct msdosfsmount
 int msdosfs_fh_remove(struct msdosfsmount *, uint32_t, uint32_t);
 int msdosfs_fh_lookup(struct msdosfsmount *, uint32_t, uint32_t, uint32_t *);
 void msdosfs_fh_destroy(struct msdosfsmount *);
-#endif	/* _KERNEL */
+#endif	/* _KERNEL || MAKEFS */
 #endif /* _MSDOSFS_DENODE_H_ */

Index: src/sys/fs/msdosfs/direntry.h
diff -u src/sys/fs/msdosfs/direntry.h:1.5 src/sys/fs/msdosfs/direntry.h:1.6
--- src/sys/fs/msdosfs/direntry.h:1.5	Sat Dec  3 12:34:43 2005
+++ src/sys/fs/msdosfs/direntry.h	Fri Jan 25 19:21:49 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: direntry.h,v 1.5 2005/12/03 17:34:43 christos Exp $	*/
+/*	$NetBSD: direntry.h,v 1.6 2013/01/26 00:21:49 christos Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -120,7 +120,8 @@ struct winentry {
 #define DD_YEAR_MASK		0xFE00	/* year - 1980 */
 #define DD_YEAR_SHIFT		9
 
-#ifdef _KERNEL
+#if defined(_KERNEL) || defined(MAKEFS)
+struct dirent;
 void	unix2dostime(const struct timespec *tsp, int gmtoff, u_int16_t *ddp,
 	    u_int16_t *dtp, u_int8_t *dhp);
 void	dos2unixtime(u_int dd, u_int dt, u_int dh, int gmtoff,
@@ -135,5 +136,5 @@ int	winChkName(const u_char *un, int unl
 int	win2unixfn(struct winentry *wep, struct dirent *dp, int chksum);
 u_int8_t winChksum(u_int8_t *name);
 int	winSlotCnt(const u_char *un, int unlen);
-#endif	/* _KERNEL */
+#endif /* _KERNEL || MAKEFS */
 #endif /* _MSDOSFS_DIRENTRY_H_ */

Index: src/sys/fs/msdosfs/fat.h
diff -u src/sys/fs/msdosfs/fat.h:1.7 src/sys/fs/msdosfs/fat.h:1.8
--- src/sys/fs/msdosfs/fat.h:1.7	Sun Nov  4 12:57:59 2012
+++ src/sys/fs/msdosfs/fat.h	Fri Jan 25 19:21:49 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: fat.h,v 1.7 2012/11/04 17:57:59 jakllsch Exp $	*/
+/*	$NetBSD: fat.h,v 1.8 2013/01/26 00:21:49 christos Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1997 Wolfgang Solfrank.
@@ -92,7 +92,7 @@
 #define	MSDOSFSEOF(cn, fatmask)	\
 	(((cn) & CLUST_EOFS) == (CLUST_EOFS & (fatmask)))
 
-#ifdef _KERNEL
+#if defined(_KERNEL) || defined(MAKEFS)
 /*
  * These are the values for the function argument to the function
  * fatentry().
@@ -115,5 +115,5 @@ void fc_purge(struct denode *, u_int);
 void fc_lookup(struct denode *, u_long, u_long *, u_long *);
 int fillinusemap(struct msdosfsmount *);
 int freeclusterchain(struct msdosfsmount *, u_long);
-#endif	/* _KERNEL */
+#endif /* _KERNEL || MAKEFS */
 #endif /* _MSDOSFS_FAT_H_ */
Index: src/sys/fs/msdosfs/msdosfs_conv.c
diff -u src/sys/fs/msdosfs/msdosfs_conv.c:1.7 src/sys/fs/msdosfs/msdosfs_conv.c:1.8
--- src/sys/fs/msdosfs/msdosfs_conv.c:1.7	Sun Mar 15 13:15:57 2009
+++ src/sys/fs/msdosfs/msdosfs_conv.c	Fri Jan 25 19:21:49 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_conv.c,v 1.7 2009/03/15 17:15:57 cegger Exp $	*/
+/*	$NetBSD: msdosfs_conv.c,v 1.8 2013/01/26 00:21:49 christos Exp $	*/
 
 /*-
  * Copyright (C) 1995, 1997 Wolfgang Solfrank.
@@ -47,8 +47,12 @@
  * October 1992
  */
 
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
+
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_conv.c,v 1.7 2009/03/15 17:15:57 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_conv.c,v 1.8 2013/01/26 00:21:49 christos Exp $");
 
 /*
  * System include files.
@@ -59,6 +63,9 @@ __KERNEL_RCSID(0, "$NetBSD: msdosfs_conv
 #include <sys/kernel.h>
 #include <sys/dirent.h>
 #include <sys/vnode.h>
+#ifndef _KERNEL
+#include <stdio.h>
+#endif
 
 /*
  * MSDOSFS include files.
@@ -209,8 +216,8 @@ dos2unixtime(u_int dd, u_int dt, u_int d
 		 */
 		month = (dd & DD_MONTH_MASK) >> DD_MONTH_SHIFT;
 		if (month == 0) {
-			printf("dos2unixtime(): month value out of range (%ld)\n",
-			    month);
+			printf("%s: month value out of range (%ld)\n",
+			    __func__, month);
 			month = 1;
 		}
 		for (m = 0; m < month - 1; m++)
@@ -700,7 +707,7 @@ int
 win2unixfn(struct winentry *wep, struct dirent *dp, int chksum)
 {
 	u_int8_t *cp;
-	u_int8_t *np, *ep = dp->d_name + WIN_MAXLEN;
+	u_int8_t *np, *ep = (u_int8_t *)dp->d_name + WIN_MAXLEN;
 	int i;
 
 	if ((wep->weCnt&WIN_CNT) > howmany(WIN_MAXLEN, WIN_CHARS)

Index: src/sys/fs/msdosfs/msdosfs_fat.c
diff -u src/sys/fs/msdosfs/msdosfs_fat.c:1.23 src/sys/fs/msdosfs/msdosfs_fat.c:1.24
--- src/sys/fs/msdosfs/msdosfs_fat.c:1.23	Thu Dec 20 06:44:39 2012
+++ src/sys/fs/msdosfs/msdosfs_fat.c	Fri Jan 25 19:21:49 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_fat.c,v 1.23 2012/12/20 11:44:39 hannken Exp $	*/
+/*	$NetBSD: msdosfs_fat.c,v 1.24 2013/01/26 00:21:49 christos Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -47,22 +47,30 @@
  * October 1992
  */
 
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
+
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_fat.c,v 1.23 2012/12/20 11:44:39 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_fat.c,v 1.24 2013/01/26 00:21:49 christos Exp $");
 
 /*
  * kernel include files.
  */
 #include <sys/param.h>
 #include <sys/systm.h>
-#include <sys/buf.h>
 #include <sys/file.h>
-#include <sys/namei.h>
 #include <sys/mount.h>		/* to define statvfs structure */
-#include <sys/vnode.h>		/* to define vattr structure */
 #include <sys/errno.h>
 #include <sys/dirent.h>
 #include <sys/kauth.h>
+#ifdef _KERNEL
+#include <sys/namei.h>
+#include <sys/buf.h>
+#include <sys/vnode.h>		/* to define vattr structure */
+#else
+#include <ffs/buf.h>
+#endif
 
 /*
  * msdosfs include files.

Index: src/sys/fs/msdosfs/msdosfs_lookup.c
diff -u src/sys/fs/msdosfs/msdosfs_lookup.c:1.27 src/sys/fs/msdosfs/msdosfs_lookup.c:1.28
--- src/sys/fs/msdosfs/msdosfs_lookup.c:1.27	Thu Dec 20 03:03:42 2012
+++ src/sys/fs/msdosfs/msdosfs_lookup.c	Fri Jan 25 19:21:49 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_lookup.c,v 1.27 2012/12/20 08:03:42 hannken Exp $	*/
+/*	$NetBSD: msdosfs_lookup.c,v 1.28 2013/01/26 00:21:49 christos Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -47,17 +47,26 @@
  * October 1992
  */
 
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
+
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_lookup.c,v 1.27 2012/12/20 08:03:42 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_lookup.c,v 1.28 2013/01/26 00:21:49 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
+#include <sys/mount.h>
+#include <sys/kauth.h>
 #include <sys/namei.h>
+#include <sys/dirent.h>
+
+#ifdef _KERNEL
 #include <sys/buf.h>
 #include <sys/vnode.h>
-#include <sys/mount.h>
-#include <sys/dirent.h>
-#include <sys/kauth.h>
+#else
+#include <ffs/buf.h>
+#endif /* _KERNEL */
 
 #include <fs/msdosfs/bpb.h>
 #include <fs/msdosfs/direntry.h>
@@ -65,6 +74,8 @@ __KERNEL_RCSID(0, "$NetBSD: msdosfs_look
 #include <fs/msdosfs/msdosfsmount.h>
 #include <fs/msdosfs/fat.h>
 
+
+#ifdef _KERNEL
 /*
  * When we search a directory the blocks containing directory entries are
  * read and examined.  The directory entries contain information that would
@@ -559,6 +570,7 @@ foundroot:
 
 	return 0;
 }
+#endif /* _KERNEL */
 
 /*
  * dep  - directory entry to copy into the directory
@@ -572,13 +584,17 @@ createde(struct denode *dep, struct deno
 {
 	int error, rberror;
 	u_long dirclust, clusoffset;
-	u_long fndoffset, havecnt=0, wcnt=1;
+	u_long fndoffset, havecnt = 0, wcnt = 1, i;
 	struct direntry *ndep;
 	struct msdosfsmount *pmp = ddep->de_pmp;
 	struct buf *bp;
 	daddr_t bn;
-	int blsize, i;
+	int blsize;
+#ifdef _KERNEL
 	int async = ddep->de_pmp->pm_mountp->mnt_flag & MNT_ASYNC;
+#else
+#define async 0
+#endif
 
 #ifdef MSDOSFS_DEBUG
 	printf("createde(dep %p, ddep %p, depp %p, cnp %p)\n",
@@ -716,7 +732,7 @@ createde(struct denode *dep, struct deno
 	ndep = bptoep(pmp, bp, clusoffset);
 
 	havecnt = ddep->de_fndcnt + 1;
-	for(i=wcnt; i <= havecnt; i++) {
+	for(i = wcnt; i <= havecnt; i++) {
 		/* mark entry as deleted */
 		ndep->deName[0] = SLOT_DELETED;
 
@@ -980,7 +996,11 @@ removede(struct denode *pdep, struct den
 	int blsize;
 	struct msdosfsmount *pmp = pdep->de_pmp;
 	u_long offset = pdep->de_fndoffset;
+#ifdef _KERNEL
 	int async = pdep->de_pmp->pm_mountp->mnt_flag & MNT_ASYNC;
+#else
+#define async 0
+#endif
 
 #ifdef MSDOSFS_DEBUG
 	printf("removede(): filename %s, dep %p, offset %08lx\n",

Index: src/sys/fs/msdosfs/msdosfsmount.h
diff -u src/sys/fs/msdosfs/msdosfsmount.h:1.17 src/sys/fs/msdosfs/msdosfsmount.h:1.18
--- src/sys/fs/msdosfs/msdosfsmount.h:1.17	Sun Nov  4 12:57:59 2012
+++ src/sys/fs/msdosfs/msdosfsmount.h	Fri Jan 25 19:21:49 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfsmount.h,v 1.17 2012/11/04 17:57:59 jakllsch Exp $	*/
+/*	$NetBSD: msdosfsmount.h,v 1.18 2013/01/26 00:21:49 christos Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -96,7 +96,9 @@ struct msdosfs_args {
 MALLOC_DECLARE(M_MSDOSFSMNT);
 MALLOC_DECLARE(M_MSDOSFSTMP);
 #endif
+#endif
 
+#if defined(_KERNEL) || defined(MAKEFS)
 /*
  * Layout of the mount control block for a MSDOSFS file system.
  */
@@ -247,5 +249,5 @@ void msdosfs_init(void);
 void msdosfs_reinit(void);
 void msdosfs_done(void);
 
-#endif /* _KERNEL */
+#endif /* _KERNEL || MAKEFS */
 #endif /* _MSDOSFS_MSDOSFSMOUNT_H_ */

Reply via email to