backlight.c revision ef5bfcf668e6029faa78534dfeb2591df854cdef
/*-*- 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 <libudev.h>
#include "util.h"
#include "mkdir.h"
#include "fileio.h"
int r;
if (argc != 3) {
log_error("This program requires two arguments.");
return EXIT_FAILURE;
}
log_open();
umask(0022);
if (r < 0) {
goto finish;
}
if (!udev) {
r = log_oom();
goto finish;
}
errno = 0;
if (!device) {
if (errno != 0) {
log_error("Failed to get backlight device: %m");
r = -errno;
} else
r = log_oom();
goto finish;
}
r = -ENODEV;
goto finish;
}
if (!saved) {
r = log_oom();
goto finish;
}
if (r < 0) {
if (r == -ENOENT) {
r = 0;
goto finish;
}
goto finish;
}
if (r < 0) {
goto finish;
}
const char *value;
if (!value) {
goto finish;
}
if (r < 0) {
goto finish;
}
} else {
r = -EINVAL;
goto finish;
}
if (device)
if (udev)
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}