Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
D
Dnsmasq
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Dnsmasq
Commits
857973e6
Commit
857973e6
authored
Dec 15, 2014
by
Simon Kelley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Teach the new inotify code about symlinks.
parent
9c448c80
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
16 deletions
+27
-16
src/inotify.c
src/inotify.c
+27
-16
No files found.
src/inotify.c
View file @
857973e6
...
@@ -41,29 +41,40 @@ void inotify_dnsmasq_init()
...
@@ -41,29 +41,40 @@ void inotify_dnsmasq_init()
inotify_buffer
=
safe_malloc
(
INOTIFY_SZ
);
inotify_buffer
=
safe_malloc
(
INOTIFY_SZ
);
daemon
->
inotifyfd
=
inotify_init1
(
IN_NONBLOCK
|
IN_CLOEXEC
);
daemon
->
inotifyfd
=
inotify_init1
(
IN_NONBLOCK
|
IN_CLOEXEC
);
if
(
daemon
->
inotifyfd
==
-
1
)
if
(
daemon
->
inotifyfd
==
-
1
)
die
(
_
(
"failed to create inotify: %s"
),
NULL
,
EC_MISC
);
die
(
_
(
"failed to create inotify: %s"
),
NULL
,
EC_MISC
);
for
(
res
=
daemon
->
resolv_files
;
res
;
res
=
res
->
next
)
for
(
res
=
daemon
->
resolv_files
;
res
;
res
=
res
->
next
)
{
{
char
*
d
=
strrchr
(
res
->
name
,
'/'
);
char
*
d
=
NULL
,
*
path
;
if
(
!
d
)
die
(
_
(
"resolv-file %s not an absolute path"
),
res
->
name
,
EC_MISC
);
*
d
=
0
;
/* make ->name just directory */
res
->
wd
=
inotify_add_watch
(
daemon
->
inotifyfd
,
res
->
name
,
IN_CLOSE_WRITE
|
IN_MOVED_TO
);
res
->
file
=
d
+
1
;
/* pointer to filename */
if
(
res
->
wd
==
-
1
&&
errno
==
ENOENT
)
die
(
_
(
"directory %s for resolv-file is missing, cannot poll"
),
res
->
name
,
EC_MISC
);
*
d
=
'/'
;
/* restore name */
if
(
!
(
path
=
realpath
(
res
->
name
,
NULL
)))
{
/* realpath will fail if the file doesn't exist, but
dnsmasq copes with missing files, so fall back
and assume that symlinks are not in use in that case. */
if
(
errno
==
ENOENT
)
path
=
res
->
name
;
else
die
(
_
(
"cannot cannonicalise resolv-file %s: %s"
),
res
->
name
,
EC_MISC
);
}
if
(
res
->
wd
==
-
1
)
if
((
d
=
strrchr
(
path
,
'/'
)))
die
(
_
(
"failed to create inotify for %s: %s"
),
res
->
name
,
EC_MISC
);
{
*
d
=
0
;
/* make path just directory */
res
->
wd
=
inotify_add_watch
(
daemon
->
inotifyfd
,
path
,
IN_CLOSE_WRITE
|
IN_MOVED_TO
);
res
->
file
=
d
+
1
;
/* pointer to filename */
*
d
=
'/'
;
if
(
res
->
wd
==
-
1
&&
errno
==
ENOENT
)
die
(
_
(
"directory %s for resolv-file is missing, cannot poll"
),
res
->
name
,
EC_MISC
);
if
(
res
->
wd
==
-
1
)
die
(
_
(
"failed to create inotify for %s: %s"
),
res
->
name
,
EC_MISC
);
}
}
}
}
}
...
...
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