Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
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
lvzhengyang
git2
Commits
1549cba9
Commit
1549cba9
authored
Jun 03, 2011
by
Romain Geissler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Filebuf: Fixed a TODO in filebuf (real lock in lock_file)
Added gitfo_creat_locked and gitfo_creat_locked_force
parent
bc648491
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
4 deletions
+18
-4
src/filebuf.c
+2
-4
src/fileops.c
+14
-0
src/fileops.h
+2
-0
No files found.
src/filebuf.c
View file @
1549cba9
...
@@ -41,16 +41,14 @@ static int lock_file(git_filebuf *file, int flags)
...
@@ -41,16 +41,14 @@ static int lock_file(git_filebuf *file, int flags)
/* create path to the file buffer is required */
/* create path to the file buffer is required */
if
(
flags
&
GIT_FILEBUF_FORCE
)
{
if
(
flags
&
GIT_FILEBUF_FORCE
)
{
file
->
fd
=
gitfo_creat_force
(
file
->
path_lock
,
0644
);
file
->
fd
=
gitfo_creat_
locked_
force
(
file
->
path_lock
,
0644
);
}
else
{
}
else
{
file
->
fd
=
gitfo_creat
(
file
->
path_lock
,
0644
);
file
->
fd
=
gitfo_creat
_locked
(
file
->
path_lock
,
0644
);
}
}
if
(
file
->
fd
<
0
)
if
(
file
->
fd
<
0
)
return
git__throw
(
GIT_EOSERR
,
"Failed to create lock"
);
return
git__throw
(
GIT_EOSERR
,
"Failed to create lock"
);
/* TODO: do a flock() in the descriptor file_lock */
if
((
flags
&
GIT_FILEBUF_APPEND
)
&&
gitfo_exists
(
file
->
path_original
)
==
0
)
{
if
((
flags
&
GIT_FILEBUF_APPEND
)
&&
gitfo_exists
(
file
->
path_original
)
==
0
)
{
git_file
source
;
git_file
source
;
char
buffer
[
2048
];
char
buffer
[
2048
];
...
...
src/fileops.c
View file @
1549cba9
...
@@ -66,6 +66,20 @@ int gitfo_creat_force(const char *path, int mode)
...
@@ -66,6 +66,20 @@ int gitfo_creat_force(const char *path, int mode)
return
gitfo_creat
(
path
,
mode
);
return
gitfo_creat
(
path
,
mode
);
}
}
int
gitfo_creat_locked
(
const
char
*
path
,
int
mode
)
{
int
fd
=
open
(
path
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
|
O_BINARY
|
O_EXCL
,
mode
);
return
fd
>=
0
?
fd
:
git__throw
(
GIT_EOSERR
,
"Failed to create locked file. Could not open %s"
,
path
);
}
int
gitfo_creat_locked_force
(
const
char
*
path
,
int
mode
)
{
if
(
gitfo_mkdir_2file
(
path
)
<
GIT_SUCCESS
)
return
git__throw
(
GIT_EOSERR
,
"Failed to create locked file %s"
,
path
);
return
gitfo_creat_locked
(
path
,
mode
);
}
int
gitfo_read
(
git_file
fd
,
void
*
buf
,
size_t
cnt
)
int
gitfo_read
(
git_file
fd
,
void
*
buf
,
size_t
cnt
)
{
{
char
*
b
=
buf
;
char
*
b
=
buf
;
...
...
src/fileops.h
View file @
1549cba9
...
@@ -65,6 +65,8 @@ extern int gitfo_exists(const char *path);
...
@@ -65,6 +65,8 @@ extern int gitfo_exists(const char *path);
extern
int
gitfo_open
(
const
char
*
path
,
int
flags
);
extern
int
gitfo_open
(
const
char
*
path
,
int
flags
);
extern
int
gitfo_creat
(
const
char
*
path
,
int
mode
);
extern
int
gitfo_creat
(
const
char
*
path
,
int
mode
);
extern
int
gitfo_creat_force
(
const
char
*
path
,
int
mode
);
extern
int
gitfo_creat_force
(
const
char
*
path
,
int
mode
);
extern
int
gitfo_creat_locked
(
const
char
*
path
,
int
mode
);
extern
int
gitfo_creat_locked_force
(
const
char
*
path
,
int
mode
);
extern
int
gitfo_mktemp
(
char
*
path_out
,
const
char
*
filename
);
extern
int
gitfo_mktemp
(
char
*
path_out
,
const
char
*
filename
);
extern
int
gitfo_isdir
(
const
char
*
path
);
extern
int
gitfo_isdir
(
const
char
*
path
);
extern
int
gitfo_isfile
(
const
char
*
path
);
extern
int
gitfo_isfile
(
const
char
*
path
);
...
...
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