.. | .. |
---|
139 | 139 | |
---|
140 | 140 | static char *follow_link(char *link) |
---|
141 | 141 | { |
---|
142 | | - int len, n; |
---|
143 | 142 | char *name, *resolved, *end; |
---|
| 143 | + int n; |
---|
144 | 144 | |
---|
145 | | - name = __getname(); |
---|
| 145 | + name = kmalloc(PATH_MAX, GFP_KERNEL); |
---|
146 | 146 | if (!name) { |
---|
147 | 147 | n = -ENOMEM; |
---|
148 | 148 | goto out_free; |
---|
.. | .. |
---|
164 | 164 | return name; |
---|
165 | 165 | |
---|
166 | 166 | *(end + 1) = '\0'; |
---|
167 | | - len = strlen(link) + strlen(name) + 1; |
---|
168 | 167 | |
---|
169 | | - resolved = kmalloc(len, GFP_KERNEL); |
---|
| 168 | + resolved = kasprintf(GFP_KERNEL, "%s%s", link, name); |
---|
170 | 169 | if (resolved == NULL) { |
---|
171 | 170 | n = -ENOMEM; |
---|
172 | 171 | goto out_free; |
---|
173 | 172 | } |
---|
174 | 173 | |
---|
175 | | - sprintf(resolved, "%s%s", link, name); |
---|
176 | | - __putname(name); |
---|
177 | | - kfree(link); |
---|
| 174 | + kfree(name); |
---|
178 | 175 | return resolved; |
---|
179 | 176 | |
---|
180 | 177 | out_free: |
---|
181 | | - __putname(name); |
---|
| 178 | + kfree(name); |
---|
182 | 179 | return ERR_PTR(n); |
---|
183 | 180 | } |
---|
184 | 181 | |
---|
.. | .. |
---|
243 | 240 | } |
---|
244 | 241 | } |
---|
245 | 242 | |
---|
246 | | -static void hostfs_i_callback(struct rcu_head *head) |
---|
| 243 | +static void hostfs_free_inode(struct inode *inode) |
---|
247 | 244 | { |
---|
248 | | - struct inode *inode = container_of(head, struct inode, i_rcu); |
---|
249 | 245 | kfree(HOSTFS_I(inode)); |
---|
250 | | -} |
---|
251 | | - |
---|
252 | | -static void hostfs_destroy_inode(struct inode *inode) |
---|
253 | | -{ |
---|
254 | | - call_rcu(&inode->i_rcu, hostfs_i_callback); |
---|
255 | 246 | } |
---|
256 | 247 | |
---|
257 | 248 | static int hostfs_show_options(struct seq_file *seq, struct dentry *root) |
---|
.. | .. |
---|
270 | 261 | |
---|
271 | 262 | static const struct super_operations hostfs_sbops = { |
---|
272 | 263 | .alloc_inode = hostfs_alloc_inode, |
---|
273 | | - .destroy_inode = hostfs_destroy_inode, |
---|
| 264 | + .free_inode = hostfs_free_inode, |
---|
274 | 265 | .evict_inode = hostfs_evict_inode, |
---|
275 | 266 | .statfs = hostfs_statfs, |
---|
276 | 267 | .show_options = hostfs_show_options, |
---|
.. | .. |
---|
555 | 546 | set_nlink(ino, st.nlink); |
---|
556 | 547 | i_uid_write(ino, st.uid); |
---|
557 | 548 | i_gid_write(ino, st.gid); |
---|
558 | | - ino->i_atime = timespec_to_timespec64(st.atime); |
---|
559 | | - ino->i_mtime = timespec_to_timespec64(st.mtime); |
---|
560 | | - ino->i_ctime = timespec_to_timespec64(st.ctime); |
---|
| 549 | + ino->i_atime = (struct timespec64){ st.atime.tv_sec, st.atime.tv_nsec }; |
---|
| 550 | + ino->i_mtime = (struct timespec64){ st.mtime.tv_sec, st.mtime.tv_nsec }; |
---|
| 551 | + ino->i_ctime = (struct timespec64){ st.ctime.tv_sec, st.ctime.tv_nsec }; |
---|
561 | 552 | ino->i_size = st.size; |
---|
562 | 553 | ino->i_blocks = st.blocks; |
---|
563 | 554 | return 0; |
---|
.. | .. |
---|
826 | 817 | } |
---|
827 | 818 | if (attr->ia_valid & ATTR_ATIME) { |
---|
828 | 819 | attrs.ia_valid |= HOSTFS_ATTR_ATIME; |
---|
829 | | - attrs.ia_atime = timespec64_to_timespec(attr->ia_atime); |
---|
| 820 | + attrs.ia_atime = (struct hostfs_timespec) |
---|
| 821 | + { attr->ia_atime.tv_sec, attr->ia_atime.tv_nsec }; |
---|
830 | 822 | } |
---|
831 | 823 | if (attr->ia_valid & ATTR_MTIME) { |
---|
832 | 824 | attrs.ia_valid |= HOSTFS_ATTR_MTIME; |
---|
833 | | - attrs.ia_mtime = timespec64_to_timespec(attr->ia_mtime); |
---|
| 825 | + attrs.ia_mtime = (struct hostfs_timespec) |
---|
| 826 | + { attr->ia_mtime.tv_sec, attr->ia_mtime.tv_nsec }; |
---|
834 | 827 | } |
---|
835 | 828 | if (attr->ia_valid & ATTR_CTIME) { |
---|
836 | 829 | attrs.ia_valid |= HOSTFS_ATTR_CTIME; |
---|
837 | | - attrs.ia_ctime = timespec64_to_timespec(attr->ia_ctime); |
---|
| 830 | + attrs.ia_ctime = (struct hostfs_timespec) |
---|
| 831 | + { attr->ia_ctime.tv_sec, attr->ia_ctime.tv_nsec }; |
---|
838 | 832 | } |
---|
839 | 833 | if (attr->ia_valid & ATTR_ATIME_SET) { |
---|
840 | 834 | attrs.ia_valid |= HOSTFS_ATTR_ATIME_SET; |
---|
.. | .. |
---|
924 | 918 | sb->s_d_op = &simple_dentry_operations; |
---|
925 | 919 | sb->s_maxbytes = MAX_LFS_FILESIZE; |
---|
926 | 920 | |
---|
927 | | - /* NULL is printed as <NULL> by sprintf: avoid that. */ |
---|
| 921 | + /* NULL is printed as '(null)' by printf(): avoid that. */ |
---|
928 | 922 | if (req_root == NULL) |
---|
929 | 923 | req_root = ""; |
---|
930 | 924 | |
---|
931 | 925 | err = -ENOMEM; |
---|
932 | 926 | sb->s_fs_info = host_root_path = |
---|
933 | | - kmalloc(strlen(root_ino) + strlen(req_root) + 2, GFP_KERNEL); |
---|
| 927 | + kasprintf(GFP_KERNEL, "%s/%s", root_ino, req_root); |
---|
934 | 928 | if (host_root_path == NULL) |
---|
935 | 929 | goto out; |
---|
936 | | - |
---|
937 | | - sprintf(host_root_path, "%s/%s", root_ino, req_root); |
---|
938 | 930 | |
---|
939 | 931 | root_inode = new_inode(sb); |
---|
940 | 932 | if (!root_inode) |
---|