Skip to content

Commit 7f67d55

Browse files
committed
Isolate symlink function into a new file
Move the symlink function to a new source file to better align with the Ext4 filesystem structure. This separation improves code organization and maintainability.
1 parent 234c607 commit 7f67d55

File tree

4 files changed

+17
-14
lines changed

4 files changed

+17
-14
lines changed

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
obj-m += simplefs.o
2-
simplefs-objs := fs.o super.o inode.o file.o dir.o extent.o
3-
2+
simplefs-objs := fs.o super.o inode.o file.o dir.o extent.o symlink.o
43
KDIR ?= /lib/modules/$(shell uname -r)/build
54

65
MKFS = mkfs.simplefs

inode.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include "simplefs.h"
1010

1111
static const struct inode_operations simplefs_inode_ops;
12-
static const struct inode_operations symlink_inode_ops;
1312

1413
/* Either return the inode that corresponds to a given inode number (ino), if
1514
* it is already in the cache, or create a new inode object if it is not in the
@@ -1161,13 +1160,6 @@ static int simplefs_symlink(struct inode *dir,
11611160
return ret;
11621161
}
11631162

1164-
static const char *simplefs_get_link(struct dentry *dentry,
1165-
struct inode *inode,
1166-
struct delayed_call *done)
1167-
{
1168-
return inode->i_link;
1169-
}
1170-
11711163
static const struct inode_operations simplefs_inode_ops = {
11721164
.lookup = simplefs_lookup,
11731165
.create = simplefs_create,
@@ -1178,7 +1170,3 @@ static const struct inode_operations simplefs_inode_ops = {
11781170
.link = simplefs_link,
11791171
.symlink = simplefs_symlink,
11801172
};
1181-
1182-
static const struct inode_operations symlink_inode_ops = {
1183-
.get_link = simplefs_get_link,
1184-
};

simplefs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,7 @@ struct simplefs_sb_info {
159159
#endif /* __KERNEL__ */
160160
};
161161

162+
163+
/* symlink.c */
164+
extern const struct inode_operations symlink_inode_ops;
162165
#endif /* SIMPLEFS_H */

symlink.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <linux/fs.h>
2+
#include "simplefs.h"
3+
4+
static const char *simplefs_get_link(struct dentry *dentry,
5+
struct inode *inode,
6+
struct delayed_call *done)
7+
{
8+
return inode->i_link;
9+
}
10+
11+
const struct inode_operations symlink_inode_ops = {
12+
.get_link = simplefs_get_link,
13+
};

0 commit comments

Comments
 (0)