Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
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
Иван Мажукин
mpd
Commits
c3bc1e5b
Commit
c3bc1e5b
authored
Jul 23, 2006
by
J. Alexander Treuman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make checkDirectoryDB check that the db file is a regular file
git-svn-id:
https://svn.musicpd.org/mpd/trunk@4436
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
bb9a5aaf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
3 deletions
+16
-3
directory.c
src/directory.c
+16
-3
No files found.
src/directory.c
View file @
c3bc1e5b
...
@@ -1021,6 +1021,7 @@ static void sortDirectory(Directory * directory)
...
@@ -1021,6 +1021,7 @@ static void sortDirectory(Directory * directory)
int
checkDirectoryDB
()
int
checkDirectoryDB
()
{
{
struct
stat
st
;
char
*
dbFile
;
char
*
dbFile
;
char
*
dirPath
;
char
*
dirPath
;
char
*
dbPath
;
char
*
dbPath
;
...
@@ -1029,11 +1030,10 @@ int checkDirectoryDB()
...
@@ -1029,11 +1030,10 @@ int checkDirectoryDB()
/* Check if the file exists */
/* Check if the file exists */
if
(
access
(
dbFile
,
F_OK
))
{
if
(
access
(
dbFile
,
F_OK
))
{
dbPath
=
strdup
(
dbFile
);
/* If the file doesn't exist, we can't check if we can write
/* If the file doesn't exist, we can't check if we can write
* it, so we are going to try to get the directory path, and
* it, so we are going to try to get the directory path, and
* see if we can write a file in that */
* see if we can write a file in that */
dbPath
=
strdup
(
dbFile
);
dirPath
=
dirname
(
dbPath
);
dirPath
=
dirname
(
dbPath
);
/* Check if we can write to the directory */
/* Check if we can write to the directory */
...
@@ -1049,7 +1049,19 @@ int checkDirectoryDB()
...
@@ -1049,7 +1049,19 @@ int checkDirectoryDB()
return
0
;
return
0
;
}
}
/* File exists, now check if we can write it */
/* Path exists, now check if it's a regular file */
if
(
stat
(
dbFile
,
&
st
)
<
0
)
{
ERROR
(
"Error stat'ing db file
\"
%s
\"
: %s
\n
"
,
dbFile
,
strerror
(
errno
));
return
-
1
;
}
if
(
!
S_ISREG
(
st
.
st_mode
))
{
ERROR
(
"db file
\"
%s
\"
is not a regular file
\n
"
,
dbFile
);
return
-
1
;
}
/* And check that we can write to it */
if
(
access
(
dbFile
,
R_OK
|
W_OK
))
{
if
(
access
(
dbFile
,
R_OK
|
W_OK
))
{
ERROR
(
"Can't open db file
\"
%s
\"
for reading/writing: %s
\n
"
,
ERROR
(
"Can't open db file
\"
%s
\"
for reading/writing: %s
\n
"
,
dbFile
,
strerror
(
errno
));
dbFile
,
strerror
(
errno
));
...
@@ -1172,6 +1184,7 @@ int readDirectoryDB()
...
@@ -1172,6 +1184,7 @@ int readDirectoryDB()
ERROR
(
"db info not found in db file
\n
"
);
ERROR
(
"db info not found in db file
\n
"
);
ERROR
(
"you should recreate the db using --create-db
\n
"
);
ERROR
(
"you should recreate the db using --create-db
\n
"
);
fseek
(
fp
,
0
,
SEEK_SET
);
fseek
(
fp
,
0
,
SEEK_SET
);
return
-
1
;
}
}
}
}
...
...
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