The maximum file size on MS-DOS filesystems is 4 GB - 1 byte, so

don't bother trying to write files bigger than this.  Just return
EFBIG to caller, rather than panic()ing later.

From OpenBSD.

This closes my PR kern/30864: "panic when copying files of >4GB on msdosfs"
This commit is contained in:
xtraeme 2005-08-29 23:22:05 +00:00
parent 3f34a9f7b6
commit 529eaccb6b
2 changed files with 10 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: denode.h,v 1.5 2005/07/23 12:18:41 yamt Exp $ */
/* $NetBSD: denode.h,v 1.6 2005/08/29 23:22:05 xtraeme Exp $ */
/*-
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@ -177,6 +177,9 @@ struct denode {
*/
#define WIN_MAXLEN 255
/* Maximum size of a file on a FAT filesystem */
#define MSDOSFS_FILESIZE_MAX 0xFFFFFFFFLL
/*
* Transfer directory entries between internal and external form.
* dep is a struct denode * (internal form),

View File

@ -1,4 +1,4 @@
/* $NetBSD: msdosfs_vnops.c,v 1.16 2005/08/19 12:24:54 christos Exp $ */
/* $NetBSD: msdosfs_vnops.c,v 1.17 2005/08/29 23:22:05 xtraeme Exp $ */
/*-
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.16 2005/08/19 12:24:54 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.17 2005/08/29 23:22:05 xtraeme Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -597,6 +597,10 @@ msdosfs_write(v)
if (uio->uio_resid == 0)
return (0);
/* Don't bother to try to write files larger than the fs limit */
if (uio->uio_offset + uio->uio_resid > MSDOSFS_FILESIZE_MAX)
return (EFBIG);
/*
* If they've exceeded their filesize limit, tell them about it.
*/