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