[BACK]Return to tmpfs_specops.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / fs / tmpfs

File: [cvs.NetBSD.org] / src / sys / fs / tmpfs / tmpfs_specops.c (download)

Revision 1.12, Fri Jul 25 08:20:52 2014 UTC (6 years, 8 months ago) by dholland
Branch: MAIN
CVS Tags: tls-maxphys-base-20171202, tls-maxphys-base, tls-earlyentropy-base, prg-localcount2-base3, prg-localcount2-base2, prg-localcount2-base1, prg-localcount2-base, prg-localcount2, phil-wifi-base, phil-wifi-20200421, phil-wifi-20200411, phil-wifi-20200406, phil-wifi-20191119, phil-wifi-20190609, phil-wifi, pgoyette-localcount-base, pgoyette-localcount-20170426, pgoyette-localcount-20170320, pgoyette-localcount-20170107, pgoyette-localcount-20161104, pgoyette-localcount-20160806, pgoyette-localcount-20160726, pgoyette-localcount, pgoyette-compat-merge-20190127, pgoyette-compat-base, pgoyette-compat-20190127, pgoyette-compat-20190118, pgoyette-compat-1226, pgoyette-compat-1126, pgoyette-compat-1020, pgoyette-compat-0930, pgoyette-compat-0906, pgoyette-compat-0728, pgoyette-compat-0625, pgoyette-compat-0521, pgoyette-compat-0502, pgoyette-compat-0422, pgoyette-compat-0415, pgoyette-compat-0407, pgoyette-compat-0330, pgoyette-compat-0322, pgoyette-compat-0315, pgoyette-compat, perseant-stdc-iso10646-base, perseant-stdc-iso10646, nick-nhusb-base-20170825, nick-nhusb-base-20170204, nick-nhusb-base-20161204, nick-nhusb-base-20161004, nick-nhusb-base-20160907, nick-nhusb-base-20160529, nick-nhusb-base-20160422, nick-nhusb-base-20160319, nick-nhusb-base-20151226, nick-nhusb-base-20150921, nick-nhusb-base-20150606, nick-nhusb-base-20150406, nick-nhusb-base, nick-nhusb, netbsd-9-base, netbsd-9-1-RELEASE, netbsd-9-0-RELEASE, netbsd-9-0-RC2, netbsd-9-0-RC1, netbsd-9, netbsd-8-base, netbsd-8-2-RELEASE, netbsd-8-1-RELEASE, netbsd-8-1-RC1, netbsd-8-0-RELEASE, netbsd-8-0-RC2, netbsd-8-0-RC1, netbsd-8, netbsd-7-nhusb-base-20170116, netbsd-7-nhusb-base, netbsd-7-nhusb, netbsd-7-base, netbsd-7-2-RELEASE, netbsd-7-1-RELEASE, netbsd-7-1-RC2, netbsd-7-1-RC1, netbsd-7-1-2-RELEASE, netbsd-7-1-1-RELEASE, netbsd-7-1, netbsd-7-0-RELEASE, netbsd-7-0-RC3, netbsd-7-0-RC2, netbsd-7-0-RC1, netbsd-7-0-2-RELEASE, netbsd-7-0-1-RELEASE, netbsd-7-0, netbsd-7, matt-nb8-mediatek-base, matt-nb8-mediatek, localcount-20160914, jdolecek-ncq-base, jdolecek-ncq, isaki-audio2-base, isaki-audio2, is-mlppp-base, is-mlppp, bouyer-xenpvh-base2, bouyer-xenpvh-base1, bouyer-xenpvh-base, bouyer-xenpvh, bouyer-socketcan-base1, bouyer-socketcan-base, bouyer-socketcan, ad-namecache-base3, ad-namecache-base2, ad-namecache-base1, ad-namecache-base, ad-namecache
Changes since 1.11: +4 -2 lines

Add VOP_FALLOCATE and VOP_FDISCARD to every vnode ops table I can
find.

The filesystem ones all call genfs_eopnotsupp - right now I am only
implementing the plumbing and we can implement fallocate and/or
fdiscard for files later.

The device ones call spec_fallocate (which is also genfs_eopnotsupp)
and spec_fdiscard, which dispatches to the device-level op.

The fifo ones all call vn_fifo_bypass, which also ends up being
EOPNOTSUPP.

/*	$NetBSD: tmpfs_specops.c,v 1.12 2014/07/25 08:20:52 dholland Exp $	*/

/*
 * Copyright (c) 2005 The NetBSD Foundation, Inc.
 * All rights reserved.
 *
 * This code is derived from software contributed to The NetBSD Foundation
 * by Julio M. Merino Vidal, developed as part of Google's Summer of Code
 * 2005 program.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

/*
 * tmpfs vnode interface for special devices.
 */

#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: tmpfs_specops.c,v 1.12 2014/07/25 08:20:52 dholland Exp $");

