Deleted Added
full compact
tmpfs_vnops.c (341074) tmpfs_vnops.c (346286)
1/* $NetBSD: tmpfs_vnops.c,v 1.39 2007/07/23 15:41:01 jmmv Exp $ */
2
3/*-
4 * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Julio M. Merino Vidal, developed as part of Google's Summer of Code

--- 20 unchanged lines hidden (view full) ---

29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33/*
34 * tmpfs vnode interface.
35 */
36#include <sys/cdefs.h>
1/* $NetBSD: tmpfs_vnops.c,v 1.39 2007/07/23 15:41:01 jmmv Exp $ */
2
3/*-
4 * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Julio M. Merino Vidal, developed as part of Google's Summer of Code

--- 20 unchanged lines hidden (view full) ---

29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33/*
34 * tmpfs vnode interface.
35 */
36#include <sys/cdefs.h>
37__FBSDID("$FreeBSD: stable/11/sys/fs/tmpfs/tmpfs_vnops.c 341074 2018-11-27 16:51:18Z markj $");
37__FBSDID("$FreeBSD: stable/11/sys/fs/tmpfs/tmpfs_vnops.c 346286 2019-04-16 17:43:14Z kib $");
38
39#include <sys/param.h>
40#include <sys/fcntl.h>
41#include <sys/lockf.h>
42#include <sys/lock.h>
43#include <sys/namei.h>
44#include <sys/priv.h>
45#include <sys/proc.h>

--- 424 unchanged lines hidden (view full) ---

470
471 vp = v->a_vp;
472 if (vp->v_type != VREG)
473 return (EISDIR);
474 uio = v->a_uio;
475 if (uio->uio_offset < 0)
476 return (EINVAL);
477 node = VP_TO_TMPFS_NODE(vp);
38
39#include <sys/param.h>
40#include <sys/fcntl.h>
41#include <sys/lockf.h>
42#include <sys/lock.h>
43#include <sys/namei.h>
44#include <sys/priv.h>
45#include <sys/proc.h>

--- 424 unchanged lines hidden (view full) ---

