Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
educg-net-28668-2608132
OSKernel2024-UNO-OS-1126
Commits
59afe076
Commit
59afe076
authored
6 months ago
by
lltsdyp
Browse files
Options
Download
Patches
Plain Diff
完成lab-8
parent
79c55dbb
master
v-0.7alpha
v-0.8alpha
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
kernel/fs/inode.c
+13
-3
kernel/fs/inode.c
with
13 additions
and
3 deletions
+13
-3
kernel/fs/inode.c
+
13
−
3
View file @
59afe076
...
...
@@ -312,7 +312,7 @@ uint32 inode_read_data(inode_t* ip, uint32 offset, uint32 len, void* dst, bool u
if
(
offset
>
ip
->
disk_inode
.
size
||
offset
+
len
<
offset
)
return
-
1
;
if
(
len
>
ip
->
disk_inode
.
size
-
offset
)
if
(
len
+
offset
>
ip
->
disk_inode
.
size
)
total
=
ip
->
disk_inode
.
size
-
offset
;
uint32
beg
=
offset
;
...
...
@@ -359,6 +359,8 @@ uint32 inode_write_data(inode_t* ip, uint32 offset, uint32 len, void* src, bool
uint32
beg
=
offset
;
char
*
src_by_byte
=
(
char
*
)
src
;
int
size_modified
=
0
;
while
(
count
<
len
)
{
buf_t
*
b
=
buf_read
(
inode_locate_block
(
ip
,
beg
/
BLOCK_SIZE
));
...
...
@@ -373,8 +375,6 @@ uint32 inode_write_data(inode_t* ip, uint32 offset, uint32 len, void* src, bool
else
memcpy
((
void
*
)(
b
->
data
+
beg
%
BLOCK_SIZE
),
(
void
*
)
src_by_byte
,
writesize
);
if
(
offset
+
len
>
ip
->
disk_inode
.
size
)
ip
->
disk_inode
.
size
=
offset
+
len
;
buf_write
(
b
);
buf_release
(
b
);
...
...
@@ -382,6 +382,16 @@ uint32 inode_write_data(inode_t* ip, uint32 offset, uint32 len, void* src, bool
beg
+=
writesize
;
count
+=
writesize
;
src_by_byte
+=
writesize
;
if
(
offset
+
count
>
ip
->
disk_inode
.
size
){
ip
->
disk_inode
.
size
=
offset
+
len
;
size_modified
=
1
;
}
}
if
(
size_modified
)
{
inode_rw
(
ip
,
true
);
}
return
count
;
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets