linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Viro <viro@math.psu.edu>
To: Peter Daum <gator@cs.tu-berlin.de>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] Re: fat problem in 2.4.2
Date: Thu, 1 Mar 2001 10:09:53 -0500 (EST)	[thread overview]
Message-ID: <Pine.GSO.4.21.0103010944001.11577-100000@weyl.math.psu.edu> (raw)
In-Reply-To: <Pine.LNX.4.30.0103011502050.23650-100000@swamp.bayern.net>



On Thu, 1 Mar 2001, Peter Daum wrote:

> In that case, why was it changed for FAT only? Ext2 will still
> happily enlarge a file by truncating it.

Basically, the program depends on behaviour that was never guaranteed to
be there.

> Staroffice (the binary-only version; the new "open source"
> version is not yet ready for real-world use) for example
> currently doesn't write to FAT filesystems anymore - which is
> pretty annoying for people who need it.

Staroffice is non-portable and badly written, film at 11...

BTW, _some_ subset is doable on FAT. You can't always do it (bloody
thing doesn't support holes), but you can try the following (warning -
untested patch):

diff -urN S2/fs/fat/inode.c S2-fat/fs/fat/inode.c
--- S2/fs/fat/inode.c	Fri Feb 16 22:52:07 2001
+++ S2-fat/fs/fat/inode.c	Thu Mar  1 10:02:45 2001
@@ -897,6 +897,36 @@
 	unlock_kernel();
 }
 
+int generic_cont_expand(struct inode *inode, loff_t size)
+{
+	struct address_space *mapping = inode->i_mapping;
+	struct page *page;
+	unsigned long index, offset, limit;
+	int err;
+
+	limit = current->rlim[RLIMIT_FSIZE].rlim_cur;
+	if (limit != RLIM_INFINITY) {
+		if (size > limit) {
+			send_sig(SIGXFSZ, current, 0);
+			size = limit;
+		}
+	}
+	offset = (size & (PAGE_CACHE_SIZE-1)); /* Within page */
+	index = size >> PAGE_CACHE_SHIFT;
+	err = -ENOMEM;
+	page = grab_cache_page(mapping, index);
+	if (!page)
+		goto out;
+	err = mapping->a_ops->prepare_write(NULL, page, offset, offset);
+	if (!err)
+		err = mapping->a_ops->commit_write(NULL, page, offset, offset);
+	UnlockPage(page);
+	page_cache_release(page);
+	if (err > 0)
+		err = 0;
+out:
+	return err;
+}
 
 int fat_notify_change(struct dentry * dentry, struct iattr * attr)
 {
@@ -904,11 +934,17 @@
 	struct inode *inode = dentry->d_inode;
-	int error;
+	int error = 0;
 
-	/* FAT cannot truncate to a longer file */
+	/*
+	 * On FAT truncate to a longer file may fail with -ENOSPC. No
+	 * way to report it from fat_truncate(), so...
+	 */
 	if (attr->ia_valid & ATTR_SIZE) {
 		if (attr->ia_size > inode->i_size)
-			return -EPERM;
+			error = generic_cont_expand(inode, attr->ia_size);
 	}
+
+	if (error)
+		return error;
 
 	error = inode_change_ok(inode, attr);
 	if (error)

That said, if your only problem is Staroffice... <shrug> I would rather
rm the crapware and forget about it, but YMMV.
							Cheers,
								Al


  reply	other threads:[~2001-03-01 15:10 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-02-25 20:08 fat problem in 2.4.2 James D Strandboge
2001-02-25 20:20 ` Alan Cox
2001-03-01 14:25   ` Peter Daum
2001-03-01 15:09     ` Alexander Viro [this message]
2001-03-02  0:21       ` [PATCH] " Albert D. Cahalan
2001-03-01 18:19     ` Alan Cox
2001-03-01 19:39       ` [CFT][PATCH] " Alexander Viro
2001-03-01 20:05         ` Linus Torvalds
2001-03-01 20:52           ` Chris Mason
2001-03-01 20:56         ` Roman Zippel
2001-03-01 21:07           ` Alexander Viro
2001-03-01 21:27             ` Roman Zippel
2001-03-02  7:45       ` ftruncate not extending files? bert hubert
2001-03-02  9:57         ` Malcolm Beattie
2001-03-02 10:56         ` Dmitry A. Fedorov
2001-03-02 14:15           ` Hugh Dickins
2001-03-03 19:32           ` Kai Henningsen
     [not found]         ` <mng==20010302095701.A4685@sable.ox.ac.uk>
2001-03-02 23:41           ` Jens-Uwe Mager

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.GSO.4.21.0103010944001.11577-100000@weyl.math.psu.edu \
    --to=viro@math.psu.edu \
    --cc=gator@cs.tu-berlin.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).