470
471 vp = v->a_vp;
472 if (vp->v_type != VREG)
473 return (EISDIR);
474 uio = v->a_uio;
475 if (uio->uio_offset < 0)
476 return (EINVAL);
477 node = VP_TO_TMPFS_NODE(vp);
478 tmpfs_set_status(node, TMPFS_NODE_ACCESSED);
478 tmpfs_set_status(VFS_TO_TMPFS(vp->v_mount), node, TMPFS_NODE_ACCESSED);
479 return (uiomove_object(node->tn_reg.tn_aobj, node->tn_size, uio));
480}
481
482static int
483tmpfs_write(struct vop_write_args *v)
484{
485 struct vnode *vp;
486 struct uio *uio;

--- 690 unchanged lines hidden (view full) ---

1177#else
1178 vap->va_type = VLNK;
1179#endif
1180
1181 return tmpfs_alloc_file(dvp, vpp, vap, cnp, target);
1182}
1183
1184static int
479 return (uiomove_object(node->tn_reg.tn_aobj, node->tn_size, uio));
480}
481
482static int
483tmpfs_write(struct vop_write_args *v)
484{
485 struct vnode *vp;
486 struct uio *uio;

--- 690 unchanged lines hidden (view full) ---

1177#else
1178 vap->va_type = VLNK;
1179#endif
1180
1181 return tmpfs_alloc_file(dvp, vpp, vap, cnp, target);
1182}
1183
1184static int
1185tmpfs_readdir(struct vop_readdir_args *v)
1185tmpfs_readdir(struct vop_readdir_args *va)
1186{
1186{
1187 struct vnode *vp = v->a_vp;
1188 struct uio *uio = v->a_uio;
1189 int *eofflag = v->a_eofflag;
1190 u_long **cookies = v->a_cookies;
1191 int *ncookies = v->a_ncookies;
1192
1193 int error;
1194 ssize_t startresid;
1195 int maxcookies;
1187 struct vnode *vp;
1188 struct uio *uio;
1189 struct tmpfs_mount *tm;
1196 struct tmpfs_node *node;
1190 struct tmpfs_node *node;
1191 u_long **cookies;
1192 int *eofflag, *ncookies;
1193 ssize_t startresid;
1194 int error, maxcookies;
1197
1195
1196 vp = va->a_vp;
1197 uio = va->a_uio;
1198 eofflag = va->a_eofflag;
1199 cookies = va->a_cookies;
1200 ncookies = va->a_ncookies;
1201
1198 /* This operation only makes sense on directory nodes. */
1199 if (vp->v_type != VDIR)
1200 return ENOTDIR;
1201
1202 maxcookies = 0;
1203 node = VP_TO_TMPFS_DIR(vp);
1202 /* This operation only makes sense on directory nodes. */
1203 if (vp->v_type != VDIR)
1204 return ENOTDIR;
1205
1206 maxcookies = 0;
1207 node = VP_TO_TMPFS_DIR(vp);
1208 tm = VFS_TO_TMPFS(vp->v_mount);
1204
1205 startresid = uio->uio_resid;
1206
1207 /* Allocate cookies for NFS and compat modules. */
1208 if (cookies != NULL && ncookies != NULL) {
1209 maxcookies = howmany(node->tn_size,
1210 sizeof(struct tmpfs_dirent)) + 2;
1211 *cookies = malloc(maxcookies * sizeof(**cookies), M_TEMP,
1212 M_WAITOK);
1213 *ncookies = 0;
1214 }
1215
1216 if (cookies == NULL)
1209
1210 startresid = uio->uio_resid;
1211
1212 /* Allocate cookies for NFS and compat modules. */
1213 if (cookies != NULL && ncookies != NULL) {
1214 maxcookies = howmany(node->tn_size,
1215 sizeof(struct tmpfs_dirent)) + 2;
1216 *cookies = malloc(maxcookies * sizeof(**cookies), M_TEMP,
1217 M_WAITOK);
1218 *ncookies = 0;
1219 }
1220
1221 if (cookies == NULL)
1217 error = tmpfs_dir_getdents(node, uio, 0, NULL, NULL);
1222 error = tmpfs_dir_getdents(tm, node, uio, 0, NULL, NULL);
1218 else
1223 else
1219 error = tmpfs_dir_getdents(node, uio, maxcookies, *cookies,
1224 error = tmpfs_dir_getdents(tm, node, uio, maxcookies, *cookies,
1220 ncookies);
1221
1222 /* Buffer was filled without hitting EOF. */
1223 if (error == EJUSTRETURN)
1224 error = (uio->uio_resid != startresid) ? 0 : EINVAL;
1225
1226 if (error != 0 && cookies != NULL && ncookies != NULL) {
1227 free(*cookies, M_TEMP);

--- 19 unchanged lines hidden (view full) ---

1247
1248 MPASS(uio->uio_offset == 0);
1249 MPASS(vp->v_type == VLNK);
1250
1251 node = VP_TO_TMPFS_NODE(vp);
1252
1253 error = uiomove(node->tn_link, MIN(node->tn_size, uio->uio_resid),
1254 uio);
1225 ncookies);
1226
1227 /* Buffer was filled without hitting EOF. */
1228 if (error == EJUSTRETURN)
1229 error = (uio->uio_resid != startresid) ? 0 : EINVAL;
1230
1231 if (error != 0 && cookies != NULL && ncookies != NULL) {
1232 free(*cookies, M_TEMP);

--- 19 unchanged lines hidden (view full) ---

1252
1253 MPASS(uio->uio_offset == 0);
1254 MPASS(vp->v_type == VLNK);
1255
1256 node = VP_TO_TMPFS_NODE(vp);
1257
1258 error = uiomove(node->tn_link, MIN(node->tn_size, uio->uio_resid),
1259 uio);
1255 tmpfs_set_status(node, TMPFS_NODE_ACCESSED);
1260 tmpfs_set_status(VFS_TO_TMPFS(vp->v_mount), node, TMPFS_NODE_ACCESSED);
1256
1257 return (error);
1258}
1259
1260static int
1261tmpfs_inactive(struct vop_inactive_args *v)
1262{
1263 struct vnode *vp;

--- 328 unchanged lines hidden ---
1261
1262 return (error);
1263}
1264
1265static int
1266tmpfs_inactive(struct vop_inactive_args *v)
1267{
1268 struct vnode *vp;

--- 328 unchanged lines hidden ---