And use proc_ prefix.
Change-Id: I555e71a71da3bcbb44f06334b876397578095421
Signed-off-by: WaLyong Cho <walyong.cho@samsung.com>
%{_includedir}/libsystem/dbus-util.h
%{_includedir}/libsystem/glib-util.h
%{_includedir}/libsystem/libsystem.h
+%{_includedir}/libsystem/proc.h
%{_libdir}/pkgconfig/libsystem.pc
%files -n libsystem-sd
libsystem/config-parser.h \
libsystem/dbus-util.h \
libsystem/glib-util.h \
- libsystem/libsystem.h
+ libsystem/libsystem.h \
+ libsystem/proc.h
lib_LTLIBRARIES += \
libsystem.la
int touch(const char *path);
/**
- * @defgroup PROC_GROUP proc group
- *
- * @brief A set utility library for /proc. Some of library functions
- * are only able to be successful root uid with security permissions.
- *
- * @{
- */
-
-/**
- * @brief Get string with operator from /proc/cmdline. If foo=bar is
- * included in /proc/cmdline and want to get the bar, then:
- * \code{.c}
- char *buf;
-
- cmdline_get_str(&buf, "foo=");
- * \endcode
- *
- * @param buf The value string is filled to here. This value has to be
- * free-ed by caller.
- * @param op An operator string.
- *
- * @return Result string. This value has to be free-ed by caller.
- */
-ssize_t cmdline_get_str(char **buf, const char *op);
-
-/**
- * @brief Get PID of process.
- *
- * @param pname Process name.
- *
- * @return PID on successful find. If not found, 0 is returned. And
- * -errno is returned on failure.
- */
-int pid_of(const char *pname);
-/**
- * @}
- */
-
-/**
* @brief Check mount entry. Multiple matches of conditoin are able to
* be set with mnt_fsname, mnt_dir, mnt_type or mnt_opts. If multiple
* matches are given, return true if a entry satisfied all matches.
#include "libsystem.h"
-/* In old kernel, this symbol maybe NOT */
-#ifndef TASK_COMM_LEN
-#define TASK_COMM_LEN 16
-#endif
-
-ssize_t cmdline_get_str(char **buf, const char *op) {
+ssize_t proc_cmdline_get_str(char **buf, const char *op) {
_cleanup_free_ char *cmdline = NULL;
char *s, *w, *state;
size_t l, ll;
return -ENOENT;
}
-int pid_of(const char *pname) {
+/* In old kernel, this symbol maybe NOT */
+#ifndef TASK_COMM_LEN
+#define TASK_COMM_LEN 16
+#endif
+
+int proc_pid_of(const char *pname) {
_cleanup_closedir_ DIR *dir = NULL;
struct dirent *de;
int r;
--- /dev/null
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/*
+ * libsystem
+ *
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file proc.h
+ *
+ * procfs utility library
+ *
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ */
+
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @defgroup PROC_GROUP proc group
+ *
+ * @brief A set utility library for /proc. Some of library functions
+ * are only able to be successful root uid with security permissions.
+ *
+ * @{
+ */
+
+/**
+ * @brief Get string with operator from /proc/cmdline. If foo=bar is
+ * included in /proc/cmdline and want to get the bar, then:
+ * \code{.c}
+ char *buf;
+
+ proc_cmdline_get_str(&buf, "foo=");
+ * \endcode
+ *
+ * @param buf The value string is filled to here. This value has to be
+ * free-ed by caller.
+ * @param op An operator string.
+ *
+ * @return Result string. This value has to be free-ed by caller.
+ */
+ssize_t proc_cmdline_get_str(char **buf, const char *op);
+
+/**
+ * @brief Get PID of process.
+ *
+ * @param pname Process name.
+ *
+ * @return PID on successful find. If not found, 0 is returned. And
+ * -errno is returned on failure.
+ */
+int proc_pid_of(const char *pname);
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif