// SPDX-License-Identifier: GPL-2.0-only/* * Copyright (C) 2011 Novell Inc. * Copyright (C) 2016 Red Hat, Inc. */#include<linux/fs.h>#include<linux/mount.h>#include<linux/slab.h>#include<linux/cred.h>#include<linux/xattr.h>#include<linux/exportfs.h>#include<linux/file.h>#include<linux/fileattr.h>#include<linux/uuid.h>#include<linux/namei.h>#include<linux/ratelimit.h>#include"overlayfs.h"intovl_want_write(structdentry*dentry){structovl_fs*ofs=OVL_FS(dentry->d_sb);returnmnt_want_write(ovl_upper_mnt(ofs));}voidovl_drop_write(structdentry*dentry){structovl_fs*ofs=OVL_FS(dentry->d_sb);mnt_drop_write(ovl_upper_mnt(ofs));}structdentry*ovl_workdir(structdentry*dentry){structovl_fs*ofs=OVL_FS(dentry->d_sb);returnofs->workdir;}conststructcred*ovl_override_creds(structsuper_block*sb){structovl_fs*ofs=OVL_FS(sb);returnoverride_creds(ofs->creator_cred);}/* * Check if underlying fs supports file handles and try to determine encoding * type, in order to deduce maximum inode number used by fs. * * Return 0 if file handles are not supported. * Return 1 (FILEID_INO32_GEN) if fs uses the default 32bit inode encoding. * Return -1 if fs uses a non default encoding with unknown inode size. */intovl_can_decode_fh(structsuper_block*sb){if(!capable(CAP_DAC_READ_SEARCH))return0;if(!sb->s_export_op||!sb->s_export_op->fh_to_dentry)return0;returnsb->s_export_op->encode_fh?-1:FILEID_INO32_GEN;}structdentry*ovl_indexdir(structsuper_block*sb){structovl_fs*ofs=OVL_FS(sb);returnofs->indexdir;}/* Index all files on copy up. For now only enabled for NFS export */bool