Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2)  * fs/sdcardfs/mmap.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  * Copyright (c) 2013 Samsung Electronics Co. Ltd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  *   Authors: Daeho Jeong, Woojoong Lee, Seunghwan Hyun,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  *               Sunghwan Yun, Sungjong Seo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  * This program has been developed as a stackable file system based on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9)  * the WrapFS which written by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)  * Copyright (c) 1998-2011 Erez Zadok
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)  * Copyright (c) 2009     Shrikar Archak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)  * Copyright (c) 2003-2011 Stony Brook University
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)  * Copyright (c) 2003-2011 The Research Foundation of SUNY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)  * This file is dual licensed.  It may be redistributed and/or modified
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)  * under the terms of the Apache 2.0 License OR version 2 of the GNU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)  * General Public License.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include "sdcardfs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) static int sdcardfs_fault(struct vm_fault *vmf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	struct file *file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	const struct vm_operations_struct *lower_vm_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	file = (struct file *)vmf->vma->vm_private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	lower_vm_ops = SDCARDFS_F(file)->lower_vm_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	BUG_ON(!lower_vm_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	err = lower_vm_ops->fault(vmf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) static void sdcardfs_vm_open(struct vm_area_struct *vma)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	struct file *file = (struct file *)vma->vm_private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	get_file(file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) static void sdcardfs_vm_close(struct vm_area_struct *vma)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	struct file *file = (struct file *)vma->vm_private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	fput(file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) static int sdcardfs_page_mkwrite(struct vm_fault *vmf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 	struct file *file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 	const struct vm_operations_struct *lower_vm_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 	file = (struct file *)vmf->vma->vm_private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	lower_vm_ops = SDCARDFS_F(file)->lower_vm_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 	BUG_ON(!lower_vm_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 	if (!lower_vm_ops->page_mkwrite)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 	err = lower_vm_ops->page_mkwrite(vmf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) static ssize_t sdcardfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 	 * This function should never be called directly.  We need it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 	 * to exist, to get past a check in open_check_o_direct(),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 	 * which is called from do_last().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) 	return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) const struct address_space_operations sdcardfs_aops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) 	.direct_IO	= sdcardfs_direct_IO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) const struct vm_operations_struct sdcardfs_vm_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) 	.fault		= sdcardfs_fault,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) 	.page_mkwrite	= sdcardfs_page_mkwrite,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) 	.open		= sdcardfs_vm_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) 	.close		= sdcardfs_vm_close,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) };