rfkill.c revision da927ba997d68401563b927f92e6e40e021a8e5c
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2013 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include "util.h"
#include "mkdir.h"
#include "fileio.h"
#include "libudev.h"
#include "udev-util.h"
int r;
if (argc != 3) {
log_error("This program requires two arguments.");
return EXIT_FAILURE;
}
log_open();
umask(0022);
if (r < 0) {
log_error_errno(r, "Failed to create rfkill directory: %m");
return EXIT_FAILURE;
}
if (!udev) {
log_oom();
return EXIT_FAILURE;
}
errno = 0;
if (!device) {
if (errno != 0)
else
log_oom();
return EXIT_FAILURE;
}
if (!name) {
log_error("rfkill device has no name?");
return EXIT_FAILURE;
}
if (!escaped_name) {
log_oom();
return EXIT_FAILURE;
}
if (path_id) {
if (!escaped_path_id) {
log_oom();
return EXIT_FAILURE;
}
} else
if (!saved) {
log_oom();
return EXIT_FAILURE;
}
if (!shall_restore_state())
return EXIT_SUCCESS;
if (r < 0) {
if (r == -ENOENT)
return EXIT_SUCCESS;
return EXIT_FAILURE;
}
if (r < 0) {
log_error_errno(r, "Failed to write system attribute: %m");
return EXIT_FAILURE;
}
const char *value;
if (!value) {
log_error_errno(r, "Failed to read system attribute: %m");
return EXIT_FAILURE;
}
if (r < 0) {
return EXIT_FAILURE;
}
} else {
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}