Changeset View
Changeset View
Standalone View
Standalone View
sys/fs/msdosfs/msdosfs_lookup.c
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | |||||
* understanding that the author is not responsible for the correct | * understanding that the author is not responsible for the correct | ||||
* functioning of this software in any circumstances and is not liable for | * functioning of this software in any circumstances and is not liable for | ||||
* any damages caused by this software. | * any damages caused by this software. | ||||
* | * | ||||
* October 1992 | * October 1992 | ||||
*/ | */ | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/errno.h> | |||||
#ifndef MAKEFS | |||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/buf.h> | #include <sys/buf.h> | ||||
#include <sys/mount.h> | #include <sys/mount.h> | ||||
#include <sys/namei.h> | #include <sys/namei.h> | ||||
#include <sys/vnode.h> | #include <sys/vnode.h> | ||||
#else | |||||
#include <string.h> | |||||
#include "ffs/buf.h" | |||||
#include "msdos/msdosfs_extern.h" | |||||
#endif | |||||
#include <fs/msdosfs/bpb.h> | #include <fs/msdosfs/bpb.h> | ||||
#include <fs/msdosfs/direntry.h> | #include <fs/msdosfs/direntry.h> | ||||
#include <fs/msdosfs/denode.h> | #include <fs/msdosfs/denode.h> | ||||
#include <fs/msdosfs/fat.h> | #include <fs/msdosfs/fat.h> | ||||
#include <fs/msdosfs/msdosfsmount.h> | #include <fs/msdosfs/msdosfsmount.h> | ||||
#ifndef MAKEFS | |||||
static int msdosfs_lookup_(struct vnode *vdp, struct vnode **vpp, | static int msdosfs_lookup_(struct vnode *vdp, struct vnode **vpp, | ||||
struct componentname *cnp, uint64_t *inum); | struct componentname *cnp, uint64_t *inum); | ||||
int | int | ||||
msdosfs_lookup(struct vop_cachedlookup_args *ap) | msdosfs_lookup(struct vop_cachedlookup_args *ap) | ||||
{ | { | ||||
return (msdosfs_lookup_(ap->a_dvp, ap->a_vpp, ap->a_cnp, NULL)); | return (msdosfs_lookup_(ap->a_dvp, ap->a_vpp, ap->a_cnp, NULL)); | ||||
▲ Show 20 Lines • Show All 507 Lines • ▼ Show 20 Lines | foundroot: | ||||
/* | /* | ||||
* Insert name into cache if appropriate. | * Insert name into cache if appropriate. | ||||
*/ | */ | ||||
if (cnp->cn_flags & MAKEENTRY) | if (cnp->cn_flags & MAKEENTRY) | ||||
cache_enter(vdp, *vpp, cnp); | cache_enter(vdp, *vpp, cnp); | ||||
return (0); | return (0); | ||||
} | } | ||||
#endif /* !MAKEFS */ | |||||
/* | /* | ||||
* dep - directory entry to copy into the directory | * dep - directory entry to copy into the directory | ||||
* ddep - directory to add to | * ddep - directory to add to | ||||
* depp - return the address of the denode for the created directory entry | * depp - return the address of the denode for the created directory entry | ||||
* if depp != 0 | * if depp != 0 | ||||
* cnp - componentname needed for Win95 long filenames | * cnp - componentname needed for Win95 long filenames | ||||
*/ | */ | ||||
int | int | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | if (error) | ||||
return error; | return error; | ||||
diroffset = ddep->de_fndoffset; | diroffset = ddep->de_fndoffset; | ||||
if (dirclust != MSDOSFSROOT) | if (dirclust != MSDOSFSROOT) | ||||
diroffset &= pmp->pm_crbomask; | diroffset &= pmp->pm_crbomask; | ||||
if ((error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp)) != 0) { | if ((error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp)) != 0) { | ||||
brelse(bp); | brelse(bp); | ||||
return error; | return error; | ||||
} | } | ||||
ndep = bptoep(pmp, bp, ddep->de_fndoffset); | ndep = bptoep(pmp, bp, ddep->de_fndoffset); | ||||
emaste: can you explain this one? | |||||
Not Done Inline ActionsThis came from here: http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/msdosfs/Attic/msdosfs_lookup.c.diff?r1=1.46&r2=1.47&only_with_tag=MAIN&f=h Wed Mar 22 14:56:56 2000 UTC (17 years, 2 months ago) by jdolecek createde(): if an error occurs, make sure to mark all modified directory slots as deleted - otherwise we would leave bogus slots in This change actually seems to be redundant, as both in netbsd's and freebsd's code, we have a macro definition in sys/fs/msdosfs/msdosfsmount.h: #define bptoep(pmp, bp, dirofs) \ ((struct direntry *)(((char *)(bp)->b_data) \ + ((dirofs) & (pmp)->pm_crbomask))) Thus, the line above, if (dirclust != MSDOSFSROOT) ... is also redundant, since we are just doing a bitwise AND twice. Should I remove these redundant lines and revert the change? smahadevan_freebsdfoundation.org: This came from here: http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/msdosfs/Attic/msdosfs_lookup.c. | |||||
DE_EXTERNALIZE(ndep, dep); | DE_EXTERNALIZE(ndep, dep); | ||||
/* | /* | ||||
* Now write the Win95 long name | * Now write the Win95 long name | ||||
*/ | */ | ||||
if (ddep->de_fndcnt > 0) { | if (ddep->de_fndcnt > 0) { | ||||
uint8_t chksum = winChksum(ndep->deName); | uint8_t chksum = winChksum(ndep->deName); | ||||
Show All 12 Lines | while (--ddep->de_fndcnt >= 0) { | ||||
error = pcbmap(ddep, | error = pcbmap(ddep, | ||||
de_cluster(pmp, | de_cluster(pmp, | ||||
ddep->de_fndoffset), | ddep->de_fndoffset), | ||||
&bn, 0, &blsize); | &bn, 0, &blsize); | ||||
if (error) | if (error) | ||||
return error; | return error; | ||||
error = bread(pmp->pm_devvp, bn, blsize, | error = bread(pmp->pm_devvp, bn, blsize, | ||||
NOCRED, &bp); | NOCRED, &bp); | ||||
Not Done Inline Actionswe don't want to mix style & functional changes emaste: we don't want to mix style & functional changes | |||||
if (error) { | if (error) { | ||||
brelse(bp); | brelse(bp); | ||||
return error; | return error; | ||||
} | } | ||||
ndep = bptoep(pmp, bp, ddep->de_fndoffset); | ndep = bptoep(pmp, bp, ddep->de_fndoffset); | ||||
} else { | } else { | ||||
ndep--; | ndep--; | ||||
ddep->de_fndoffset -= sizeof(struct direntry); | ddep->de_fndoffset -= sizeof(struct direntry); | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | if ((error = pcbmap(dep, cn, &bn, 0, &blsize)) != 0) { | ||||
return (0); | return (0); | ||||
} | } | ||||
error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp); | error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp); | ||||
if (error) { | if (error) { | ||||
brelse(bp); | brelse(bp); | ||||
return (0); | return (0); | ||||
} | } | ||||
for (dentp = (struct direntry *)bp->b_data; | for (dentp = (struct direntry *)bp->b_data; | ||||
(char *)dentp < bp->b_data + blsize; | (char *)dentp < (char *)bp->b_data + blsize; | ||||
Not Done Inline ActionsFrom NetBSD Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. emaste: From NetBSD `Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.`
| |||||
dentp++) { | dentp++) { | ||||
if (dentp->deName[0] != SLOT_DELETED && | if (dentp->deName[0] != SLOT_DELETED && | ||||
(dentp->deAttributes & ATTR_VOLUME) == 0) { | (dentp->deAttributes & ATTR_VOLUME) == 0) { | ||||
/* | /* | ||||
* In dos directories an entry whose name | * In dos directories an entry whose name | ||||
* starts with SLOT_EMPTY (0) starts the | * starts with SLOT_EMPTY (0) starts the | ||||
* beginning of the unused part of the | * beginning of the unused part of the | ||||
* directory, so we can just return that it | * directory, so we can just return that it | ||||
▲ Show 20 Lines • Show All 273 Lines • ▼ Show 20 Lines | for (cn = error = 0; !error; cn++) { | ||||
return error; | return error; | ||||
} | } | ||||
error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp); | error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp); | ||||
if (error) { | if (error) { | ||||
brelse(bp); | brelse(bp); | ||||
return error; | return error; | ||||
} | } | ||||
for (dentp = (struct direntry *)bp->b_data; | for (dentp = (struct direntry *)bp->b_data; | ||||
(char *)dentp < bp->b_data + blsize; | (char *)dentp < (char *)bp->b_data + blsize; | ||||
dentp++) { | dentp++) { | ||||
if (dentp->deName[0] == SLOT_EMPTY) { | if (dentp->deName[0] == SLOT_EMPTY) { | ||||
/* | /* | ||||
* Last used entry and not found | * Last used entry and not found | ||||
*/ | */ | ||||
brelse(bp); | brelse(bp); | ||||
return 0; | return 0; | ||||
} | } | ||||
Show All 14 Lines |
can you explain this one?