Punt rc_is_file
This commit is contained in:
parent
bd83448633
commit
bb9ad38de2
@ -151,21 +151,6 @@ bool rc_exists (const char *pathname)
|
|||||||
}
|
}
|
||||||
librc_hidden_def(rc_exists)
|
librc_hidden_def(rc_exists)
|
||||||
|
|
||||||
bool rc_is_file (const char *pathname)
|
|
||||||
{
|
|
||||||
struct stat buf;
|
|
||||||
|
|
||||||
if (! pathname)
|
|
||||||
return (false);
|
|
||||||
|
|
||||||
if (stat (pathname, &buf) == 0)
|
|
||||||
return (S_ISREG (buf.st_mode));
|
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
return (false);
|
|
||||||
}
|
|
||||||
librc_hidden_def(rc_is_file)
|
|
||||||
|
|
||||||
bool rc_is_dir (const char *pathname)
|
bool rc_is_dir (const char *pathname)
|
||||||
{
|
{
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
@ -447,7 +432,7 @@ char **rc_env_filter (void)
|
|||||||
if (! whitelist)
|
if (! whitelist)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
if (rc_is_file (PROFILE_ENV))
|
if (rc_exists (PROFILE_ENV))
|
||||||
profile = rc_config_load (PROFILE_ENV);
|
profile = rc_config_load (PROFILE_ENV);
|
||||||
|
|
||||||
STRLIST_FOREACH (whitelist, env_name, count) {
|
STRLIST_FOREACH (whitelist, env_name, count) {
|
||||||
|
@ -296,7 +296,7 @@ bool rc_service_mark (const char *service, const rc_service_state_t state)
|
|||||||
base = basename (svc);
|
base = basename (svc);
|
||||||
|
|
||||||
if (state != RC_SERVICE_STOPPED) {
|
if (state != RC_SERVICE_STOPPED) {
|
||||||
if (! rc_is_file(init)) {
|
if (! rc_exists (init)) {
|
||||||
free (init);
|
free (init);
|
||||||
free (svc);
|
free (svc);
|
||||||
return (false);
|
return (false);
|
||||||
@ -498,7 +498,7 @@ static pid_t _exec_service (const char *service, const char *arg)
|
|||||||
char *svc;
|
char *svc;
|
||||||
|
|
||||||
file = rc_service_resolve (service);
|
file = rc_service_resolve (service);
|
||||||
if (! rc_is_file (file)) {
|
if (! rc_exists (file)) {
|
||||||
rc_service_mark (service, RC_SERVICE_STOPPED);
|
rc_service_mark (service, RC_SERVICE_STOPPED);
|
||||||
free (file);
|
free (file);
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -67,7 +67,6 @@ librc_hidden_proto(rc_exists)
|
|||||||
librc_hidden_proto(rc_find_pids)
|
librc_hidden_proto(rc_find_pids)
|
||||||
librc_hidden_proto(rc_is_dir)
|
librc_hidden_proto(rc_is_dir)
|
||||||
librc_hidden_proto(rc_is_exec)
|
librc_hidden_proto(rc_is_exec)
|
||||||
librc_hidden_proto(rc_is_file)
|
|
||||||
librc_hidden_proto(rc_is_link)
|
librc_hidden_proto(rc_is_link)
|
||||||
librc_hidden_proto(rc_ls_dir)
|
librc_hidden_proto(rc_ls_dir)
|
||||||
librc_hidden_proto(rc_rm_dir)
|
librc_hidden_proto(rc_rm_dir)
|
||||||
|
7
src/rc.h
7
src/rc.h
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
//#include <stdio.h>
|
||||||
|
|
||||||
/*! @name Reserved runlevel names */
|
/*! @name Reserved runlevel names */
|
||||||
#define RC_LEVEL_SYSINIT "sysinit"
|
#define RC_LEVEL_SYSINIT "sysinit"
|
||||||
@ -463,11 +463,6 @@ bool rc_env_bool (const char *variable);
|
|||||||
* @return true if it exists, otherwise false */
|
* @return true if it exists, otherwise false */
|
||||||
bool rc_exists (const char *pathname);
|
bool rc_exists (const char *pathname);
|
||||||
|
|
||||||
/*! Check if the file is a real file
|
|
||||||
* @param pathname to check
|
|
||||||
* @return true if it's a real file, otherwise false */
|
|
||||||
bool rc_is_file (const char *pathname);
|
|
||||||
|
|
||||||
/*! Check if the file is a symbolic link or not
|
/*! Check if the file is a symbolic link or not
|
||||||
* @param pathname to check
|
* @param pathname to check
|
||||||
* @return true if it's a symbolic link, otherwise false */
|
* @return true if it's a symbolic link, otherwise false */
|
||||||
|
@ -17,7 +17,6 @@ global:
|
|||||||
rc_find_pids;
|
rc_find_pids;
|
||||||
rc_is_dir;
|
rc_is_dir;
|
||||||
rc_is_exec;
|
rc_is_exec;
|
||||||
rc_is_file;
|
|
||||||
rc_is_link;
|
rc_is_link;
|
||||||
rc_ls_dir;
|
rc_ls_dir;
|
||||||
rc_rm_dir;
|
rc_rm_dir;
|
||||||
|
@ -728,7 +728,7 @@ int start_stop_daemon (int argc, char **argv)
|
|||||||
tmp = rc_strcatpaths (ch_root, exec, (char *) NULL);
|
tmp = rc_strcatpaths (ch_root, exec, (char *) NULL);
|
||||||
else
|
else
|
||||||
tmp = exec;
|
tmp = exec;
|
||||||
if (! rc_is_file (tmp)) {
|
if (! rc_exists (tmp)) {
|
||||||
eerror ("%s: %s does not exist", applet, tmp);
|
eerror ("%s: %s does not exist", applet, tmp);
|
||||||
if (ch_root)
|
if (ch_root)
|
||||||
free (tmp);
|
free (tmp);
|
||||||
@ -754,7 +754,7 @@ int start_stop_daemon (int argc, char **argv)
|
|||||||
if (result < 1)
|
if (result < 1)
|
||||||
exit (result == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
exit (result == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||||
|
|
||||||
if (pidfile && rc_is_file (pidfile))
|
if (pidfile && rc_exists (pidfile))
|
||||||
unlink (pidfile);
|
unlink (pidfile);
|
||||||
|
|
||||||
if (svcname)
|
if (svcname)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user