wdenk | 34b613e | 2002-12-17 01:51:00 +0000 | [diff] [blame] | 1 | /* |
Grant Erickson | 73a4e5e | 2008-05-06 20:16:15 -0700 | [diff] [blame] | 2 | * (C) Copyright 2000-2008 |
wdenk | 34b613e | 2002-12-17 01:51:00 +0000 | [diff] [blame] | 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
Wolfgang Denk | bd8ec7e | 2013-10-07 13:07:26 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | 34b613e | 2002-12-17 01:51:00 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | /* |
wdenk | ef5fe75 | 2003-03-12 10:41:04 +0000 | [diff] [blame] | 9 | * Command line user interface to firmware (=U-Boot) environment. |
wdenk | 34b613e | 2002-12-17 01:51:00 +0000 | [diff] [blame] | 10 | * |
| 11 | * Implements: |
Marek Vasut | 05ed2a5 | 2014-03-05 19:59:52 +0100 | [diff] [blame] | 12 | * fw_printenv [ -a key ] [[ -n name ] | [ name ... ]] |
Grant Erickson | 73a4e5e | 2008-05-06 20:16:15 -0700 | [diff] [blame] | 13 | * - prints the value of a single environment variable |
| 14 | * "name", the ``name=value'' pairs of one or more |
| 15 | * environment variables "name", or the whole |
| 16 | * environment if no names are specified. |
Marek Vasut | 05ed2a5 | 2014-03-05 19:59:52 +0100 | [diff] [blame] | 17 | * fw_setenv [ -a key ] name [ value ... ] |
wdenk | 34b613e | 2002-12-17 01:51:00 +0000 | [diff] [blame] | 18 | * - If a name without any values is given, the variable |
| 19 | * with this name is deleted from the environment; |
| 20 | * otherwise, all "value" arguments are concatenated, |
Grant Erickson | 73a4e5e | 2008-05-06 20:16:15 -0700 | [diff] [blame] | 21 | * separated by single blank characters, and the |
wdenk | 34b613e | 2002-12-17 01:51:00 +0000 | [diff] [blame] | 22 | * resulting string is assigned to the environment |
| 23 | * variable "name" |
Marek Vasut | 05ed2a5 | 2014-03-05 19:59:52 +0100 | [diff] [blame] | 24 | * |
| 25 | * If '-a key' is specified, the env block is encrypted with AES 128 CBC. |
| 26 | * The 'key' argument is in the format of 32 hexadecimal numbers (16 bytes |
| 27 | * of AES key), eg. '-a aabbccddeeff00112233445566778899'. |
wdenk | 34b613e | 2002-12-17 01:51:00 +0000 | [diff] [blame] | 28 | */ |
| 29 | |
Joe Hershberger | 3f1f175 | 2012-10-03 09:38:49 +0000 | [diff] [blame] | 30 | #include <fcntl.h> |
| 31 | #include <getopt.h> |
wdenk | 34b613e | 2002-12-17 01:51:00 +0000 | [diff] [blame] | 32 | #include <stdio.h> |
| 33 | #include <string.h> |
| 34 | #include <stdlib.h> |
Joe Hershberger | 3f1f175 | 2012-10-03 09:38:49 +0000 | [diff] [blame] | 35 | #include <sys/file.h> |
| 36 | #include <unistd.h> |
wdenk | 34b613e | 2002-12-17 01:51:00 +0000 | [diff] [blame] | 37 | #include "fw_env.h" |
| 38 | |
Andreas Fenkart | 9b5a28b | 2015-12-09 13:13:27 +0100 | [diff] [blame] | 39 | #define CMD_PRINTENV "fw_printenv" |
wdenk | 34b613e | 2002-12-17 01:51:00 +0000 | [diff] [blame] | 40 | #define CMD_SETENV "fw_setenv" |
Andreas Fenkart | 9b5a28b | 2015-12-09 13:13:27 +0100 | [diff] [blame] | 41 | static int do_printenv; |
wdenk | 34b613e | 2002-12-17 01:51:00 +0000 | [diff] [blame] | 42 | |
Stefano Babic | ada628b | 2010-05-24 12:08:16 +0200 | [diff] [blame] | 43 | static struct option long_options[] = { |
Andreas Fenkart | 9b5a28b | 2015-12-09 13:13:27 +0100 | [diff] [blame] | 44 | {"aes", required_argument, NULL, 'a'}, |
| 45 | {"config", required_argument, NULL, 'c'}, |
Stefano Babic | ada628b | 2010-05-24 12:08:16 +0200 | [diff] [blame] | 46 | {"help", no_argument, NULL, 'h'}, |
Andreas Fenkart | 9b5a28b | 2015-12-09 13:13:27 +0100 | [diff] [blame] | 47 | {"script", required_argument, NULL, 's'}, |
| 48 | {"noheader", required_argument, NULL, 'n'}, |
B, Ravi | ccb293f | 2016-09-26 18:24:08 +0530 | [diff] [blame] | 49 | {"lock", required_argument, NULL, 'l'}, |
Stefano Babic | ada628b | 2010-05-24 12:08:16 +0200 | [diff] [blame] | 50 | {NULL, 0, NULL, 0} |
| 51 | }; |
| 52 | |
Andreas Fenkart | 2437190 | 2016-04-05 23:13:42 +0200 | [diff] [blame] | 53 | static struct env_opts env_opts; |
| 54 | |
| 55 | /* setenv options */ |
| 56 | static int noheader; |
| 57 | |
| 58 | /* getenv options */ |
| 59 | static char *script_file; |
| 60 | |
Andreas Fenkart | 9b5a28b | 2015-12-09 13:13:27 +0100 | [diff] [blame] | 61 | void usage_printenv(void) |
Stefano Babic | ada628b | 2010-05-24 12:08:16 +0200 | [diff] [blame] | 62 | { |
| 63 | |
Andreas Fenkart | 9b5a28b | 2015-12-09 13:13:27 +0100 | [diff] [blame] | 64 | fprintf(stderr, |
| 65 | "Usage: fw_printenv [OPTIONS]... [VARIABLE]...\n" |
| 66 | "Print variables from U-Boot environment\n" |
| 67 | "\n" |
| 68 | " -h, --help print this help.\n" |
| 69 | #ifdef CONFIG_ENV_AES |
| 70 | " -a, --aes aes key to access environment\n" |
Michael Heimpold | 211e17b | 2015-10-27 22:34:49 +0100 | [diff] [blame] | 71 | #endif |
Andreas Fenkart | 9b5a28b | 2015-12-09 13:13:27 +0100 | [diff] [blame] | 72 | #ifdef CONFIG_FILE |
| 73 | " -c, --config configuration file, default:" CONFIG_FILE "\n" |
| 74 | #endif |
| 75 | " -n, --noheader do not repeat variable name in output\n" |
B, Ravi | ccb293f | 2016-09-26 18:24:08 +0530 | [diff] [blame] | 76 | " -l, --lock lock node, default:/var/lock\n" |
Andreas Fenkart | 9b5a28b | 2015-12-09 13:13:27 +0100 | [diff] [blame] | 77 | "\n"); |
| 78 | } |
| 79 | |
| 80 | void usage_setenv(void) |
| 81 | { |
| 82 | fprintf(stderr, |
| 83 | "Usage: fw_setenv [OPTIONS]... [VARIABLE]...\n" |
| 84 | "Modify variables in U-Boot environment\n" |
| 85 | "\n" |
| 86 | " -h, --help print this help.\n" |
| 87 | #ifdef CONFIG_ENV_AES |
| 88 | " -a, --aes aes key to access environment\n" |
| 89 | #endif |
| 90 | #ifdef CONFIG_FILE |
| 91 | " -c, --config configuration file, default:" CONFIG_FILE "\n" |
| 92 | #endif |
B, Ravi | ccb293f | 2016-09-26 18:24:08 +0530 | [diff] [blame] | 93 | " -l, --lock lock node, default:/var/lock\n" |
Andreas Fenkart | 9b5a28b | 2015-12-09 13:13:27 +0100 | [diff] [blame] | 94 | " -s, --script batch mode to minimize writes\n" |
| 95 | "\n" |
| 96 | "Examples:\n" |
| 97 | " fw_setenv foo bar set variable foo equal bar\n" |
| 98 | " fw_setenv foo clear variable foo\n" |
| 99 | " fw_setenv --script file run batch script\n" |
Stefano Babic | ada628b | 2010-05-24 12:08:16 +0200 | [diff] [blame] | 100 | "\n" |
Andreas Fenkart | 9b5a28b | 2015-12-09 13:13:27 +0100 | [diff] [blame] | 101 | "Script Syntax:\n" |
| 102 | " key [space] value\n" |
Vagrant Cascadian | 3464566 | 2016-03-15 12:11:12 -0700 | [diff] [blame] | 103 | " lines starting with '#' are treated as comment\n" |
Stefano Babic | ada628b | 2010-05-24 12:08:16 +0200 | [diff] [blame] | 104 | "\n" |
Andreas Fenkart | 9b5a28b | 2015-12-09 13:13:27 +0100 | [diff] [blame] | 105 | " A variable without value will be deleted. Any number of spaces are\n" |
| 106 | " allowed between key and value. Space inside of the value is treated\n" |
| 107 | " as part of the value itself.\n" |
| 108 | "\n" |
| 109 | "Script Example:\n" |
| 110 | " netdev eth0\n" |
| 111 | " kernel_addr 400000\n" |
| 112 | " foo empty empty empty empty empty empty\n" |
| 113 | " bar\n" |
| 114 | "\n"); |
Stefano Babic | ada628b | 2010-05-24 12:08:16 +0200 | [diff] [blame] | 115 | } |
| 116 | |
Andreas Fenkart | 6726fc4 | 2015-12-09 13:13:26 +0100 | [diff] [blame] | 117 | static void parse_common_args(int argc, char *argv[]) |
wdenk | 34b613e | 2002-12-17 01:51:00 +0000 | [diff] [blame] | 118 | { |
Stefano Babic | ada628b | 2010-05-24 12:08:16 +0200 | [diff] [blame] | 119 | int c; |
wdenk | 34b613e | 2002-12-17 01:51:00 +0000 | [diff] [blame] | 120 | |
Andreas Fenkart | aa01f8d | 2015-12-09 13:13:24 +0100 | [diff] [blame] | 121 | #ifdef CONFIG_FILE |
Andreas Fenkart | 2437190 | 2016-04-05 23:13:42 +0200 | [diff] [blame] | 122 | env_opts.config_file = CONFIG_FILE; |
Andreas Fenkart | aa01f8d | 2015-12-09 13:13:24 +0100 | [diff] [blame] | 123 | #endif |
| 124 | |
B, Ravi | ccb293f | 2016-09-26 18:24:08 +0530 | [diff] [blame] | 125 | while ((c = getopt_long(argc, argv, ":a:c:l:h", long_options, NULL)) != |
Andreas Fenkart | 6726fc4 | 2015-12-09 13:13:26 +0100 | [diff] [blame] | 126 | EOF) { |
Stefano Babic | ada628b | 2010-05-24 12:08:16 +0200 | [diff] [blame] | 127 | switch (c) { |
Marek Vasut | 05ed2a5 | 2014-03-05 19:59:52 +0100 | [diff] [blame] | 128 | case 'a': |
Andreas Fenkart | 2437190 | 2016-04-05 23:13:42 +0200 | [diff] [blame] | 129 | if (parse_aes_key(optarg, env_opts.aes_key)) { |
Andreas Fenkart | aa01f8d | 2015-12-09 13:13:24 +0100 | [diff] [blame] | 130 | fprintf(stderr, "AES key parse error\n"); |
Andreas Fenkart | 6726fc4 | 2015-12-09 13:13:26 +0100 | [diff] [blame] | 131 | exit(EXIT_FAILURE); |
Andreas Fenkart | aa01f8d | 2015-12-09 13:13:24 +0100 | [diff] [blame] | 132 | } |
Andreas Fenkart | 2437190 | 2016-04-05 23:13:42 +0200 | [diff] [blame] | 133 | env_opts.aes_flag = 1; |
Marek Vasut | 05ed2a5 | 2014-03-05 19:59:52 +0100 | [diff] [blame] | 134 | break; |
Andreas Fenkart | aa01f8d | 2015-12-09 13:13:24 +0100 | [diff] [blame] | 135 | #ifdef CONFIG_FILE |
Michael Heimpold | 211e17b | 2015-10-27 22:34:49 +0100 | [diff] [blame] | 136 | case 'c': |
Andreas Fenkart | 2437190 | 2016-04-05 23:13:42 +0200 | [diff] [blame] | 137 | env_opts.config_file = optarg; |
Michael Heimpold | 211e17b | 2015-10-27 22:34:49 +0100 | [diff] [blame] | 138 | break; |
Andreas Fenkart | aa01f8d | 2015-12-09 13:13:24 +0100 | [diff] [blame] | 139 | #endif |
B, Ravi | ccb293f | 2016-09-26 18:24:08 +0530 | [diff] [blame] | 140 | case 'l': |
| 141 | env_opts.lockname = optarg; |
| 142 | break; |
Andreas Fenkart | 6726fc4 | 2015-12-09 13:13:26 +0100 | [diff] [blame] | 143 | case 'h': |
Andreas Fenkart | 9b5a28b | 2015-12-09 13:13:27 +0100 | [diff] [blame] | 144 | do_printenv ? usage_printenv() : usage_setenv(); |
Andreas Fenkart | 6726fc4 | 2015-12-09 13:13:26 +0100 | [diff] [blame] | 145 | exit(EXIT_SUCCESS); |
| 146 | break; |
| 147 | default: |
| 148 | /* ignore unknown options */ |
| 149 | break; |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | /* Reset getopt for the next pass. */ |
| 154 | opterr = 1; |
| 155 | optind = 1; |
| 156 | } |
| 157 | |
| 158 | int parse_printenv_args(int argc, char *argv[]) |
| 159 | { |
| 160 | int c; |
| 161 | |
| 162 | parse_common_args(argc, argv); |
| 163 | |
B, Ravi | ccb293f | 2016-09-26 18:24:08 +0530 | [diff] [blame] | 164 | while ((c = getopt_long(argc, argv, "a:c:ns:l:h", long_options, NULL)) |
| 165 | != EOF) { |
Andreas Fenkart | 6726fc4 | 2015-12-09 13:13:26 +0100 | [diff] [blame] | 166 | switch (c) { |
Daniel Hobi | 6c55426 | 2010-09-15 19:46:26 +0200 | [diff] [blame] | 167 | case 'n': |
Andreas Fenkart | 2437190 | 2016-04-05 23:13:42 +0200 | [diff] [blame] | 168 | noheader = 1; |
Daniel Hobi | 6c55426 | 2010-09-15 19:46:26 +0200 | [diff] [blame] | 169 | break; |
Andreas Fenkart | 6726fc4 | 2015-12-09 13:13:26 +0100 | [diff] [blame] | 170 | case 'a': |
| 171 | case 'c': |
Andreas Fenkart | 33e9177 | 2015-12-09 13:13:23 +0100 | [diff] [blame] | 172 | case 'h': |
B, Ravi | ccb293f | 2016-09-26 18:24:08 +0530 | [diff] [blame] | 173 | case 'l': |
Andreas Fenkart | 6726fc4 | 2015-12-09 13:13:26 +0100 | [diff] [blame] | 174 | /* ignore common options */ |
Andreas Fenkart | 33e9177 | 2015-12-09 13:13:23 +0100 | [diff] [blame] | 175 | break; |
| 176 | default: /* '?' */ |
Andreas Fenkart | 9b5a28b | 2015-12-09 13:13:27 +0100 | [diff] [blame] | 177 | usage_printenv(); |
Andreas Fenkart | 33e9177 | 2015-12-09 13:13:23 +0100 | [diff] [blame] | 178 | exit(EXIT_FAILURE); |
| 179 | break; |
| 180 | } |
| 181 | } |
| 182 | return 0; |
| 183 | } |
| 184 | |
| 185 | int parse_setenv_args(int argc, char *argv[]) |
| 186 | { |
| 187 | int c; |
| 188 | |
Andreas Fenkart | 6726fc4 | 2015-12-09 13:13:26 +0100 | [diff] [blame] | 189 | parse_common_args(argc, argv); |
Andreas Fenkart | aa01f8d | 2015-12-09 13:13:24 +0100 | [diff] [blame] | 190 | |
B, Ravi | ccb293f | 2016-09-26 18:24:08 +0530 | [diff] [blame] | 191 | while ((c = getopt_long(argc, argv, "a:c:ns:l:h", long_options, NULL)) |
| 192 | != EOF) { |
Andreas Fenkart | 33e9177 | 2015-12-09 13:13:23 +0100 | [diff] [blame] | 193 | switch (c) { |
Stefano Babic | ada628b | 2010-05-24 12:08:16 +0200 | [diff] [blame] | 194 | case 's': |
Andreas Fenkart | 2437190 | 2016-04-05 23:13:42 +0200 | [diff] [blame] | 195 | script_file = optarg; |
Stefano Babic | ada628b | 2010-05-24 12:08:16 +0200 | [diff] [blame] | 196 | break; |
Andreas Fenkart | 6726fc4 | 2015-12-09 13:13:26 +0100 | [diff] [blame] | 197 | case 'a': |
| 198 | case 'c': |
Stefano Babic | ada628b | 2010-05-24 12:08:16 +0200 | [diff] [blame] | 199 | case 'h': |
B, Ravi | ccb293f | 2016-09-26 18:24:08 +0530 | [diff] [blame] | 200 | case 'l': |
Andreas Fenkart | 6726fc4 | 2015-12-09 13:13:26 +0100 | [diff] [blame] | 201 | /* ignore common options */ |
Andreas Fenkart | 33e9177 | 2015-12-09 13:13:23 +0100 | [diff] [blame] | 202 | break; |
Daniel Hobi | 6a20a32 | 2010-09-16 14:36:09 +0200 | [diff] [blame] | 203 | default: /* '?' */ |
Andreas Fenkart | 9b5a28b | 2015-12-09 13:13:27 +0100 | [diff] [blame] | 204 | usage_setenv(); |
Andreas Fenkart | 33e9177 | 2015-12-09 13:13:23 +0100 | [diff] [blame] | 205 | exit(EXIT_FAILURE); |
| 206 | break; |
Stefano Babic | ada628b | 2010-05-24 12:08:16 +0200 | [diff] [blame] | 207 | } |
| 208 | } |
Andreas Fenkart | 33e9177 | 2015-12-09 13:13:23 +0100 | [diff] [blame] | 209 | return 0; |
| 210 | } |
| 211 | |
| 212 | int main(int argc, char *argv[]) |
| 213 | { |
B, Ravi | ccb293f | 2016-09-26 18:24:08 +0530 | [diff] [blame] | 214 | char *lockname = "/var/lock/" CMD_PRINTENV ".lock"; |
Andreas Fenkart | 33e9177 | 2015-12-09 13:13:23 +0100 | [diff] [blame] | 215 | int lockfd = -1; |
| 216 | int retval = EXIT_SUCCESS; |
Andreas Fenkart | 9b5a28b | 2015-12-09 13:13:27 +0100 | [diff] [blame] | 217 | char *_cmdname; |
Andreas Fenkart | 33e9177 | 2015-12-09 13:13:23 +0100 | [diff] [blame] | 218 | |
Andreas Fenkart | 9b5a28b | 2015-12-09 13:13:27 +0100 | [diff] [blame] | 219 | _cmdname = *argv; |
| 220 | if (strrchr(_cmdname, '/') != NULL) |
| 221 | _cmdname = strrchr(_cmdname, '/') + 1; |
Stefano Babic | ada628b | 2010-05-24 12:08:16 +0200 | [diff] [blame] | 222 | |
Andreas Fenkart | 9b5a28b | 2015-12-09 13:13:27 +0100 | [diff] [blame] | 223 | if (strcmp(_cmdname, CMD_PRINTENV) == 0) { |
| 224 | do_printenv = 1; |
| 225 | } else if (strcmp(_cmdname, CMD_SETENV) == 0) { |
| 226 | do_printenv = 0; |
Andreas Fenkart | 33e9177 | 2015-12-09 13:13:23 +0100 | [diff] [blame] | 227 | } else { |
| 228 | fprintf(stderr, |
| 229 | "Identity crisis - may be called as `%s' or as `%s' but not as `%s'\n", |
Andreas Fenkart | 9b5a28b | 2015-12-09 13:13:27 +0100 | [diff] [blame] | 230 | CMD_PRINTENV, CMD_SETENV, _cmdname); |
Andreas Fenkart | 33e9177 | 2015-12-09 13:13:23 +0100 | [diff] [blame] | 231 | exit(EXIT_FAILURE); |
| 232 | } |
| 233 | |
Andreas Fenkart | 9b5a28b | 2015-12-09 13:13:27 +0100 | [diff] [blame] | 234 | if (do_printenv) { |
| 235 | if (parse_printenv_args(argc, argv)) |
| 236 | exit(EXIT_FAILURE); |
| 237 | } else { |
| 238 | if (parse_setenv_args(argc, argv)) |
| 239 | exit(EXIT_FAILURE); |
| 240 | } |
| 241 | |
Andreas Fenkart | 14908ef | 2015-12-09 13:13:25 +0100 | [diff] [blame] | 242 | /* shift parsed flags, jump to non-option arguments */ |
| 243 | argc -= optind; |
| 244 | argv += optind; |
| 245 | |
B, Ravi | ccb293f | 2016-09-26 18:24:08 +0530 | [diff] [blame] | 246 | if (env_opts.lockname) { |
| 247 | lockname = malloc(sizeof(env_opts.lockname) + |
| 248 | sizeof(CMD_PRINTENV) + 10); |
| 249 | if (!lockname) { |
| 250 | fprintf(stderr, "Unable allocate memory"); |
| 251 | exit(EXIT_FAILURE); |
| 252 | } |
| 253 | |
| 254 | sprintf(lockname, "%s/%s.lock", |
| 255 | env_opts.lockname, CMD_PRINTENV); |
| 256 | } |
| 257 | |
Andreas Fenkart | 33e9177 | 2015-12-09 13:13:23 +0100 | [diff] [blame] | 258 | lockfd = open(lockname, O_WRONLY | O_CREAT | O_TRUNC, 0666); |
| 259 | if (-1 == lockfd) { |
| 260 | fprintf(stderr, "Error opening lock file %s\n", lockname); |
| 261 | return EXIT_FAILURE; |
| 262 | } |
| 263 | |
| 264 | if (-1 == flock(lockfd, LOCK_EX)) { |
| 265 | fprintf(stderr, "Error locking file %s\n", lockname); |
| 266 | close(lockfd); |
| 267 | return EXIT_FAILURE; |
| 268 | } |
| 269 | |
Andreas Fenkart | 9b5a28b | 2015-12-09 13:13:27 +0100 | [diff] [blame] | 270 | if (do_printenv) { |
Andreas Fenkart | 2437190 | 2016-04-05 23:13:42 +0200 | [diff] [blame] | 271 | if (fw_printenv(argc, argv, noheader, &env_opts) != 0) |
Joe Hershberger | 3f1f175 | 2012-10-03 09:38:49 +0000 | [diff] [blame] | 272 | retval = EXIT_FAILURE; |
Andreas Fenkart | 9b5a28b | 2015-12-09 13:13:27 +0100 | [diff] [blame] | 273 | } else { |
Andreas Fenkart | 2437190 | 2016-04-05 23:13:42 +0200 | [diff] [blame] | 274 | if (!script_file) { |
| 275 | if (fw_setenv(argc, argv, &env_opts) != 0) |
Joe Hershberger | 3f1f175 | 2012-10-03 09:38:49 +0000 | [diff] [blame] | 276 | retval = EXIT_FAILURE; |
Stefano Babic | ada628b | 2010-05-24 12:08:16 +0200 | [diff] [blame] | 277 | } else { |
Andreas Fenkart | 2437190 | 2016-04-05 23:13:42 +0200 | [diff] [blame] | 278 | if (fw_parse_script(script_file, &env_opts) != 0) |
Joe Hershberger | 3f1f175 | 2012-10-03 09:38:49 +0000 | [diff] [blame] | 279 | retval = EXIT_FAILURE; |
Stefano Babic | ada628b | 2010-05-24 12:08:16 +0200 | [diff] [blame] | 280 | } |
wdenk | 34b613e | 2002-12-17 01:51:00 +0000 | [diff] [blame] | 281 | } |
| 282 | |
B, Ravi | ccb293f | 2016-09-26 18:24:08 +0530 | [diff] [blame] | 283 | if (env_opts.lockname) |
| 284 | free(lockname); |
| 285 | |
Joe Hershberger | 3f1f175 | 2012-10-03 09:38:49 +0000 | [diff] [blame] | 286 | flock(lockfd, LOCK_UN); |
| 287 | close(lockfd); |
| 288 | return retval; |
wdenk | 34b613e | 2002-12-17 01:51:00 +0000 | [diff] [blame] | 289 | } |