.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * linux/fs/9p/vfs_inode_dotl.c |
---|
3 | 4 | * |
---|
.. | .. |
---|
5 | 6 | * |
---|
6 | 7 | * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com> |
---|
7 | 8 | * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> |
---|
8 | | - * |
---|
9 | | - * This program is free software; you can redistribute it and/or modify |
---|
10 | | - * it under the terms of the GNU General Public License version 2 |
---|
11 | | - * as published by the Free Software Foundation. |
---|
12 | | - * |
---|
13 | | - * This program is distributed in the hope that it will be useful, |
---|
14 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | | - * GNU General Public License for more details. |
---|
17 | | - * |
---|
18 | | - * You should have received a copy of the GNU General Public License |
---|
19 | | - * along with this program; if not, write to: |
---|
20 | | - * Free Software Foundation |
---|
21 | | - * 51 Franklin Street, Fifth Floor |
---|
22 | | - * Boston, MA 02111-1301 USA |
---|
23 | | - * |
---|
24 | 9 | */ |
---|
25 | 10 | |
---|
26 | 11 | #include <linux/module.h> |
---|
.. | .. |
---|
74 | 59 | struct p9_stat_dotl *st = (struct p9_stat_dotl *)data; |
---|
75 | 60 | |
---|
76 | 61 | /* don't match inode of different type */ |
---|
77 | | - if ((inode->i_mode & S_IFMT) != (st->st_mode & S_IFMT)) |
---|
| 62 | + if (inode_wrong_type(inode, st->st_mode)) |
---|
78 | 63 | return 0; |
---|
79 | 64 | |
---|
80 | 65 | if (inode->i_generation != st->st_gen) |
---|
.. | .. |
---|
555 | 540 | int v9fs_vfs_setattr_dotl(struct dentry *dentry, struct iattr *iattr) |
---|
556 | 541 | { |
---|
557 | 542 | int retval; |
---|
558 | | - struct p9_fid *fid; |
---|
559 | | - struct p9_iattr_dotl p9attr; |
---|
| 543 | + struct p9_fid *fid = NULL; |
---|
| 544 | + struct p9_iattr_dotl p9attr = { |
---|
| 545 | + .uid = INVALID_UID, |
---|
| 546 | + .gid = INVALID_GID, |
---|
| 547 | + }; |
---|
560 | 548 | struct inode *inode = d_inode(dentry); |
---|
561 | 549 | |
---|
562 | 550 | p9_debug(P9_DEBUG_VFS, "\n"); |
---|
.. | .. |
---|
566 | 554 | return retval; |
---|
567 | 555 | |
---|
568 | 556 | p9attr.valid = v9fs_mapped_iattr_valid(iattr->ia_valid); |
---|
569 | | - p9attr.mode = iattr->ia_mode; |
---|
570 | | - p9attr.uid = iattr->ia_uid; |
---|
571 | | - p9attr.gid = iattr->ia_gid; |
---|
572 | | - p9attr.size = iattr->ia_size; |
---|
573 | | - p9attr.atime_sec = iattr->ia_atime.tv_sec; |
---|
574 | | - p9attr.atime_nsec = iattr->ia_atime.tv_nsec; |
---|
575 | | - p9attr.mtime_sec = iattr->ia_mtime.tv_sec; |
---|
576 | | - p9attr.mtime_nsec = iattr->ia_mtime.tv_nsec; |
---|
| 557 | + if (iattr->ia_valid & ATTR_MODE) |
---|
| 558 | + p9attr.mode = iattr->ia_mode; |
---|
| 559 | + if (iattr->ia_valid & ATTR_UID) |
---|
| 560 | + p9attr.uid = iattr->ia_uid; |
---|
| 561 | + if (iattr->ia_valid & ATTR_GID) |
---|
| 562 | + p9attr.gid = iattr->ia_gid; |
---|
| 563 | + if (iattr->ia_valid & ATTR_SIZE) |
---|
| 564 | + p9attr.size = iattr->ia_size; |
---|
| 565 | + if (iattr->ia_valid & ATTR_ATIME_SET) { |
---|
| 566 | + p9attr.atime_sec = iattr->ia_atime.tv_sec; |
---|
| 567 | + p9attr.atime_nsec = iattr->ia_atime.tv_nsec; |
---|
| 568 | + } |
---|
| 569 | + if (iattr->ia_valid & ATTR_MTIME_SET) { |
---|
| 570 | + p9attr.mtime_sec = iattr->ia_mtime.tv_sec; |
---|
| 571 | + p9attr.mtime_nsec = iattr->ia_mtime.tv_nsec; |
---|
| 572 | + } |
---|
577 | 573 | |
---|
578 | | - fid = v9fs_fid_lookup(dentry); |
---|
| 574 | + if (iattr->ia_valid & ATTR_FILE) { |
---|
| 575 | + fid = iattr->ia_file->private_data; |
---|
| 576 | + WARN_ON(!fid); |
---|
| 577 | + } |
---|
| 578 | + if (!fid) |
---|
| 579 | + fid = v9fs_fid_lookup(dentry); |
---|
579 | 580 | if (IS_ERR(fid)) |
---|
580 | 581 | return PTR_ERR(fid); |
---|
581 | 582 | |
---|
.. | .. |
---|
656 | 657 | if (stat->st_result_mask & P9_STATS_NLINK) |
---|
657 | 658 | set_nlink(inode, stat->st_nlink); |
---|
658 | 659 | if (stat->st_result_mask & P9_STATS_MODE) { |
---|
659 | | - inode->i_mode = stat->st_mode; |
---|
660 | | - if ((S_ISBLK(inode->i_mode)) || |
---|
661 | | - (S_ISCHR(inode->i_mode))) |
---|
662 | | - init_special_inode(inode, inode->i_mode, |
---|
663 | | - inode->i_rdev); |
---|
| 660 | + mode = stat->st_mode & S_IALLUGO; |
---|
| 661 | + mode |= inode->i_mode & ~S_IALLUGO; |
---|
| 662 | + inode->i_mode = mode; |
---|
664 | 663 | } |
---|
665 | | - if (stat->st_result_mask & P9_STATS_RDEV) |
---|
666 | | - inode->i_rdev = new_decode_dev(stat->st_rdev); |
---|
667 | 664 | if (!(flags & V9FS_STAT2INODE_KEEP_ISIZE) && |
---|
668 | 665 | stat->st_result_mask & P9_STATS_SIZE) |
---|
669 | 666 | v9fs_i_size_write(inode, stat->st_size); |
---|
.. | .. |
---|
943 | 940 | /* |
---|
944 | 941 | * Don't update inode if the file type is different |
---|
945 | 942 | */ |
---|
946 | | - if ((inode->i_mode & S_IFMT) != (st->st_mode & S_IFMT)) |
---|
| 943 | + if (inode_wrong_type(inode, st->st_mode)) |
---|
947 | 944 | goto out; |
---|
948 | 945 | |
---|
949 | 946 | /* |
---|