Esempio n. 1
0
afs_omount(struct mount *mp, char *path, caddr_t data, struct nameidata *ndp,
	THREAD_OR_PROC)
#endif
{
    /* ndp contains the mounted-from device.  Just ignore it.
     * we also don't care about our proc struct. */
    size_t size;

    if (mp->mnt_flag & MNT_UPDATE)
	return EINVAL;

    AFS_GLOCK();
    AFS_STATCNT(afs_mount);

    if (afs_globalVFS) {	/* Don't allow remounts. */
	AFS_GUNLOCK();
	return EBUSY;
    }

    afs_globalVFS = mp;
    mp->vfs_bsize = 8192;
    vfs_getnewfsid(mp);
#ifdef AFS_FBSD70_ENV /* XXX 70? */
    MNT_ILOCK(mp);
    mp->mnt_flag &= ~MNT_LOCAL;
    mp->mnt_kern_flag |= MNTK_MPSAFE; /* solid steel */
#endif
    mp->mnt_stat.f_iosize = 8192;

    if (path != NULL)
	copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size);
    else
	bcopy("/afs", mp->mnt_stat.f_mntonname, size = 4);
    memset(mp->mnt_stat.f_mntonname + size, 0, MNAMELEN - size);
    memset(mp->mnt_stat.f_mntfromname, 0, MNAMELEN);
    strcpy(mp->mnt_stat.f_mntfromname, "AFS");
    /* null terminated string "AFS" will fit, just leave it be. */
    strcpy(mp->mnt_stat.f_fstypename, "afs");
#ifdef AFS_FBSD70_ENV
    MNT_IUNLOCK(mp);
#endif
    AFS_GUNLOCK();
    afs_statfs(mp, &mp->mnt_stat, p);

    return 0;
}
Esempio n. 2
0
void
VSetPartitionDiskUsage_r(register struct DiskPartition64 *dp)
{
    int bsize, code;
    afs_int64 totalblks, free, used, availblks;
    int reserved;
#ifdef afs_statvfs
    struct afs_statvfs statbuf;
#else
    struct afs_statfs statbuf;
#endif

    if (dp->flags & PART_DONTUPDATE)
	return;
    /* Note:  we don't bother syncing because it's only an estimate, update
     * is syncing every 30 seconds anyway, we only have to keep the disk
     * approximately 10% from full--you just can't get the stuff in from
     * the net fast enough to worry */
#ifdef afs_statvfs
    code = afs_statvfs(dp->name, &statbuf);
#else
    code = afs_statfs(dp->name, &statbuf);
#endif
    if (code < 0) {
	Log("statfs of %s failed in VSetPartitionDiskUsage (errno = %d)\n",
	    dp->name, errno);
	return;
    }
    if (statbuf.f_blocks == -1) {	/* Undefined; skip stats.. */
	Log("statfs of %s failed in VSetPartitionDiskUsage\n", dp->name);
	return;
    }
    totalblks = statbuf.f_blocks;
    free = statbuf.f_bfree;
    reserved = free - statbuf.f_bavail;
#ifdef afs_statvfs
    bsize = statbuf.f_frsize;
#else
    bsize = statbuf.f_bsize;
#endif
    availblks = totalblks - reserved;
    dp->f_files = statbuf.f_files;	/* max # of files in partition */

    /* Now free and totalblks are in fragment units, but we want them in
     * 1K units.
     */
    if (bsize >= 1024) {
	free *= (bsize / 1024);
	totalblks *= (bsize / 1024);
	availblks *= (bsize / 1024);
	reserved *= (bsize / 1024);
    } else {
	free /= (1024 / bsize);
	totalblks /= (1024 / bsize);
	availblks /= (1024 / bsize);
	reserved /= (1024 / bsize);
    }
    /* now compute remaining figures */
    used = totalblks - free;

    dp->minFree = reserved;	/* only used in VPrintDiskStats_r */
    dp->totalUsable = availblks;
    dp->free = availblks - used;	/* this is exactly f_bavail */
}
Esempio n. 3
0
afs_omount(struct mount *mp, char *path, caddr_t data, struct nameidata *ndp,
	struct thread *p)
#endif
{
    /* ndp contains the mounted-from device.  Just ignore it.
     * we also don't care about our thread struct. */
    size_t size;

    if (mp->mnt_flag & MNT_UPDATE)
	return EINVAL;

    AFS_GLOCK();
    AFS_STATCNT(afs_mount);

    if (afs_globalVFS) {	/* Don't allow remounts. */
	AFS_GUNLOCK();
	return EBUSY;
    }

    afs_globalVFS = mp;
    mp->vfs_bsize = 8192;
    vfs_getnewfsid(mp);
    /*
     * This is kind of ugly, as the interlock has grown to encompass
     * more fields over time and there's not a good way to group the
     * code without duplication.
     */
#ifdef AFS_FBSD62_ENV
    MNT_ILOCK(mp);
#endif
    mp->mnt_flag &= ~MNT_LOCAL;
#if defined(AFS_FBSD61_ENV) && !defined(AFS_FBSD62_ENV)
    MNT_ILOCK(mp);
#endif
#if __FreeBSD_version < 1000021
    mp->mnt_kern_flag |= MNTK_MPSAFE; /* solid steel */
#endif
#ifndef AFS_FBSD61_ENV
    MNT_ILOCK(mp);
#endif
    /*
     * XXX mnt_stat "is considered stable as long as a ref is held".
     * We should check that we hold the only ref.
     */
    mp->mnt_stat.f_iosize = 8192;

    if (path != NULL)
	copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size);
    else
	bcopy("/afs", mp->mnt_stat.f_mntonname, size = 4);
    memset(mp->mnt_stat.f_mntonname + size, 0, MNAMELEN - size);
    memset(mp->mnt_stat.f_mntfromname, 0, MNAMELEN);
    strcpy(mp->mnt_stat.f_mntfromname, "AFS");
    /* null terminated string "AFS" will fit, just leave it be. */
    strcpy(mp->mnt_stat.f_fstypename, "afs");
    MNT_IUNLOCK(mp);
    AFS_GUNLOCK();
#ifdef AFS_FBSD80_ENV
    afs_statfs(mp, &mp->mnt_stat);
#else
    afs_statfs(mp, &mp->mnt_stat, p);
#endif

    return 0;
}