hc
2024-02-19 1c055e55a242a33e574e48be530e06770a210dcd
kernel/fs/hostfs/hostfs_kern.c
....@@ -139,10 +139,10 @@
139139
140140 static char *follow_link(char *link)
141141 {
142
- int len, n;
143142 char *name, *resolved, *end;
143
+ int n;
144144
145
- name = __getname();
145
+ name = kmalloc(PATH_MAX, GFP_KERNEL);
146146 if (!name) {
147147 n = -ENOMEM;
148148 goto out_free;
....@@ -164,21 +164,18 @@
164164 return name;
165165
166166 *(end + 1) = '\0';
167
- len = strlen(link) + strlen(name) + 1;
168167
169
- resolved = kmalloc(len, GFP_KERNEL);
168
+ resolved = kasprintf(GFP_KERNEL, "%s%s", link, name);
170169 if (resolved == NULL) {
171170 n = -ENOMEM;
172171 goto out_free;
173172 }
174173
175
- sprintf(resolved, "%s%s", link, name);
176
- __putname(name);
177
- kfree(link);
174
+ kfree(name);
178175 return resolved;
179176
180177 out_free:
181
- __putname(name);
178
+ kfree(name);
182179 return ERR_PTR(n);
183180 }
184181
....@@ -243,15 +240,9 @@
243240 }
244241 }
245242
246
-static void hostfs_i_callback(struct rcu_head *head)
243
+static void hostfs_free_inode(struct inode *inode)
247244 {
248
- struct inode *inode = container_of(head, struct inode, i_rcu);
249245 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);
255246 }
256247
257248 static int hostfs_show_options(struct seq_file *seq, struct dentry *root)
....@@ -270,7 +261,7 @@
270261
271262 static const struct super_operations hostfs_sbops = {
272263 .alloc_inode = hostfs_alloc_inode,
273
- .destroy_inode = hostfs_destroy_inode,
264
+ .free_inode = hostfs_free_inode,
274265 .evict_inode = hostfs_evict_inode,
275266 .statfs = hostfs_statfs,
276267 .show_options = hostfs_show_options,
....@@ -555,9 +546,9 @@
555546 set_nlink(ino, st.nlink);
556547 i_uid_write(ino, st.uid);
557548 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 };
561552 ino->i_size = st.size;
562553 ino->i_blocks = st.blocks;
563554 return 0;
....@@ -826,15 +817,18 @@
826817 }
827818 if (attr->ia_valid & ATTR_ATIME) {
828819 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 };
830822 }
831823 if (attr->ia_valid & ATTR_MTIME) {
832824 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 };
834827 }
835828 if (attr->ia_valid & ATTR_CTIME) {
836829 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 };
838832 }
839833 if (attr->ia_valid & ATTR_ATIME_SET) {
840834 attrs.ia_valid |= HOSTFS_ATTR_ATIME_SET;
....@@ -924,17 +918,15 @@
924918 sb->s_d_op = &simple_dentry_operations;
925919 sb->s_maxbytes = MAX_LFS_FILESIZE;
926920
927
- /* NULL is printed as <NULL> by sprintf: avoid that. */
921
+ /* NULL is printed as '(null)' by printf(): avoid that. */
928922 if (req_root == NULL)
929923 req_root = "";
930924
931925 err = -ENOMEM;
932926 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);
934928 if (host_root_path == NULL)
935929 goto out;
936
-
937
- sprintf(host_root_path, "%s/%s", root_ino, req_root);
938930
939931 root_inode = new_inode(sb);
940932 if (!root_inode)