Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
35b17acf
Commit
35b17acf
authored
Jan 02, 2017
by
Dridi Boukelmoune
Committed by
guillaume quintard
Jan 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A VFIL_writefile function similar to VFIL_readfile
parent
ecf13bf2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
0 deletions
+35
-0
vfil.h
include/vfil.h
+1
-0
vfil.c
lib/libvarnish/vfil.c
+34
-0
No files found.
include/vfil.h
View file @
35b17acf
...
...
@@ -33,6 +33,7 @@ struct vfil_path;
/* from libvarnish/vfil.c */
int
seed_random
(
void
);
char
*
VFIL_readfile
(
const
char
*
pfx
,
const
char
*
fn
,
ssize_t
*
sz
);
int
VFIL_writefile
(
const
char
*
pfx
,
const
char
*
fn
,
const
char
*
buf
,
size_t
sz
);
int
VFIL_nonblocking
(
int
fd
);
int
VFIL_fsinfo
(
int
fd
,
unsigned
*
pbs
,
uintmax_t
*
size
,
uintmax_t
*
space
);
int
VFIL_allocate
(
int
fd
,
off_t
size
,
int
insist
);
...
...
lib/libvarnish/vfil.c
View file @
35b17acf
...
...
@@ -85,6 +85,24 @@ vfil_readfd(int fd, ssize_t *sz)
return
(
f
);
}
static
int
vfil_writefd
(
int
fd
,
const
char
*
buf
,
size_t
sz
)
{
ssize_t
len
;
while
(
sz
>
0
)
{
len
=
write
(
fd
,
buf
,
sz
);
if
(
len
<
0
)
return
(
len
);
if
(
len
==
0
)
break
;
buf
+=
len
;
sz
-=
len
;
}
return
(
sz
==
0
?
0
:
-
1
);
}
static
int
vfil_openfile
(
const
char
*
pfx
,
const
char
*
fn
,
int
flags
,
int
mode
)
{
...
...
@@ -118,6 +136,22 @@ VFIL_readfile(const char *pfx, const char *fn, ssize_t *sz)
return
(
r
);
}
int
VFIL_writefile
(
const
char
*
pfx
,
const
char
*
fn
,
const
char
*
buf
,
size_t
sz
)
{
int
fd
,
err
;
int
r
;
fd
=
vfil_openfile
(
pfx
,
fn
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
,
0660
);
if
(
fd
<
0
)
return
(
fd
);
r
=
vfil_writefd
(
fd
,
buf
,
sz
);
err
=
errno
;
AZ
(
close
(
fd
));
errno
=
err
;
return
(
r
);
}
int
VFIL_nonblocking
(
int
fd
)
{
...
...
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