Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
78d211b3
Commit
78d211b3
authored
Nov 23, 2009
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
server: Move the functions to extend file to mapping.c since it's the only user.
parent
ddaf2384
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
43 deletions
+42
-43
file.c
server/file.c
+0
-42
file.h
server/file.h
+0
-1
mapping.c
server/mapping.c
+42
-0
No files found.
server/file.c
View file @
78d211b3
...
...
@@ -641,48 +641,6 @@ struct file *grab_file_unless_removable( struct file *file )
return
(
struct
file
*
)
grab_object
(
file
);
}
/* extend a file beyond the current end of file */
static
int
extend_file
(
struct
file
*
file
,
file_pos_t
new_size
)
{
static
const
char
zero
;
int
unix_fd
=
get_file_unix_fd
(
file
);
off_t
size
=
new_size
;
if
(
unix_fd
==
-
1
)
return
0
;
if
(
sizeof
(
new_size
)
>
sizeof
(
size
)
&&
size
!=
new_size
)
{
set_error
(
STATUS_INVALID_PARAMETER
);
return
0
;
}
/* extend the file one byte beyond the requested size and then truncate it */
/* this should work around ftruncate implementations that can't extend files */
if
(
pwrite
(
unix_fd
,
&
zero
,
1
,
size
)
!=
-
1
)
{
ftruncate
(
unix_fd
,
size
);
return
1
;
}
file_set_error
();
return
0
;
}
/* try to grow the file to the specified size */
int
grow_file
(
struct
file
*
file
,
file_pos_t
size
)
{
struct
stat
st
;
int
unix_fd
=
get_file_unix_fd
(
file
);
if
(
unix_fd
==
-
1
)
return
0
;
if
(
fstat
(
unix_fd
,
&
st
)
==
-
1
)
{
file_set_error
();
return
0
;
}
if
(
st
.
st_size
>=
size
)
return
1
;
/* already large enough */
return
extend_file
(
file
,
size
);
}
/* create a file */
DECL_HANDLER
(
create_file
)
{
...
...
server/file.h
View file @
78d211b3
...
...
@@ -110,7 +110,6 @@ extern struct file *get_file_obj( struct process *process, obj_handle_t handle,
extern
int
get_file_unix_fd
(
struct
file
*
file
);
extern
int
is_same_file
(
struct
file
*
file1
,
struct
file
*
file2
);
extern
struct
file
*
grab_file_unless_removable
(
struct
file
*
file
);
extern
int
grow_file
(
struct
file
*
file
,
file_pos_t
size
);
extern
struct
file
*
create_temp_file
(
int
access
);
extern
void
file_set_error
(
void
);
extern
struct
security_descriptor
*
mode_to_sd
(
mode_t
mode
,
const
SID
*
user
,
const
SID
*
group
);
...
...
server/mapping.c
View file @
78d211b3
...
...
@@ -126,6 +126,48 @@ static void init_page_size(void)
#define ROUND_SIZE(size) (((size) + page_mask) & ~page_mask)
/* extend a file beyond the current end of file */
static
int
extend_file
(
struct
file
*
file
,
file_pos_t
new_size
)
{
static
const
char
zero
;
int
unix_fd
=
get_file_unix_fd
(
file
);
off_t
size
=
new_size
;
if
(
unix_fd
==
-
1
)
return
0
;
if
(
sizeof
(
new_size
)
>
sizeof
(
size
)
&&
size
!=
new_size
)
{
set_error
(
STATUS_INVALID_PARAMETER
);
return
0
;
}
/* extend the file one byte beyond the requested size and then truncate it */
/* this should work around ftruncate implementations that can't extend files */
if
(
pwrite
(
unix_fd
,
&
zero
,
1
,
size
)
!=
-
1
)
{
ftruncate
(
unix_fd
,
size
);
return
1
;
}
file_set_error
();
return
0
;
}
/* try to grow the file to the specified size */
static
int
grow_file
(
struct
file
*
file
,
file_pos_t
size
)
{
struct
stat
st
;
int
unix_fd
=
get_file_unix_fd
(
file
);
if
(
unix_fd
==
-
1
)
return
0
;
if
(
fstat
(
unix_fd
,
&
st
)
==
-
1
)
{
file_set_error
();
return
0
;
}
if
(
st
.
st_size
>=
size
)
return
1
;
/* already large enough */
return
extend_file
(
file
,
size
);
}
/* find the shared PE mapping for a given mapping */
static
struct
file
*
get_shared_file
(
struct
mapping
*
mapping
)
{
...
...
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