Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
criu
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhul
criu
Commits
b0502e4f
Commit
b0502e4f
authored
Sep 12, 2012
by
Pavel Emelyanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fd: Split fd opening and serving out routines
Signed-off-by:
Pavel Emelyanov
<
xemul@parallels.com
>
parent
ae4796d0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
20 deletions
+28
-20
files.c
files.c
+28
-20
No files found.
files.c
View file @
b0502e4f
...
...
@@ -395,41 +395,28 @@ static int post_open_fd(int pid, FdinfoEntry *fe, struct file_desc *d)
return
d
->
ops
->
post_open
(
d
,
fle
->
fe
->
fd
);
}
static
int
open_fd
(
int
pid
,
FdinfoEntry
*
fe
,
struct
file_desc
*
d
)
static
int
serve_out_fd
(
int
pid
,
int
fd
,
struct
file_desc
*
d
)
{
int
ret
;
int
sock
;
int
sock
,
ret
;
struct
fdinfo_list_entry
*
fle
;
fle
=
file_master
(
d
);
if
((
fle
->
pid
!=
pid
)
||
(
fe
->
fd
!=
fle
->
fe
->
fd
))
return
0
;
ret
=
d
->
ops
->
open
(
d
);
if
(
ret
<
0
)
return
-
1
;
if
(
reopen_fd_as
(
fe
->
fd
,
ret
))
return
-
1
;
fcntl
(
fe
->
fd
,
F_SETFD
,
fe
->
flags
);
sock
=
socket
(
PF_UNIX
,
SOCK_DGRAM
,
0
);
if
(
sock
<
0
)
{
pr_perror
(
"Can't create socket"
);
return
-
1
;
}
pr_info
(
"
\t\t
Create fd for %d
\n
"
,
f
e
->
f
d
);
pr_info
(
"
\t\t
Create fd for %d
\n
"
,
fd
);
list_for_each_entry
(
fle
,
&
d
->
fd_info_head
,
desc_list
)
{
if
(
pid
==
fle
->
pid
)
ret
=
send_fd_to_self
(
f
e
->
f
d
,
fle
,
&
sock
);
ret
=
send_fd_to_self
(
fd
,
fle
,
&
sock
);
else
ret
=
send_fd_to_peer
(
f
e
->
f
d
,
fle
,
sock
);
ret
=
send_fd_to_peer
(
fd
,
fle
,
sock
);
if
(
ret
)
{
pr_err
(
"Can't sent fd %d to %d
\n
"
,
f
e
->
f
d
,
fle
->
pid
);
pr_err
(
"Can't sent fd %d to %d
\n
"
,
fd
,
fle
->
pid
);
return
-
1
;
}
}
...
...
@@ -438,6 +425,27 @@ static int open_fd(int pid, FdinfoEntry *fe, struct file_desc *d)
return
0
;
}
static
int
open_fd
(
int
pid
,
FdinfoEntry
*
fe
,
struct
file_desc
*
d
)
{
int
new_fd
;
struct
fdinfo_list_entry
*
fle
;
fle
=
file_master
(
d
);
if
((
fle
->
pid
!=
pid
)
||
(
fe
->
fd
!=
fle
->
fe
->
fd
))
return
0
;
new_fd
=
d
->
ops
->
open
(
d
);
if
(
new_fd
<
0
)
return
-
1
;
if
(
reopen_fd_as
(
fe
->
fd
,
new_fd
))
return
-
1
;
fcntl
(
fe
->
fd
,
F_SETFD
,
fe
->
flags
);
return
serve_out_fd
(
pid
,
fe
->
fd
,
d
);
}
static
int
receive_fd
(
int
pid
,
FdinfoEntry
*
fe
,
struct
file_desc
*
d
)
{
int
tmp
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment