FreeBSD/sys/fs/msdosfs/msdosfs_denode.c
/*
 * Extend the file described by dep to length specified by length.
 */
Extend the file described by dep to length specified by length.
Extend the file described by dep to length specified by length .
int
deextend(struct denode *dep, u_long length, struct ucred *cred)
{
	struct msdosfsmount *pmp = dep->de_pmp;
	u_long count;
	int error;
	if ((DETOV(dep)->v_vflag & VV_ROOT) && !FAT32(pmp))
		return (EINVAL);
	if (dep->de_Attributes & ATTR_DIRECTORY)
		return (EISDIR);
	if (length <= dep->de_FileSize)
		panic("deextend: file too large");
	count = de_clcount(pmp, length) - de_clcount(pmp, dep->de_FileSize);
	if (count > 0) {
		if (count > pmp->pm_freeclustercount)
			return (ENOSPC);
		error = extendfile(dep, count, NULL, NULL, DE_CLEAR);
		if (error) {
			(void) detrunc(dep, dep->de_FileSize, 0, cred);
			return (error);
		}
	}
	dep->de_FileSize = length;
	dep->de_flag |= DE_UPDATE | DE_MODIFIED;
	return (deupdat(dep, !DOINGASYNC(DETOV(dep))));
}
int deextend ( struct denode * dep , u_long length , struct ucred * cred ) { struct msdosfsmount * pmp = dep -> de_pmp ; u_long count ; int error ; if ( ( DETOV ( dep ) -> v_vflag & VV_ROOT ) && ! FAT32 ( pmp ) ) return ( EINVAL ) ; if ( dep -> de_Attributes & ATTR_DIRECTORY ) return ( EISDIR ) ; if ( length <= dep -> de_FileSize ) panic ( " " ) ; count = de_clcount ( pmp , length ) - de_clcount ( pmp , dep -> de_FileSize ) ; if ( count > 0 ) { if ( count > pmp -> pm_freeclustercount ) return ( ENOSPC ) ; error = extendfile ( dep , count , NULL , NULL , DE_CLEAR ) ; if ( error ) { ( void ) detrunc ( dep , dep -> de_FileSize , 0 , cred ) ; return ( error ) ; } } dep -> de_FileSize = length ; dep -> de_flag |= DE_UPDATE | DE_MODIFIED ; return ( deupdat ( dep , ! DOINGASYNC ( DETOV ( dep ) ) ) ) ; }
Extend the file described by dep to length specified by length.
Extend the file described by dep to length specified by length .
/*
	 * The root of a DOS filesystem cannot be extended.
	 */ /*
	 * Directories cannot be extended.
	 */ /*
	 * Compute the number of clusters to allocate.
	 */ /* truncate the added clusters away again */