aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNeal Gompa <ngompa13@gmail.com>2017-12-30 12:19:16 -0500
committerNeal Gompa <ngompa13@gmail.com>2017-12-30 12:22:39 -0500
commitd54da94b818a0cf51352ba1f4cdeb857ebc92218 (patch)
treee5469d8c1a2cee28c5773349ea9544da179f934c /src
parentd465fd1adf0105bf43261e9340bd8f8997f01839 (diff)
parent7fa374712f6da22f97bce84fff2e4cd535e9ef8d (diff)
downloadinitscripts-d54da94b818a0cf51352ba1f4cdeb857ebc92218.tar
initscripts-d54da94b818a0cf51352ba1f4cdeb857ebc92218.tar.gz
initscripts-d54da94b818a0cf51352ba1f4cdeb857ebc92218.tar.bz2
initscripts-d54da94b818a0cf51352ba1f4cdeb857ebc92218.tar.xz
initscripts-d54da94b818a0cf51352ba1f4cdeb857ebc92218.zip
Merge tag '9.78' into distro/mga
Tag as 9.78
Diffstat (limited to 'src')
-rw-r--r--src/netreport.c4
-rw-r--r--src/rename_device.c44
-rw-r--r--src/usleep.15
-rw-r--r--src/usleep.c3
4 files changed, 42 insertions, 14 deletions
diff --git a/src/netreport.c b/src/netreport.c
index 31bfe2f6..204a77d7 100644
--- a/src/netreport.c
+++ b/src/netreport.c
@@ -34,7 +34,7 @@ usage(void) {
#define DEL 0
int main(int argc, char ** argv) {
int action = ADD;
- /* more than long enough for "/var/run/netreport/<pid>\0" */
+ /* more than long enough for "/run/netreport/<pid>\0" */
char netreport_name[64];
int netreport_file;
@@ -51,7 +51,7 @@ int main(int argc, char ** argv) {
}
snprintf(netreport_name, sizeof(netreport_name),
- "/var/run/netreport/%d", getppid());
+ "/run/netreport/%d", getppid());
if (action == ADD) {
netreport_file = open(netreport_name,
O_EXCL|O_CREAT|O_WRONLY|O_TRUNC|O_NOFOLLOW, 0);
diff --git a/src/rename_device.c b/src/rename_device.c
index d49205ed..6d6030eb 100644
--- a/src/rename_device.c
+++ b/src/rename_device.c
@@ -104,20 +104,40 @@ char *read_subchannels(char *path) {
#endif
+/*
+ * Taken from systemd:
+ * https://github.com/systemd/systemd/blob/master/src/basic/string-util.c#L49
+ */
+char* endswith(const char *s, const char *postfix) {
+ size_t sl, pl;
+
+ sl = strlen(s);
+ pl = strlen(postfix);
+
+ if (pl == 0)
+ return (char*) s + sl;
+
+ if (sl < pl)
+ return NULL;
+
+ if (memcmp(s + sl - pl, postfix, pl) != 0)
+ return NULL;
+
+ return (char*) s + sl - pl;
+}
+
int isCfg(const struct dirent *dent) {
- int len = strlen(dent->d_name);
-
- if (strncmp(dent->d_name,"ifcfg-",6))
- return 0;
- if (strstr(dent->d_name,"rpmnew") ||
- strstr(dent->d_name,"rpmsave") ||
- strstr(dent->d_name,"rpmorig"))
- return 0;
- if (dent->d_name[len-1] == '~')
- return 0;
- if (!strncmp(dent->d_name+len-4,".bak",4))
+ if (strncmp(dent->d_name, "ifcfg-",6) ||
+ endswith(dent->d_name, ".rpmnew") != NULL ||
+ endswith(dent->d_name, ".rpmsave") != NULL ||
+ endswith(dent->d_name, ".rpmorig") != NULL ||
+ endswith(dent->d_name, ".orig") != NULL ||
+ endswith(dent->d_name, ".old") != NULL ||
+ endswith(dent->d_name, ".bak") != NULL ||
+ endswith(dent->d_name, "~") != NULL)
return 0;
- return 1;
+ else
+ return 1;
}
static inline char *dequote(char *start, char *end) {
diff --git a/src/usleep.1 b/src/usleep.1
index 2d7520f7..30db2bad 100644
--- a/src/usleep.1
+++ b/src/usleep.1
@@ -7,6 +7,9 @@ usleep \- sleep some number of microseconds
.SH DESCRIPTION
.B usleep
sleeps some number of microseconds. The default is 1.
+.SH WARNING
+.B usleep
+has been deprecated, and will be removed in near future. Use sleep(1) instead.
.SH OPTIONS
\fI--usage\fP
Show short usage message.
@@ -23,3 +26,5 @@ on precision only to -4 or maybe -5.
Donald Barnes <djb@redhat.com>
.br
Erik Troan <ewt@redhat.com>
+.SH SEE ALSO
+sleep(1)
diff --git a/src/usleep.c b/src/usleep.c
index a5e7d9d7..e5e3077d 100644
--- a/src/usleep.c
+++ b/src/usleep.c
@@ -77,6 +77,9 @@ int main(int argc, char **argv) {
else count = strtoul(countStr, NULL, 0);
+ fprintf(stderr, "warning: usleep is deprecated, and will be removed in near future!\n"
+ "warning: use \"sleep %.7g\" instead...\n", count / 1e6);
+
usleep(count);
return 0;
}