- when receiving fd to lib from daemon, the kernel blocks fd by security check.
- change 90-gpio.rules name to 90-peripheral-io.rules
Change-Id: I5c75056e4d54fb667e6acdc7398f5f35ae9a3ff3
Signed-off-by: Segwon <segwon.han@samsung.com>
+++ /dev/null
-SUBSYSTEM=="gpio", KERNEL=="gpio*", ACTION=="add",\
- RUN+="/bin/chown root:system_fw /sys%p/value",\
- RUN+="/bin/chmod g+rw /sys%p/value",\
- RUN+="/bin/chsmack -a System /sys%p/value"
-SUBSYSTEM=="gpio", KERNEL=="gpio*", ACTION=="add",\
- RUN+="/bin/chown root:system_fw /sys%p/direction",\
- RUN+="/bin/chmod g+rw /sys%p/direction",\
- RUN+="/bin/chsmack -a System /sys%p/direction"
-SUBSYSTEM=="gpio", KERNEL=="gpio*", ACTION=="add",\
- RUN+="/bin/chown root:system_fw /sys%p/edge",\
- RUN+="/bin/chmod g+rw /sys%p/edge",\
- RUN+="/bin/chsmack -a System /sys%p/edge"
--- /dev/null
+SUBSYSTEM=="gpio", KERNEL=="gpio*", ACTION=="add",\
+ RUN+="/bin/chown root:root /sys%p/value",\
+ RUN+="/bin/chmod 0660 /sys%p/value",\
+ RUN+="/bin/chsmack -a * /sys%p/value"
+SUBSYSTEM=="gpio", KERNEL=="gpio*", ACTION=="add",\
+ RUN+="/bin/chown root:root /sys%p/direction",\
+ RUN+="/bin/chmod 0660 /sys%p/direction",\
+ RUN+="/bin/chsmack -a * /sys%p/direction"
+SUBSYSTEM=="gpio", KERNEL=="gpio*", ACTION=="add",\
+ RUN+="/bin/chown root:root /sys%p/edge",\
+ RUN+="/bin/chmod 0660 /sys%p/edge",\
+ RUN+="/bin/chsmack -a * /sys%p/edge"
+
+SUBSYSTEM=="i2c-dev", KERNEL=="i2c-*", ACTION=="add", \
+ MODE="0660", OWNER="root", GROUP="root", SECLABEL{smack}="*"
+
+SUBSYSTEM=="spidev", KERNEL=="spidev*.*", ACTION=="add", \
+ MODE="0660", OWNER="root", GROUP="root", SECLABEL{smack}="*"
Source1: %{name}.manifest
Source2: %{name}.service
Source3: %{name}.tmpfiles.conf
-Source4: 90-gpio.rules
+Source4: 90-peripheral-io.rules
BuildRequires: cmake
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(gio-2.0)
%{_bindir}/%{name}
%{_unitdir}/%{name}.service
%{_tmpfilesdir}/%{name}.conf
-/usr/lib/udev/rules.d/90-gpio.rules
+/usr/lib/udev/rules.d/90-peripheral-io.rules
%{_unitdir}/multi-user.target.wants/%{name}.service
/etc/peripheral-bus/*.ini
goto out;
}
- ret = peripheral_interface_gpio_export(pin);
+ ret = peripheral_handle_gpio_create(pin, &gpio_handle, user_data);
if (ret != PERIPHERAL_ERROR_NONE) {
- _E("Failed to export gpio");
+ _E("Failed to create gpio handle");
goto out;
}
- ret = peripheral_interface_gpio_fd_list_create(pin, &gpio_fd_list);
+ ret = peripheral_interface_gpio_export(pin);
if (ret != PERIPHERAL_ERROR_NONE) {
- _E("Failed to create gpio fd list");
- peripheral_interface_gpio_unexport(pin);
+ _E("Failed to export gpio");
+ peripheral_handle_gpio_destroy(gpio_handle);
goto out;
}
- ret = peripheral_handle_gpio_create(pin, &gpio_handle, user_data);
+ ret = peripheral_interface_gpio_fd_list_create(pin, &gpio_fd_list);
if (ret != PERIPHERAL_ERROR_NONE) {
- _E("Failed to create gpio handle");
+ _E("Failed to create gpio fd list");
peripheral_interface_gpio_unexport(pin);
+ peripheral_handle_gpio_destroy(gpio_handle);
goto out;
}
* limitations under the License.
*/
+#include <stdlib.h>
#include "peripheral_interface_pwm.h"
#include "peripheral_interface_common.h"
ret = close(fd);
IF_ERROR_RETURN(ret != 0);
+ snprintf(buf, MAX_BUF_LEN, "chsmack -a \"*\" /sys/class/pwm/pwmchip%d/pwm%d/period", chip, pin);
+ ret = system(buf);
+ if (ret != 0) {
+ _E("Failed to change period security label to read/write.");
+ return PERIPHERAL_ERROR_IO_ERROR;
+ }
+
+ snprintf(buf, MAX_BUF_LEN, "chsmack -a \"*\" /sys/class/pwm/pwmchip%d/pwm%d/duty_cycle", chip, pin);
+ ret = system(buf);
+ if (ret != 0) {
+ _E("Failed to change duty_cycle security label to read/write.");
+ return PERIPHERAL_ERROR_IO_ERROR;
+ }
+
+ snprintf(buf, MAX_BUF_LEN, "chsmack -a \"*\" /sys/class/pwm/pwmchip%d/pwm%d/polarity", chip, pin);
+ ret = system(buf);
+ if (ret != 0) {
+ _E("Failed to change polarity security label to read/write.");
+ return PERIPHERAL_ERROR_IO_ERROR;
+ }
+
+ snprintf(buf, MAX_BUF_LEN, "chsmack -a \"*\" /sys/class/pwm/pwmchip%d/pwm%d/enable", chip, pin);
+ ret = system(buf);
+ if (ret != 0) {
+ _E("Failed to change enable security label to read/write.");
+ return PERIPHERAL_ERROR_IO_ERROR;
+ }
+
return PERIPHERAL_ERROR_NONE;
}
char path[MAX_BUF_LEN] = {0};
char buf[MAX_BUF_LEN] = {0};
- _D("chip : %d, pin : %d", chip, pin);
-
snprintf(path, MAX_BUF_LEN, "/sys/class/pwm/pwmchip%d/unexport", chip);
fd = open(path, O_WRONLY);
IF_ERROR_RETURN(fd < 0);