ARM64: dts: rk3368-tb-sheep: add grf offset property for dwc-control-usb
[firefly-linux-kernel-4.4.55.git] / fs / stat.c
index 04ce1ac20d20b393d13bdfcd0e24c8ca4cde743e..d4a61d8dc021e6e70a3a1317ef793753de8165ed 100644 (file)
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -37,14 +37,21 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
 
 EXPORT_SYMBOL(generic_fillattr);
 
-int vfs_getattr(struct path *path, struct kstat *stat)
+/**
+ * vfs_getattr_nosec - getattr without security checks
+ * @path: file to get attributes from
+ * @stat: structure to return attributes in
+ *
+ * Get attributes without calling security_inode_getattr.
+ *
+ * Currently the only caller other than vfs_getattr is internal to the
+ * filehandle lookup code, which uses only the inode number and returns
+ * no attributes to any user.  Any other code probably wants
+ * vfs_getattr.
+ */
+int vfs_getattr_nosec(struct path *path, struct kstat *stat)
 {
-       struct inode *inode = path->dentry->d_inode;
-       int retval;
-
-       retval = security_inode_getattr(path->mnt, path->dentry);
-       if (retval)
-               return retval;
+       struct inode *inode = d_backing_inode(path->dentry);
 
        if (inode->i_op->getattr)
                return inode->i_op->getattr(path->mnt, path->dentry, stat);
@@ -53,6 +60,18 @@ int vfs_getattr(struct path *path, struct kstat *stat)
        return 0;
 }
 
+EXPORT_SYMBOL(vfs_getattr_nosec);
+
+int vfs_getattr(struct path *path, struct kstat *stat)
+{
+       int retval;
+
+       retval = security_inode_getattr(path);
+       if (retval)
+               return retval;
+       return vfs_getattr_nosec(path, stat);
+}
+
 EXPORT_SYMBOL(vfs_getattr);
 
 int vfs_fstat(unsigned int fd, struct kstat *stat)
@@ -307,7 +326,7 @@ SYSCALL_DEFINE4(readlinkat, int, dfd, const char __user *, pathname,
 retry:
        error = user_path_at_empty(dfd, pathname, lookup_flags, &path, &empty);
        if (!error) {
-               struct inode *inode = path.dentry->d_inode;
+               struct inode *inode = d_backing_inode(path.dentry);
 
                error = empty ? -ENOENT : -EINVAL;
                if (inode->i_op->readlink) {
@@ -348,8 +367,6 @@ static long cp_new_stat64(struct kstat *stat, struct stat64 __user *statbuf)
        INIT_STRUCT_STAT64_PADDING(tmp);
 #ifdef CONFIG_MIPS
        /* mips has weird padding, so we don't get 64 bits there */
-       if (!new_valid_dev(stat->dev) || !new_valid_dev(stat->rdev))
-               return -EOVERFLOW;
        tmp.st_dev = new_encode_dev(stat->dev);
        tmp.st_rdev = new_encode_dev(stat->rdev);
 #else
@@ -447,9 +464,8 @@ void inode_add_bytes(struct inode *inode, loff_t bytes)
 
 EXPORT_SYMBOL(inode_add_bytes);
 
-void inode_sub_bytes(struct inode *inode, loff_t bytes)
+void __inode_sub_bytes(struct inode *inode, loff_t bytes)
 {
-       spin_lock(&inode->i_lock);
        inode->i_blocks -= bytes >> 9;
        bytes &= 511;
        if (inode->i_bytes < bytes) {
@@ -457,6 +473,14 @@ void inode_sub_bytes(struct inode *inode, loff_t bytes)
                inode->i_bytes += 512;
        }
        inode->i_bytes -= bytes;
+}
+
+EXPORT_SYMBOL(__inode_sub_bytes);
+
+void inode_sub_bytes(struct inode *inode, loff_t bytes)
+{
+       spin_lock(&inode->i_lock);
+       __inode_sub_bytes(inode, bytes);
        spin_unlock(&inode->i_lock);
 }