#include <sys/param.h>
#include <sys/vnode.h>

#include <fs/tmpfs/tmpfs.h>
#include <fs/tmpfs/tmpfs_specops.h>

/*
 * vnode operations vector used for special devices stored in a tmpfs
 * file system.
 */

int (**tmpfs_specop_p)(void *);

const struct vnodeopv_entry_desc tmpfs_specop_entries[] = {
	{ &vop_default_desc,		vn_default_error },
	{ &vop_lookup_desc,		tmpfs_spec_lookup },
	{ &vop_create_desc,		tmpfs_spec_create },
	{ &vop_mknod_desc,		tmpfs_spec_mknod },
	{ &vop_open_desc,		tmpfs_spec_open },
	{ &vop_close_desc,		tmpfs_spec_close },
	{ &vop_access_desc,		tmpfs_spec_access },
	{ &vop_getattr_desc,		tmpfs_spec_getattr },
	{ &vop_setattr_desc,		tmpfs_spec_setattr },
	{ &vop_read_desc,		tmpfs_spec_read },
	{ &vop_write_desc,		tmpfs_spec_write },
	{ &vop_fallocate_desc,		spec_fallocate },
	{ &vop_fdiscard_desc,		spec_fdiscard },
	{ &vop_ioctl_desc,		tmpfs_spec_ioctl },
	{ &vop_fcntl_desc,		tmpfs_spec_fcntl },
	{ &vop_poll_desc,		tmpfs_spec_poll },
	{ &vop_kqfilter_desc,		tmpfs_spec_kqfilter },
	{ &vop_revoke_desc,		tmpfs_spec_revoke },
	{ &vop_mmap_desc,		tmpfs_spec_mmap },
	{ &vop_fsync_desc,		tmpfs_spec_fsync },
	{ &vop_seek_desc,		tmpfs_spec_seek },
	{ &vop_remove_desc,		tmpfs_spec_remove },
	{ &vop_link_desc,		tmpfs_spec_link },
	{ &vop_rename_desc,		tmpfs_spec_rename },
	{ &vop_mkdir_desc,		tmpfs_spec_mkdir },
	{ &vop_rmdir_desc,		tmpfs_spec_rmdir },
	{ &vop_symlink_desc,		tmpfs_spec_symlink },
	{ &vop_readdir_desc,		tmpfs_spec_readdir },
	{ &vop_readlink_desc,		tmpfs_spec_readlink },
	{ &vop_abortop_desc,		tmpfs_spec_abortop },
	{ &vop_inactive_desc,		tmpfs_spec_inactive },
	{ &vop_reclaim_desc,		tmpfs_spec_reclaim },
	{ &vop_lock_desc,		tmpfs_spec_lock },
	{ &vop_unlock_desc,		tmpfs_spec_unlock },
	{ &vop_bmap_desc,		tmpfs_spec_bmap },
	{ &vop_strategy_desc,		tmpfs_spec_strategy },
	{ &vop_print_desc,		tmpfs_spec_print },
	{ &vop_pathconf_desc,		tmpfs_spec_pathconf },
	{ &vop_islocked_desc,		tmpfs_spec_islocked },
	{ &vop_advlock_desc,		tmpfs_spec_advlock },
	{ &vop_bwrite_desc,		tmpfs_spec_bwrite },
	{ &vop_getpages_desc,		tmpfs_spec_getpages },
	{ &vop_putpages_desc,		tmpfs_spec_putpages },
	{ NULL, NULL }
};

const struct vnodeopv_desc tmpfs_specop_opv_desc = {
	&tmpfs_specop_p, tmpfs_specop_entries
};

int
tmpfs_spec_close(void *v)
{
	struct vop_close_args /* {
		struct vnode	*a_vp;
		int		a_fflag;
		kauth_cred_t	a_cred;
	} */ *ap __unused = v;

	return VOCALL(spec_vnodeop_p, VOFFSET(vop_close), v);
}

int
tmpfs_spec_read(void *v)
{
	struct vop_read_args /* {
		struct vnode *a_vp;
		struct uio *a_uio;
		int a_ioflag;
		kauth_cred_t a_cred;
	} */ *ap = v;
	vnode_t *vp = ap->a_vp;

	tmpfs_update(vp, TMPFS_UPDATE_ATIME);
	return VOCALL(spec_vnodeop_p, VOFFSET(vop_read), v);
}

int
tmpfs_spec_write(void *v)
{
	struct vop_write_args /* {
		struct vnode *a_vp;
		struct uio *a_uio;
		int a_ioflag;
		kauth_cred_t a_cred;
	} */ *ap = v;
	vnode_t *vp = ap->a_vp;

	tmpfs_update(vp, TMPFS_UPDATE_MTIME);
	return VOCALL(spec_vnodeop_p, VOFFSET(vop_write), v);
}