public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Christian Ruppert" <idl0r@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/openrc:master commit in: src/includes/, src/rc/
Date: Thu, 26 Jan 2012 19:47:53 +0000 (UTC)	[thread overview]
Message-ID: <44019f6542885fd684c5113c7a5c06308a51102a.idl0r@gentoo> (raw)

commit:     44019f6542885fd684c5113c7a5c06308a51102a
Author:     Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Thu Jan 26 19:44:33 2012 +0000
Commit:     Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Thu Jan 26 19:46:31 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=44019f65

Add is_writable() function to check whether a path is writable or not

---
 src/includes/rc-misc.h |    7 +++++++
 src/rc/rc-misc.c       |    9 +++++++++
 2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/src/includes/rc-misc.h b/src/includes/rc-misc.h
index 773c4b9..18ed5b9 100644
--- a/src/includes/rc-misc.h
+++ b/src/includes/rc-misc.h
@@ -36,6 +36,7 @@
 #include <stdbool.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 
 #define RC_LEVEL_BOOT           "boot"
 #define RC_LEVEL_DEFAULT        "default"
@@ -166,6 +167,12 @@ int svc_lock(const char *);
 int svc_unlock(const char *, int);
 pid_t exec_service(const char *, const char *);
 
+/*
+ * Check whether path is writable or not,
+ * this also works properly with read-only filesystems
+ */
+int is_writable(const char *);
+
 #define service_start(service) exec_service(service, "start");
 #define service_stop(service)  exec_service(service, "stop");
 

diff --git a/src/rc/rc-misc.c b/src/rc/rc-misc.c
index a06ff08..27397d7 100644
--- a/src/rc/rc-misc.c
+++ b/src/rc/rc-misc.c
@@ -331,3 +331,12 @@ parse_mode(mode_t *mode, char *text)
 	errno = EINVAL;
 	return -1;
 }
+
+int
+is_writable(const char *path)
+{
+	if (access(path, W_OK) == 0)
+		return 1;
+
+	return 0;
+}



             reply	other threads:[~2012-01-26 19:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-26 19:47 Christian Ruppert [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-12-08 18:43 [gentoo-commits] proj/openrc:master commit in: src/includes/, src/rc/ William Hubbs
2016-01-12 20:12 William Hubbs
2016-01-12 20:12 William Hubbs
2016-01-12 20:12 William Hubbs
2016-01-19  6:12 William Hubbs
2017-08-23 19:38 William Hubbs
2018-05-18 22:27 William Hubbs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44019f6542885fd684c5113c7a5c06308a51102a.idl0r@gentoo \
    --to=idl0r@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox