/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/sysmacros.h>
/*
* Reserve swap space for the size of the file.
* Called before growing a file (i.e. ftruncate, write)
* Returns 0 on success.
*/
int
int pagecreate) /* call anon_resv if set */
{
/*
* pagecreate is set only if we actually need to call anon_resv
* to reserve an additional page of anonymous memory.
* Since anon_resv always reserves a page at a time,
* it should only get called when we know we're growing the
* file into a new page or filling a hole.
*
* Deny if trying to reserve more than tmpfs can allocate
*/
return (1);
}
/*
* update statistics
*/
if (pagecreate) {
}
return (0);
}
/*
* tmp_unresv - called when truncating a file
* Only called if we're freeing at least pagesize bytes
* because anon_unresv does a btopr(delta)
*/
static void
{
}
/*
* Grow the anon pointer array to cover 'newsize' bytes plus slack.
*/
void
{
return;
return;
}
}
/*
* Initialize a tmpnode and add it to file list under mount point.
*/
void
{
t->tn_mask = 0;
t->tn_nlink = 1;
t->tn_size = 0;
} else {
}
t->tn_blksize = PAGESIZE;
t->tn_nblocks = 0;
gethrestime(&now);
t->tn_seq = 0;
/*
* Increment the pseudo generation number for this tmpnode.
* Since tmpnodes are allocated and freed, there really is no
* particular generation number for a new tmpnode. Just fake it
* by using a counter in each file system.
*/
/*
* Add new tmpnode to end of linked list of tmpnodes for this tmpfs
* Root directory is handled specially in tmp_mount.
*/
}
}
/*
* tmpnode_trunc - set length of tmpnode and deal with resources
*/
int
{
int error = 0;
/* Required by POSIX */
goto stamp_out;
}
case VREG:
/* Growing the file */
/*
* Grow the size of the anon array to the new size
* Reserve the space for the growth here.
* We do it this way for now because this is how
* tmpfs used to do it, and this way the reserved
* space is alway equal to the file size.
* Alternatively, we could wait to reserve space 'til
* someone tries to store into one of the newly
* trunc'ed up pages. This would give us behavior
* identical to ufs; i.e., you could fail a
* fault on storing into a holey region of a file
* if there is no space in the filesystem to fill
* the hole at that time.
*/
/*
* tmp_resv calls anon_resv only if we're extending
* the file into a new page
*/
goto out;
}
break;
}
/* Free anon pages if shrinking file over page boundary. */
}
/*
* Update the file size now to reflect the pages we just
* blew away as we're about to drop the
* contents lock to zero the partial page (which could
* re-enter tmpfs via getpage and try to reacquire the lock)
* Once we drop the lock, faulters can fill in holes in
* the file and if we haven't updated the size they
* may fill in holes that are beyond EOF, which will then
* never get cleared.
*/
/* Zero new size of file to page boundary. */
}
if (newsize == 0) {
/* Delete anon array for tmpnode */
}
break;
case VLNK:
/*
* Don't do anything here
* tmp_inactive frees the memory
*/
if (newsize != 0)
goto out;
case VDIR:
/*
* Remove all the directory entries under this directory.
*/
if (newsize != 0) {
goto out;
}
break;
default:
goto out;
}
gethrestime(&now);
out:
/*
* tmpnode_trunc() cannot fail when newsize == 0.
*/
return (error);
}