From: jzp0409 <jzp0409@163.com>
To: miklos@szeredi.hu
Cc: linux-fsdevel@vger.kernel.org, "edison.jiang" <jiangzhipeng@yulong.com>
Subject: [PATCH] fuse: set limit size
Date: Tue, 15 Jun 2021 14:41:55 +0800 [thread overview]
Message-ID: <20210615064155.911-1-jzp0409@163.com> (raw)
From: "edison.jiang" <jiangzhipeng@yulong.com>
Android-R /sdcard mount FUSE filesystem type,
use "dd" command to filli up /sdcard dir,
Android will not boot normal,
becase this system need at least 128M userspace.
Test: open adb port,
adb shell "dd if=dev/zero of=sdcard/ae bs=1024000 count=xxx"
Result: if not limit size,Android system can not boot normal.
Signed-off-by: edison.jiang <jiangzhipeng@yulong.com>
---
fs/fuse/inode.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index b0e18b4..f4e54505 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -477,6 +477,21 @@ static void convert_fuse_statfs(struct kstatfs *stbuf, struct fuse_kstatfs *attr
stbuf->f_files = attr->files;
stbuf->f_ffree = attr->ffree;
stbuf->f_namelen = attr->namelen;
+#ifdef LIMIT_SDCARD_SIZE
+ u32 data_free_size_th = 128*1024*1024;
+
+ stbuf->f_blocks -= (u32)data_free_size_th/attr->bsize;
+
+ if (stbuf->f_bfree < ((u32)data_free_size_th/attr->bsize))
+ stbuf->f_bfree = 0;
+ else
+ stbuf->f_bfree -= (u32)data_free_size_th/attr->bsize;
+
+ if (stbuf->f_bavail < ((u32)data_free_size_th/attr->bsize))
+ stbuf->f_bavail = 0;
+ else
+ stbuf->f_bavail -= (u32)data_free_size_th/attr->bsize;
+#endif
/* fsid is left zero */
}
--
1.9.1
next reply other threads:[~2021-06-15 6:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-15 6:41 jzp0409 [this message]
2021-06-18 7:10 ` [PATCH] fuse: set limit size Miklos Szeredi
[not found] ` <3a47eade.6096.17a1e87d2f9.Coremail.jzp0409@163.com>
2021-06-18 9:55 ` Miklos Szeredi
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=20210615064155.911-1-jzp0409@163.com \
--to=jzp0409@163.com \
--cc=jiangzhipeng@yulong.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=miklos@szeredi.hu \
/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).