2 * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
5 * JiHye Kim <jihye1128.kim@samsung.com>
6 * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
23 * 2012-03-05 Dohyung Hong <don.hong@samsung.com> Changed package name for the maru board of emulator
24 * 2014-11-05 Jinhyung Choi <jinhyung2.choi@samsung.com> Changed package name for the emulator
32 #include <devman_plugin_intf.h>
34 #include <sys/types.h>
37 #define EXPORT_API __attribute__((visibility("default")))
43 int sys_check_node(char *path)
47 fd = open(path, O_RDONLY);
56 int sys_get_node(char *path, char *node)
58 if (0 >= snprintf(node, strlen(path) + 1, "%s", path))
64 int sys_get_int_wo_convert(char *path, int *value)
68 fd = open(path, O_RDONLY);
73 if (0 > read(fd, value, sizeof(int))) {
82 int sys_set_int_wo_convert(char *path, int value)
86 fd = open(path, O_WRONLY);
91 if (0 > write(fd, &value, sizeof(int))) {
100 static int sys_read_buf(char *file, char *buf)
105 fd = open(file, O_RDONLY);
110 r = read(fd, buf, BUFF_MAX - 1);
111 if ((r >= 0) && (r < BUFF_MAX))
122 static int sys_write_buf(char *file, char *buf)
127 fd = open(file, O_WRONLY);
132 r = write(fd, buf, strlen(buf));
141 int sys_get_int(char *fname, int *val)
145 if (sys_read_buf(fname, buf) == 0) {
154 int sys_get_str(char *fname, char* str)
156 char buf[BUFF_MAX] = {0};
158 if (sys_read_buf(fname, buf) == 0) {
159 memset(str, 0, strlen(buf) + 1);
160 memcpy(str, buf, strlen(buf));
167 int sys_set_int(char *fname, int val)
171 snprintf(buf, sizeof(buf), "%d", val);
173 if (sys_write_buf(fname, buf) == 0)
179 int sys_set_str(char *fname, char *val)
184 if (sys_write_buf(fname, val) == 0)