diff options
author | 2016-10-16 19:16:39 +0000 | |
---|---|---|
committer | 2016-10-16 19:16:39 +0000 | |
commit | 047015fa761358b9d9f849d61499ad00e1bcf8ef (patch) | |
tree | 995ce2016d9045ff4f48c9842f1d1177b947812a | |
parent | Notifys can go via the command queue instead of using their own queue. (diff) | |
download | wireguard-openbsd-047015fa761358b9d9f849d61499ad00e1bcf8ef.tar.xz wireguard-openbsd-047015fa761358b9d9f849d61499ad00e1bcf8ef.zip |
Remove some unused functions. Found by cppcheck from ports.
-rw-r--r-- | usr.sbin/makefs/ffs/ffs_alloc.c | 97 | ||||
-rw-r--r-- | usr.sbin/makefs/ffs/ffs_extern.h | 3 | ||||
-rw-r--r-- | usr.sbin/makefs/fs/msdosfs/denode.h | 4 | ||||
-rw-r--r-- | usr.sbin/makefs/fs/msdosfs/msdosfs_lookup.c | 292 | ||||
-rw-r--r-- | usr.sbin/makefs/ufs/ffs/ffs_extern.h | 2 | ||||
-rw-r--r-- | usr.sbin/makefs/ufs/ffs/ffs_subr.c | 58 |
6 files changed, 0 insertions, 456 deletions
diff --git a/usr.sbin/makefs/ffs/ffs_alloc.c b/usr.sbin/makefs/ffs/ffs_alloc.c index 74aa0d1cad3..dfd2784c9b2 100644 --- a/usr.sbin/makefs/ffs/ffs_alloc.c +++ b/usr.sbin/makefs/ffs/ffs_alloc.c @@ -413,103 +413,6 @@ gotit: return (blkno); } -/* - * Free a block or fragment. - * - * The specified block or fragment is placed back in the - * free map. If a fragment is deallocated, a possible - * block reassembly is checked. - */ -void -ffs_blkfree(struct inode *ip, daddr_t bno, long size) -{ - struct cg *cgp; - struct buf *bp; - int32_t fragno, cgbno; - int i, error, cg, blk, frags, bbase; - struct fs *fs = ip->i_fs; - const int needswap = UFS_FSNEEDSWAP(fs); - - if (size > fs->fs_bsize || ffs_fragoff(fs, size) != 0 || - ffs_fragnum(fs, bno) + ffs_numfrags(fs, size) > fs->fs_frag) { - errx(EXIT_FAILURE, "%s: bad size: bno %lld bsize %d " - "size %ld", __func__, (long long)bno, fs->fs_bsize, size); - } - cg = dtog(fs, bno); - if (bno >= fs->fs_size) { - warnx("bad block %lld, ino %llu", (long long)bno, - (unsigned long long)ip->i_number); - return; - } - error = bread(ip->i_devvp, FFS_FSBTODB(fs, cgtod(fs, cg)), - (int)fs->fs_cgsize, 0, &bp); - if (error) { - brelse(bp, 0); - return; - } - cgp = (struct cg *)bp->b_data; - if (!cg_chkmagic(cgp, needswap)) { - brelse(bp, 0); - return; - } - cgbno = dtogd(fs, bno); - if (size == fs->fs_bsize) { - fragno = ffs_fragstoblks(fs, cgbno); - if (!ffs_isfreeblock(fs, cg_blksfree(cgp, needswap), fragno)) { - errx(EXIT_FAILURE, "%s: freeing free block %lld", - __func__, (long long)bno); - } - ffs_setblock(fs, cg_blksfree(cgp, needswap), fragno); - ffs_clusteracct(fs, cgp, fragno, 1); - ufs_add32(cgp->cg_cs.cs_nbfree, 1, needswap); - fs->fs_cstotal.cs_nbfree++; - fs->fs_cs(fs, cg).cs_nbfree++; - } else { - bbase = cgbno - ffs_fragnum(fs, cgbno); - /* - * decrement the counts associated with the old frags - */ - blk = blkmap(fs, cg_blksfree(cgp, needswap), bbase); - ffs_fragacct(fs, blk, cgp->cg_frsum, -1, needswap); - /* - * deallocate the fragment - */ - frags = ffs_numfrags(fs, size); - for (i = 0; i < frags; i++) { - if (isset(cg_blksfree(cgp, needswap), cgbno + i)) { - errx(EXIT_FAILURE, "%s: freeing free frag: " - "block %lld", __func__, - (long long)(cgbno + i)); - } - setbit(cg_blksfree(cgp, needswap), cgbno + i); - } - ufs_add32(cgp->cg_cs.cs_nffree, i, needswap); - fs->fs_cstotal.cs_nffree += i; - fs->fs_cs(fs, cg).cs_nffree += i; - /* - * add back in counts associated with the new frags - */ - blk = blkmap(fs, cg_blksfree(cgp, needswap), bbase); - ffs_fragacct(fs, blk, cgp->cg_frsum, 1, needswap); - /* - * if a complete block has been reassembled, account for it - */ - fragno = ffs_fragstoblks(fs, bbase); - if (ffs_isblock(fs, cg_blksfree(cgp, needswap), fragno)) { - ufs_add32(cgp->cg_cs.cs_nffree, -fs->fs_frag, needswap); - fs->fs_cstotal.cs_nffree -= fs->fs_frag; - fs->fs_cs(fs, cg).cs_nffree -= fs->fs_frag; - ffs_clusteracct(fs, cgp, fragno, 1); - ufs_add32(cgp->cg_cs.cs_nbfree, 1, needswap); - fs->fs_cstotal.cs_nbfree++; - fs->fs_cs(fs, cg).cs_nbfree++; - } - } - fs->fs_fmod = 1; - bdwrite(bp); -} - - static int scanc(u_int size, const u_char *cp, const u_char table[], int mask) { diff --git a/usr.sbin/makefs/ffs/ffs_extern.h b/usr.sbin/makefs/ffs/ffs_extern.h index 53e9fe2ee12..2f023c6462b 100644 --- a/usr.sbin/makefs/ffs/ffs_extern.h +++ b/usr.sbin/makefs/ffs/ffs_extern.h @@ -52,7 +52,6 @@ void panic(const char *, ...) int ffs_alloc(struct inode *, daddr_t, daddr_t, int, daddr_t *); daddr_t ffs_blkpref_ufs1(struct inode *, daddr_t, int, int32_t *); daddr_t ffs_blkpref_ufs2(struct inode *, daddr_t, int, int64_t *); -void ffs_blkfree(struct inode *, daddr_t, long); void ffs_clusteracct(struct fs *, struct cg *, int32_t, int); /* ffs_balloc.c */ @@ -66,9 +65,7 @@ void ffs_csum_swap(struct csum *, struct csum *, int); void ffs_cg_swap(struct cg *, struct cg *, struct fs *); /* ffs_subr.c */ -void ffs_fragacct(struct fs *, int, int32_t[], int, int); int ffs_isblock(struct fs *, u_char *, int32_t); -int ffs_isfreeblock(struct fs *, u_char *, int32_t); void ffs_clrblock(struct fs *, u_char *, int32_t); void ffs_setblock(struct fs *, u_char *, int32_t); diff --git a/usr.sbin/makefs/fs/msdosfs/denode.h b/usr.sbin/makefs/fs/msdosfs/denode.h index e60909fbac9..3a707c23052 100644 --- a/usr.sbin/makefs/fs/msdosfs/denode.h +++ b/usr.sbin/makefs/fs/msdosfs/denode.h @@ -307,14 +307,10 @@ int deextend(struct denode *, u_long, struct kauth_cred *); int deget(struct msdosfsmount *, u_long, u_long, struct denode **); int detrunc(struct denode *, u_long, int, struct kauth_cred *); int deupdat(struct denode *, int); -int doscheckpath(struct denode *, struct denode *); -int dosdirempty(struct denode *); int readde(struct denode *, struct buf **, struct direntry **); int readep(struct msdosfsmount *, u_long, u_long, struct buf **, struct direntry **); -int removede(struct denode *, struct denode *); int uniqdosname(struct denode *, struct componentname *, u_char *); -int findwin95(struct denode *); int msdosfs_gop_alloc(struct vnode *, off_t, off_t, int, struct kauth_cred *); void msdosfs_gop_markupdate(struct vnode *, int); void msdosfs_detimes(struct denode *, const struct timespec *, diff --git a/usr.sbin/makefs/fs/msdosfs/msdosfs_lookup.c b/usr.sbin/makefs/fs/msdosfs/msdosfs_lookup.c index cf6303c0297..7c839764e7c 100644 --- a/usr.sbin/makefs/fs/msdosfs/msdosfs_lookup.c +++ b/usr.sbin/makefs/fs/msdosfs/msdosfs_lookup.c @@ -260,169 +260,6 @@ createde(struct denode *dep, struct denode *ddep, struct denode **depp, struct c } /* - * Be sure a directory is empty except for "." and "..". Return 1 if empty, - * return 0 if not empty or error. - */ -int -dosdirempty(struct denode *dep) -{ - int blsize; - int error; - u_long cn; - daddr_t bn; - struct buf *bp; - struct msdosfsmount *pmp = dep->de_pmp; - struct direntry *dentp; - - /* - * Since the filesize field in directory entries for a directory is - * zero, we just have to feel our way through the directory until - * we hit end of file. - */ - for (cn = 0;; cn++) { - if ((error = pcbmap(dep, cn, &bn, 0, &blsize)) != 0) { - if (error == E2BIG) - return (1); /* it's empty */ - return (0); - } - error = bread(pmp->pm_devvp, de_bn2kb(pmp, bn), blsize, - 0, &bp); - if (error) { - return (0); - } - for (dentp = (struct direntry *)bp->b_data; - (char *)dentp < (char *)bp->b_data + blsize; - dentp++) { - if (dentp->deName[0] != SLOT_DELETED && - (dentp->deAttributes & ATTR_VOLUME) == 0) { - /* - * In dos directories an entry whose name - * starts with SLOT_EMPTY (0) starts the - * beginning of the unused part of the - * directory, so we can just return that it - * is empty. - */ - if (dentp->deName[0] == SLOT_EMPTY) { - brelse(bp, 0); - return (1); - } - /* - * Any names other than "." and ".." in a - * directory mean it is not empty. - */ - if (memcmp(dentp->deName, ". ", 11) && - memcmp(dentp->deName, ".. ", 11)) { - brelse(bp, 0); -#ifdef MSDOSFS_DEBUG - printf("dosdirempty(): found %.11s, %d, %d\n", - dentp->deName, dentp->deName[0], - dentp->deName[1]); -#endif - return (0); /* not empty */ - } - } - } - brelse(bp, 0); - } - /* NOTREACHED */ -} - -/* - * Check to see if the directory described by target is in some - * subdirectory of source. This prevents something like the following from - * succeeding and leaving a bunch or files and directories orphaned. mv - * /a/b/c /a/b/c/d/e/f Where c and f are directories. - * - * source - the inode for /a/b/c - * target - the inode for /a/b/c/d/e/f - * - * Returns 0 if target is NOT a subdirectory of source. - * Otherwise returns a non-zero error number. - * The target inode is always unlocked on return. - */ -int -doscheckpath(struct denode *source, struct denode *target) -{ - u_long scn; - struct msdosfsmount *pmp; - struct direntry *ep; - struct denode *dep; - struct buf *bp = NULL; - int error = 0; - - dep = target; - if ((target->de_Attributes & ATTR_DIRECTORY) == 0 || - (source->de_Attributes & ATTR_DIRECTORY) == 0) { - error = ENOTDIR; - goto out; - } - if (dep->de_StartCluster == source->de_StartCluster) { - error = EEXIST; - goto out; - } - if (dep->de_StartCluster == MSDOSFSROOT) - goto out; - pmp = dep->de_pmp; -#ifdef DIAGNOSTIC - if (pmp != source->de_pmp) - panic("doscheckpath: source and target on different filesystems"); -#endif - if (FAT32(pmp) && dep->de_StartCluster == pmp->pm_rootdirblk) - goto out; - - for (;;) { - if ((dep->de_Attributes & ATTR_DIRECTORY) == 0) { - error = ENOTDIR; - break; - } - scn = dep->de_StartCluster; - error = bread(pmp->pm_devvp, de_bn2kb(pmp, cntobn(pmp, scn)), - pmp->pm_bpcluster, 0, &bp); - if (error) - break; - - ep = (struct direntry *) bp->b_data + 1; - if ((ep->deAttributes & ATTR_DIRECTORY) == 0 || - memcmp(ep->deName, ".. ", 11) != 0) { - error = ENOTDIR; - break; - } - scn = getushort(ep->deStartCluster); - if (FAT32(pmp)) - scn |= getushort(ep->deHighClust) << 16; - - if (scn == source->de_StartCluster) { - error = EINVAL; - break; - } - if (scn == MSDOSFSROOT) - break; - if (FAT32(pmp) && scn == pmp->pm_rootdirblk) { - /* - * scn should be 0 in this case, - * but we silently ignore the error. - */ - break; - } - - vput(DETOV(dep)); - brelse(bp, 0); - bp = NULL; - /* NOTE: deget() clears dep on error */ - if ((error = deget(pmp, scn, 0, &dep)) != 0) - break; - } -out: - if (bp) - brelse(bp, 0); - if (error == ENOTDIR) - printf("doscheckpath(): .. not a directory?\n"); - if (dep != NULL) - vput(DETOV(dep)); - return (error); -} - -/* * Read in the disk block containing the directory entry (dirclu, dirofs) * and return the address of the buf header, and the address of the * directory entry within the block. @@ -462,82 +299,6 @@ readde(struct denode *dep, struct buf **bpp, struct direntry **epp) } /* - * Remove a directory entry. At this point the file represented by the - * directory entry to be removed is still full length until noone has it - * open. When the file no longer being used msdosfs_inactive() is called - * and will truncate the file to 0 length. When the vnode containing the - * denode is needed for some other purpose by VFS it will call - * msdosfs_reclaim() which will remove the denode from the denode cache. - */ -int -removede(struct denode *pdep, struct denode *dep) - /* pdep: directory where the entry is removed */ - /* dep: file to be removed */ -{ - int error; - struct direntry *ep; - struct buf *bp; - daddr_t bn; - int blsize; - struct msdosfsmount *pmp = pdep->de_pmp; - u_long offset = pdep->de_fndoffset; -#define async 0 - -#ifdef MSDOSFS_DEBUG - printf("removede(): filename %s, dep %p, offset %08lx\n", - dep->de_Name, dep, offset); -#endif - - if (--dep->de_refcnt == 0) { - } - offset += sizeof(struct direntry); - do { - offset -= sizeof(struct direntry); - error = pcbmap(pdep, de_cluster(pmp, offset), &bn, 0, &blsize); - if (error) - return error; - error = bread(pmp->pm_devvp, de_bn2kb(pmp, bn), blsize, - B_MODIFY, &bp); - if (error) { - return error; - } - ep = bptoep(pmp, bp, offset); - /* - * Check whether, if we came here the second time, i.e. - * when underflowing into the previous block, the last - * entry in this block is a longfilename entry, too. - */ - if (ep->deAttributes != ATTR_WIN95 - && offset != pdep->de_fndoffset) { - brelse(bp, 0); - break; - } - offset += sizeof(struct direntry); - while (1) { - /* - * We are a bit agressive here in that we delete any Win95 - * entries preceding this entry, not just the ones we "own". - * Since these presumably aren't valid anyway, - * there should be no harm. - */ - offset -= sizeof(struct direntry); - ep--->deName[0] = SLOT_DELETED; - if ((pmp->pm_flags & MSDOSFSMNT_NOWIN95) - || !(offset & pmp->pm_crbomask) - || ep->deAttributes != ATTR_WIN95) - break; - } - if (async) - bdwrite(bp); - else if ((error = bwrite(bp)) != 0) - return error; - } while (!(pmp->pm_flags & MSDOSFSMNT_NOWIN95) - && !(offset & pmp->pm_crbomask) - && offset); - return 0; -} - -/* * Create a unique DOS name in dvp */ int @@ -597,56 +358,3 @@ uniqdosname(struct denode *dep, struct componentname *cnp, u_char *cp) } } } - -/* - * Find any Win'95 long filename entry in directory dep - */ -int -findwin95(struct denode *dep) -{ - struct msdosfsmount *pmp = dep->de_pmp; - struct direntry *dentp; - int blsize, win95; - u_long cn; - daddr_t bn; - struct buf *bp; - - win95 = 1; - /* - * Read through the directory looking for Win'95 entries - * XXX Note: Error currently handled just as EOF - */ - for (cn = 0;; cn++) { - if (pcbmap(dep, cn, &bn, 0, &blsize)) - return win95; - if (bread(pmp->pm_devvp, de_bn2kb(pmp, bn), blsize, - 0, &bp)) { - return win95; - } - for (dentp = (struct direntry *)bp->b_data; - (char *)dentp < (char *)bp->b_data + blsize; - dentp++) { - if (dentp->deName[0] == SLOT_EMPTY) { - /* - * Last used entry and not found - */ - brelse(bp, 0); - return win95; - } - if (dentp->deName[0] == SLOT_DELETED) { - /* - * Ignore deleted files - * Note: might be an indication of Win'95 - * anyway XXX - */ - continue; - } - if (dentp->deAttributes == ATTR_WIN95) { - brelse(bp, 0); - return 1; - } - win95 = 0; - } - brelse(bp, 0); - } -} diff --git a/usr.sbin/makefs/ufs/ffs/ffs_extern.h b/usr.sbin/makefs/ufs/ffs/ffs_extern.h index db52e9e658d..6437a54cfaf 100644 --- a/usr.sbin/makefs/ufs/ffs/ffs_extern.h +++ b/usr.sbin/makefs/ufs/ffs/ffs_extern.h @@ -86,9 +86,7 @@ void ffs_csumtotal_swap(struct csum_total *, struct csum_total *); void ffs_cg_swap(struct cg *, struct cg *, struct fs *); /* ffs_subr.c */ -void ffs_fragacct(struct fs *, int, int32_t[], int, int); int ffs_isblock(struct fs *, u_char *, int32_t); -int ffs_isfreeblock(struct fs *, u_char *, int32_t); void ffs_clrblock(struct fs *, u_char *, int32_t); void ffs_setblock(struct fs *, u_char *, int32_t); void ffs_itimes(struct inode *, const struct timespec *, diff --git a/usr.sbin/makefs/ufs/ffs/ffs_subr.c b/usr.sbin/makefs/ufs/ffs/ffs_subr.c index 2fe62a0ae97..464ae41c586 100644 --- a/usr.sbin/makefs/ufs/ffs/ffs_subr.c +++ b/usr.sbin/makefs/ufs/ffs/ffs_subr.c @@ -47,40 +47,6 @@ void panic(const char *, ...) /* - * Update the frsum fields to reflect addition or deletion - * of some frags. - */ -void -ffs_fragacct(struct fs *fs, int fragmap, int32_t fraglist[], int cnt, - int needswap) -{ - int inblk; - int field, subfield; - int siz, pos; - - inblk = (int)(fragtbl[fs->fs_frag][fragmap]) << 1; - fragmap <<= 1; - for (siz = 1; siz < fs->fs_frag; siz++) { - if ((inblk & (1 << (siz + (fs->fs_frag & (NBBY - 1))))) == 0) - continue; - field = around[siz]; - subfield = inside[siz]; - for (pos = siz; pos <= fs->fs_frag; pos++) { - if ((fragmap & field) == subfield) { - fraglist[siz] = ufs_rw32( - ufs_rw32(fraglist[siz], needswap) + cnt, - needswap); - pos += siz; - field <<= siz; - subfield <<= siz; - } - field <<= 1; - subfield <<= 1; - } - } -} - -/* * block operations * * check if a block is available @@ -111,30 +77,6 @@ ffs_isblock(struct fs *fs, u_char *cp, int32_t h) } /* - * check if a block is completely allocated - * returns true if all the corresponding bits in the free map are 0 - * returns false if any corresponding bit in the free map is 1 - */ -int -ffs_isfreeblock(struct fs *fs, u_char *cp, int32_t h) -{ - - switch ((int)fs->fs_fragshift) { - case 3: - return (cp[h] == 0); - case 2: - return ((cp[h >> 1] & (0x0f << ((h & 0x1) << 2))) == 0); - case 1: - return ((cp[h >> 2] & (0x03 << ((h & 0x3) << 1))) == 0); - case 0: - return ((cp[h >> 3] & (0x01 << (h & 0x7))) == 0); - default: - panic("ffs_isfreeblock: unknown fs_fragshift %d", - (int)fs->fs_fragshift); - } -} - -/* * take a block out of the map */ void |