read without generating spurious headaches.
-/* $OpenBSD: bootsect.h,v 1.5 2006/12/15 03:04:24 krw Exp $ */
+/* $OpenBSD: bootsect.h,v 1.6 2015/10/23 10:45:31 krw Exp $ */
/* $NetBSD: bootsect.h,v 1.8 1997/10/17 11:23:29 ws Exp $ */
/*
* Written by Paul Popelka (paulp@uts.amdahl.com)
- *
+ *
* You can do anything you want with this software, just don't say you wrote
* it, and don't remove this notice.
- *
+ *
* This software is provided "as is".
- *
+ *
* The author supplies this software to be publicly redistributed on the
* understanding that the author is not responsible for the correct
* functioning of this software in any circumstances and is not liable for
* any damages caused by this software.
- *
+ *
* October 1992
*/
-/* $OpenBSD: bpb.h,v 1.6 2014/12/19 22:44:59 guenther Exp $ */
+/* $OpenBSD: bpb.h,v 1.7 2015/10/23 10:45:31 krw Exp $ */
/* $NetBSD: bpb.h,v 1.6 1997/10/17 11:23:35 ws Exp $ */
/*
* Written by Paul Popelka (paulp@uts.amdahl.com)
- *
+ *
* You can do anything you want with this software, just don't say you wrote
* it, and don't remove this notice.
- *
+ *
* This software is provided "as is".
- *
+ *
* The author supplies this software to be publicly redistributed on the
* understanding that the author is not responsible for the correct
* functioning of this software in any circumstances and is not liable for
* any damages caused by this software.
- *
+ *
* October 1992
*/
-/* $OpenBSD: denode.h,v 1.26 2013/06/11 16:42:16 deraadt Exp $ */
+/* $OpenBSD: denode.h,v 1.27 2015/10/23 10:45:31 krw Exp $ */
/* $NetBSD: denode.h,v 1.24 1997/10/17 11:23:39 ws Exp $ */
/*-
*/
/*
* Written by Paul Popelka (paulp@uts.amdahl.com)
- *
+ *
* You can do anything you want with this software, just don't say you wrote
* it, and don't remove this notice.
- *
+ *
* This software is provided "as is".
- *
+ *
* The author supplies this software to be publicly redistributed on the
* understanding that the author is not responsible for the correct
* functioning of this software in any circumstances and is not liable for
* any damages caused by this software.
- *
+ *
* October 1992
*/
-/* $OpenBSD: direntry.h,v 1.6 2002/03/14 01:27:09 millert Exp $ */
+/* $OpenBSD: direntry.h,v 1.7 2015/10/23 10:45:31 krw Exp $ */
/* $NetBSD: direntry.h,v 1.13 1997/10/17 11:23:45 ws Exp $ */
/*-
*/
/*
* Written by Paul Popelka (paulp@uts.amdahl.com)
- *
+ *
* You can do anything you want with this software, just don't say you wrote
* it, and don't remove this notice.
- *
+ *
* This software is provided "as is".
- *
+ *
* The author supplies this software to be publicly redistributed on the
* understanding that the author is not responsible for the correct
* functioning of this software in any circumstances and is not liable for
* any damages caused by this software.
- *
+ *
* October 1992
*/
-/* $OpenBSD: fat.h,v 1.10 2013/06/11 16:42:16 deraadt Exp $ */
+/* $OpenBSD: fat.h,v 1.11 2015/10/23 10:45:31 krw Exp $ */
/* $NetBSD: fat.h,v 1.11 1997/10/17 11:23:49 ws Exp $ */
/*-
*/
/*
* Written by Paul Popelka (paulp@uts.amdahl.com)
- *
+ *
* You can do anything you want with this software, just don't say you wrote
* it, and don't remove this notice.
- *
+ *
* This software is provided "as is".
- *
+ *
* The author supplies this software to be publicly redistributed on the
* understanding that the author is not responsible for the correct
* functioning of this software in any circumstances and is not liable for
* any damages caused by this software.
- *
+ *
* October 1992
*/
-/* $OpenBSD: msdosfs_conv.c,v 1.18 2014/12/16 18:30:04 tedu Exp $ */
+/* $OpenBSD: msdosfs_conv.c,v 1.19 2015/10/23 10:45:31 krw Exp $ */
/* $NetBSD: msdosfs_conv.c,v 1.24 1997/10/17 11:23:54 ws Exp $ */
/*-
*/
/*
* Written by Paul Popelka (paulp@uts.amdahl.com)
- *
+ *
* You can do anything you want with this software, just don't say you wrote
* it, and don't remove this notice.
- *
+ *
* This software is provided "as is".
- *
+ *
* The author supplies this software to be publicly redistributed on the
* understanding that the author is not responsible for the correct
* functioning of this software in any circumstances and is not liable for
* any damages caused by this software.
- *
+ *
* October 1992
*/
c = dos2unix[*dn];
*un++ = lower ? u2l[c] : c;
dn++;
-
+
/*
* Copy the name portion into the unix filename string.
*/
thislong++;
}
dn += 8 - i;
-
+
/*
* Now, if there is an extension then put in a period and copy in
* the extension.
int conv = 1;
u_char *cp, *dp, *dp1;
u_char gentext[6];
-
+
/*
* Fill the dos filename string with blanks. These are DOS's pad
* characters.
*/
for (i = 0; i < 11; i++)
dn[i] = ' ';
-
+
/*
* The filenames "." and ".." are handled specially, since they
* don't follow dos filename rules.
break;
if (i < 0)
return 0;
-
+
/*
* Now find the extension
* Note: dot as first char doesn't start extension
break;
}
}
-
+
/*
* Now convert it
*/
*/
if (!j)
dn[0] = '_';
-
+
/*
* The first character cannot be E5,
* because that means a deleted entry
*/
if (dn[0] == 0xe5)
dn[0] = SLOT_E5;
-
+
/*
* If there wasn't any char dropped,
* there is no place for generation numbers
return 0;
return conv;
}
-
+
/*
* Now insert the generation number into the filename part
*/
un += (cnt - 1) * WIN_CHARS;
unlen -= (cnt - 1) * WIN_CHARS;
-
+
/*
* Initialize winentry to some useful default
*/
wep->weReserved1 = 0;
wep->weChksum = chksum;
wep->weReserved2 = 0;
-
+
/*
* Now convert the filename parts
*/
{
u_int8_t *cp;
int i;
-
+
/*
* First compare checksums
*/
chksum = -1;
if (chksum == -1)
return -1;
-
+
/*
* Offset of this entry
*/
if ((wep->weCnt&WIN_LAST) && unlen > WIN_CHARS)
return -1;
-
+
/*
* Compare the name parts
*/
if ((wep->weCnt&WIN_CNT) > howmany(WIN_MAXLEN, WIN_CHARS)
|| !(wep->weCnt&WIN_CNT))
return -1;
-
+
/*
* First compare checksums
*/
chksum = -1;
if (chksum == -1)
return -1;
-
+
/*
* Offset of this entry
*/
i = ((wep->weCnt&WIN_CNT) - 1) * WIN_CHARS;
np = (u_int8_t *)dp->d_name + i;
-
+
/*
* Convert the name parts
*/
{
int i;
u_int8_t s;
-
+
for (s = 0, i = 11; --i >= 0; s += *name++)
s = (s << 7)|(s >> 1);
return s;
-/* $OpenBSD: msdosfs_denode.c,v 1.53 2015/01/09 05:01:57 tedu Exp $ */
+/* $OpenBSD: msdosfs_denode.c,v 1.54 2015/10/23 10:45:31 krw Exp $ */
/* $NetBSD: msdosfs_denode.c,v 1.23 1997/10/17 11:23:58 ws Exp $ */
/*-
*/
/*
* Written by Paul Popelka (paulp@uts.amdahl.com)
- *
+ *
* You can do anything you want with this software, just don't say you wrote
* it, and don't remove this notice.
- *
+ *
* This software is provided "as is".
- *
+ *
* The author supplies this software to be publicly redistributed on the
* understanding that the author is not responsible for the correct
* functioning of this software in any circumstances and is not liable for
* any damages caused by this software.
- *
+ *
* October 1992
*/
{
struct denode *dep;
struct proc *p = curproc; /* XXX */
-
+
for (;;)
for (dep = dehashtbl[DEHASH(dev, dirclust, diroff)]; ;
dep = dep->de_next) {
depp = &dehashtbl[DEHASH(dep->de_dev, dep->de_dirclust,
dep->de_diroffset)];
-
+
for (deq = *depp; deq; deq = deq->de_next) {
if (dep->de_dirclust == deq->de_dirclust &&
dep->de_diroffset == deq->de_diroffset &&
}
/*
- * If deget() succeeds it returns with the gotten denode locked().
+ * If deget() succeeds it returns with the gotten denode locked().
*
* pmp - address of msdosfsmount structure of the filesystem containing
* the denode of interest. The pm_dev field and the address of
- * the msdosfsmount structure are used.
+ * the msdosfsmount structure are used.
* dirclust - which cluster bp contains, if dirclust is 0 (root directory)
* diroffset is relative to the beginning of the root directory,
- * otherwise it is cluster relative.
- * diroffset - offset past begin of cluster of denode we want
+ * otherwise it is cluster relative.
+ * diroffset - offset past begin of cluster of denode we want
* depp - returns the address of the gotten denode.
*/
int
* the directory entry to compute the hash value. For subdir use
* address of "." entry. For root dir (if not FAT32) use cluster
* MSDOSFSROOT, offset MSDOSFSROOT_OFS
- *
+ *
* NOTE: The check for de_refcnt > 0 below insures the denode being
* examined does not represent an unlinked but still open file.
* These files are not to be accessible even when the directory
if (error) {
vput (nvp);
-
+
if (error == EEXIST)
goto retry;
struct msdosfsmount *pmp = dep->de_pmp;
uint32_t count;
int error;
-
+
/*
* The root of a DOS filesystem cannot be extended.
*/
if (length <= dep->de_FileSize)
panic("deextend: file too large");
-
+
/*
* Compute the number of clusters to allocate.
*/
return (error);
}
}
-
+
dep->de_FileSize = length;
dep->de_flag |= DE_UPDATE|DE_MODIFIED;
return (deupdat(dep, 1));
if (prtactive && vp->v_usecount != 0)
vprint("msdosfs_reclaim(): pushing active", vp);
#endif
-
+
#ifdef MSDOSFS_DEBUG
printf("msdosfs_reclaim(): dep %08x, file %.11s, refcnt %d\n",
dep, dep->de_Name, dep->de_refcnt);
if (prtactive && vp->v_usecount != 0)
vprint("msdosfs_inactive(): pushing active", vp);
#endif
-
+
#ifdef MSDOSFS_DEBUG
printf("msdosfs_inactive(): dep %08x, de_Name[0] %x\n", dep,
dep->de_Name[0]);
/*
* Get rid of denodes related to stale file handles.
*/
- if (dep->de_Name[0] == SLOT_DELETED)
+ if (dep->de_Name[0] == SLOT_DELETED)
goto out;
/*
-/* $OpenBSD: msdosfs_fat.c,v 1.26 2014/12/16 18:30:04 tedu Exp $ */
+/* $OpenBSD: msdosfs_fat.c,v 1.27 2015/10/23 10:45:31 krw Exp $ */
/* $NetBSD: msdosfs_fat.c,v 1.26 1997/10/17 11:24:02 ws Exp $ */
/*-
*/
/*
* Written by Paul Popelka (paulp@uts.amdahl.com)
- *
+ *
* You can do anything you want with this software, just don't say you wrote
* it, and don't remove this notice.
- *
+ *
* This software is provided "as is".
- *
+ *
* The author supplies this software to be publicly redistributed on the
* understanding that the author is not responsible for the correct
* functioning of this software in any circumstances and is not liable for
* any damages caused by this software.
- *
+ *
* October 1992
*/
/*
* Updating entries in 12 bit fats is a pain in the butt.
- *
+ *
* The following picture shows where nibbles go when moving from a 12 bit
* cluster number into the appropriate bytes in the FAT.
- *
+ *
* byte m byte m+1 byte m+2
* +----+----+ +----+----+ +----+----+
* | 0 1 | | 2 3 | | 4 5 | FAT bytes
* +----+----+ +----+----+ +----+----+
- *
+ *
* +----+----+----+ +----+----+----+
* | 3 0 1 | | 4 5 2 |
* +----+----+----+ +----+----+----+
- * cluster n cluster n+1
- *
+ * cluster n cluster n+1
+ *
* Where n is even. m = n + (n >> 2)
- *
+ *
*/
static __inline void
usemap_alloc(struct msdosfsmount *pmp, uint32_t cn)
* cluster'th entry if this is a get function
* newcontents - the new value to be written into the cluster'th element of
* the fat if this is a set function.
- *
+ *
* This function can also be used to free a cluster by setting the fat entry
* for a cluster to 0.
- *
+ *
* All copies of the fat are updated if this is a set function. NOTE: If
* fatentry() marks a cluster as free it does not update the inusemap in
* the msdosfsmount structure. This is left to the caller.
brelse(bp);
return (error);
}
-
+
if (function & FAT_GET) {
if (FAT32(pmp))
readcn = getulong(&bp->b_data[bo]);
int error;
uint32_t bn, bo, bsize, byteoffset, readcn, newc;
struct buf *bp;
-
+
#ifdef MSDOSFS_DEBUG
printf("fatchain(pmp %08x, start %d, count %d, fillwith %d)\n",
pmp, start, count, fillwith);
*/
if (start < CLUST_FIRST || start + count - 1 > pmp->pm_maxcluster)
return (EINVAL);
-
+
while (count > 0) {
byteoffset = FATOFS(pmp, start);
fatblock(pmp, byteoffset, &bn, &bsize, &bo);
uint32_t idx, max_idx;
u_int map;
uint32_t len;
-
+
max_idx = pmp->pm_maxcluster / N_INUSEBITS;
idx = start / N_INUSEBITS;
start %= N_INUSEBITS;
uint32_t len, newst, foundl, cn, l;
uint32_t foundcn = 0; /* XXX: foundcn could be used uninitialized */
u_int map;
-
+
#ifdef MSDOSFS_DEBUG
printf("clusteralloc(): find %d clusters\n",count);
#endif
* This is a new file, initialize start
*/
struct timeval tv;
-
+
microtime(&tv);
start = (tv.tv_usec >> 10) | tv.tv_usec;
len = 0;
}
-
+
/*
* Start at a (pseudo) random place to maximize cluster runs
* under multiple writers.
*/
newst = (start * 1103515245 + 12345) % (pmp->pm_maxcluster + 1);
foundl = 0;
-
+
for (cn = newst; cn <= pmp->pm_maxcluster;) {
idx = cn / N_INUSEBITS;
map = pmp->pm_inusemap[idx];
uint32_t cn, got;
struct msdosfsmount *pmp = dep->de_pmp;
struct buf *bp;
-
+
/*
* Don't try to extend the root directory
*/
error = clusteralloc(pmp, cn, count, CLUST_EOFE, &cn, &got);
if (error)
return (error);
-
+
count -= got;
-
+
/*
* Give them the filesystem relative cluster number if they want
* it.
*ncp = cn;
ncp = NULL;
}
-
+
if (dep->de_StartCluster == 0) {
dep->de_StartCluster = cn;
frcn = 0;
}
frcn = dep->de_fc[FC_LASTFC].fc_frcn + 1;
}
-
+
/*
* Update the "last cluster of the file" entry in the denode's fat
* cache.
*/
fc_setcache(dep, FC_LASTFC, frcn + got - 1, cn + got - 1);
-
+
if (flags & DE_CLEAR) {
while (got-- > 0) {
/*
}
}
}
-
+
return (0);
}
-/* $OpenBSD: msdosfs_lookup.c,v 1.27 2014/12/16 18:30:04 tedu Exp $ */
+/* $OpenBSD: msdosfs_lookup.c,v 1.28 2015/10/23 10:45:31 krw Exp $ */
/* $NetBSD: msdosfs_lookup.c,v 1.34 1997/10/18 22:12:27 ws Exp $ */
/*-
*/
/*
* Written by Paul Popelka (paulp@uts.amdahl.com)
- *
+ *
* You can do anything you want with this software, just don't say you wrote
* it, and don't remove this notice.
- *
+ *
* This software is provided "as is".
- *
+ *
* The author supplies this software to be publicly redistributed on the
* understanding that the author is not responsible for the correct
* functioning of this software in any circumstances and is not liable for
* any damages caused by this software.
- *
+ *
* October 1992
*/
if ((nameiop == CREATE || nameiop == RENAME) &&
(flags & ISLASTCN))
slotcount = 0;
-
+
#ifdef MSDOSFS_DEBUG
printf("msdosfs_lookup(): dos version of filename '%.11s', length %d\n",
dosfilename, cnp->cn_namelen);
* Drop memory of previous long matches
*/
chksum = -1;
-
+
if (slotcount < wincnt) {
slotcount++;
slotoffset = diroff;
*/
if (slotcount < wincnt)
slotcount = 0;
-
+
/*
* Check for Win95 long filename entry
*/
chksum);
continue;
}
-
+
/*
* Ignore volume labels (anywhere, not just
* the root directory).
}
if (wincnt > slotcount)
slotoffset += sizeof(struct direntry) * (wincnt - slotcount);
-
+
/*
* If we get here we didn't find the entry we were looking for. But
* that's ok if we are creating or renaming and are at the end of
* in a deadlock.
*/
brelse(bp);
-
+
foundroot:;
/*
* If we entered at foundroot, then we are looking for the . or ..
struct buf *bp;
daddr_t bn;
int blsize;
-
+
#ifdef MSDOSFS_DEBUG
printf("createde(dep %08x, ddep %08x, depp %08x, cnp %08x)\n",
dep, ddep, depp, cnp);
*/
ddep->de_FileSize += de_cn2off(pmp, dirclust);
}
-
+
/*
* We just read in the cluster with space. Copy the new directory
* entry in. Then write it to disk. NOTE: DOS directories
return error;
}
ndep = bptoep(pmp, bp, ddep->de_fndoffset);
-
+
DE_EXTERNALIZE(ndep, dep);
/*
u_char *un = (u_char *)cnp->cn_nameptr;
int unlen = cnp->cn_namelen;
int cnt = 1;
-
+
while (--ddep->de_fndcnt >= 0) {
if (!(ddep->de_fndoffset & pmp->pm_crbomask)) {
if ((error = bwrite(bp)) != 0)
break;
}
}
-
+
if ((error = bwrite(bp)) != 0)
return error;
}
return deget(pmp, dirclust, diroffset, depp);
}
-
+
return 0;
}
int blsize;
struct msdosfsmount *pmp = pdep->de_pmp;
uint32_t offset = pdep->de_fndoffset;
-
+
#ifdef MSDOSFS_DEBUG
printf("removede(): filename %.11s, dep %08x, offset %08x\n",
dep->de_Name, dep, offset);
*/
if (!unix2dosfn((u_char *)cnp->cn_nameptr, cp, cnp->cn_namelen, gen))
return gen == 1 ? EINVAL : EEXIST;
-
+
/*
* Now look for a dir entry with this exact name
*/
-/* $OpenBSD: msdosfs_vfsops.c,v 1.71 2015/02/13 13:35:03 millert Exp $ */
+/* $OpenBSD: msdosfs_vfsops.c,v 1.72 2015/10/23 10:45:31 krw Exp $ */
/* $NetBSD: msdosfs_vfsops.c,v 1.48 1997/10/18 02:54:57 briggs Exp $ */
/*-
*/
/*
* Written by Paul Popelka (paulp@uts.amdahl.com)
- *
+ *
* You can do anything you want with this software, just don't say you wrote
* it, and don't remove this notice.
- *
+ *
* This software is provided "as is".
- *
+ *
* The author supplies this software to be publicly redistributed on the
* understanding that the author is not responsible for the correct
* functioning of this software in any circumstances and is not liable for
* any damages caused by this software.
- *
+ *
* October 1992
*/
int msdosfs_sync_vnode(struct vnode *, void *);
/*
- * mp - path - addr in user space of mount point (ie /usr or whatever)
+ * mp - path - addr in user space of mount point (ie /usr or whatever)
* data - addr in user space of mount params including the name of the block
- * special file to treat as a filesystem.
+ * special file to treat as a filesystem.
*/
int
msdosfs_mount(struct mount *mp, const char *path, void *data,
/*
* Process export requests.
*/
- return (vfs_export(mp, &pmp->pm_export,
+ return (vfs_export(mp, &pmp->pm_export,
&args.export_info));
}
}
else if (!(pmp->pm_flags &
(MSDOSFSMNT_SHORTNAME | MSDOSFSMNT_LONGNAME))) {
struct vnode *rvp;
-
+
/*
* Try to divine whether to support Win'95 long filenames
*/
/* Determine the number of DEV_BSIZE blocks in a MSDOSFS sector */
pmp->pm_BlkPerSec = pmp->pm_BytesPerSec / DEV_BSIZE;
- if (!pmp->pm_BytesPerSec || !SecPerClust || pmp->pm_SecPerTrack > 64) {
+ if (!pmp->pm_BytesPerSec || !SecPerClust || pmp->pm_SecPerTrack > 64) {
error = EFTYPE;
goto error_exit;
}
* MSDOSFS sectors per cluster: >0 && power of 2
* MSDOSFS sector size: >= DEV_BSIZE && power of 2
* HUGE sector count: >0
- * FAT sectors: >0
+ * FAT sectors: >0
*/
if ((SecPerClust == 0) || (SecPerClust & (SecPerClust - 1)) ||
(pmp->pm_BytesPerSec < DEV_BSIZE) ||
(SecPerClust * pmp->pm_BlkPerSec > MAXBSIZE / DEV_BSIZE)) {
error = EINVAL;
goto error_exit;
- }
-
+ }
+
pmp->pm_HugeSectors *= pmp->pm_BlkPerSec;
pmp->pm_HiddenSects *= pmp->pm_BlkPerSec;
pmp->pm_FATsecs *= pmp->pm_BlkPerSec;
struct denode *dep;
dep = VTODE(vp);
- if (vp->v_type == VNON ||
+ if (vp->v_type == VNON ||
((dep->de_flag & (DE_ACCESS | DE_CREATE | DE_UPDATE | DE_MODIFIED)) == 0
&& LIST_EMPTY(&vp->v_dirtyblkhd)) ||
msa->waitfor == MNT_LAZY) {
-/* $OpenBSD: msdosfs_vnops.c,v 1.101 2015/09/23 15:37:26 tedu Exp $ */
+/* $OpenBSD: msdosfs_vnops.c,v 1.102 2015/10/23 10:45:31 krw Exp $ */
/* $NetBSD: msdosfs_vnops.c,v 1.63 1997/10/17 11:24:19 ws Exp $ */
/*-
vap->va_gen = 0;
vap->va_blocksize = dep->de_pmp->pm_bpcluster;
vap->va_bytes = (dep->de_FileSize + dep->de_pmp->pm_crbomask) &
- ~(dep->de_pmp->pm_crbomask);
+ ~(dep->de_pmp->pm_crbomask);
vap->va_type = ap->a_vp->v_type;
return (0);
}
vrele(fvp);
return (error);
}
-
+
/*
* If source and dest are the same, do nothing.
*/
CASE_LOWER_BASE | CASE_LOWER_EXT, /* lower case */
0, /* create time 100ths */
{ 0, 0 }, { 0, 0 }, /* create time & date */
- { 0, 0 }, /* access date */
+ { 0, 0 }, /* access date */
{ 0, 0 }, /* high bits of start cluster */
{ 210, 4 }, { 210, 4 }, /* modify time & date */
{ 0, 0 }, /* startcluster */
- { 0, 0, 0, 0 } /* filesize */
+ { 0, 0, 0, 0 } /* filesize */
},
{ ".. ", " ", /* the .. entry */
ATTR_DIRECTORY, /* file attribute */
clrbuf(bp);
}
if (bp->b_blkno == -1) {
- s = splbio();
+ s = splbio();
biodone(bp);
splx(s);
return (error);
-/* $OpenBSD: msdosfsmount.h,v 1.19 2009/01/05 01:14:40 krw Exp $ */
+/* $OpenBSD: msdosfsmount.h,v 1.20 2015/10/23 10:45:31 krw Exp $ */
/* $NetBSD: msdosfsmount.h,v 1.16 1997/10/17 11:24:24 ws Exp $ */
/*-
*/
/*
* Written by Paul Popelka (paulp@uts.amdahl.com)
- *
+ *
* You can do anything you want with this software, just don't say you wrote
* it, and don't remove this notice.
- *
+ *
* This software is provided "as is".
- *
+ *
* The author supplies this software to be publicly redistributed on the
* understanding that the author is not responsible for the correct
* functioning of this software in any circumstances and is not liable for
* any damages caused by this software.
- *
+ *
* October 1992
*/