diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-04-11 21:43:28 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-04-11 21:43:34 +0200 |
commit | 90ff9edfa9c5fcfa3a36d1653ff105e89b888e21 (patch) | |
tree | 780a2071f5072c8e8e044db741eb295c3f3ea2a7 /src/util/disk.c | |
parent | 3bcfe59f1ce533246bda271f00b3ee957cae304d (diff) | |
download | gnunet-90ff9edfa9c5fcfa3a36d1653ff105e89b888e21.tar.gz gnunet-90ff9edfa9c5fcfa3a36d1653ff105e89b888e21.zip |
fixing #6149
Diffstat (limited to 'src/util/disk.c')
-rw-r--r-- | src/util/disk.c | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/src/util/disk.c b/src/util/disk.c index b98c81e4b..9018aa955 100644 --- a/src/util/disk.c +++ b/src/util/disk.c | |||
@@ -1188,70 +1188,6 @@ GNUNET_DISK_file_change_owner (const char *filename, const char *user) | |||
1188 | 1188 | ||
1189 | 1189 | ||
1190 | /** | 1190 | /** |
1191 | * Lock a part of a file | ||
1192 | * | ||
1193 | * @param fh file handle | ||
1194 | * @param lock_start absolute position from where to lock | ||
1195 | * @param lock_end absolute position until where to lock | ||
1196 | * @param excl #GNUNET_YES for an exclusive lock | ||
1197 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
1198 | */ | ||
1199 | int | ||
1200 | GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, | ||
1201 | off_t lock_start, | ||
1202 | off_t lock_end, | ||
1203 | int excl) | ||
1204 | { | ||
1205 | if (fh == NULL) | ||
1206 | { | ||
1207 | errno = EINVAL; | ||
1208 | return GNUNET_SYSERR; | ||
1209 | } | ||
1210 | |||
1211 | struct flock fl; | ||
1212 | |||
1213 | memset (&fl, 0, sizeof(struct flock)); | ||
1214 | fl.l_type = excl ? F_WRLCK : F_RDLCK; | ||
1215 | fl.l_whence = SEEK_SET; | ||
1216 | fl.l_start = lock_start; | ||
1217 | fl.l_len = lock_end; | ||
1218 | |||
1219 | return fcntl (fh->fd, F_SETLK, &fl) != 0 ? GNUNET_SYSERR : GNUNET_OK; | ||
1220 | } | ||
1221 | |||
1222 | |||
1223 | /** | ||
1224 | * Unlock a part of a file | ||
1225 | * | ||
1226 | * @param fh file handle | ||
1227 | * @param unlock_start absolute position from where to unlock | ||
1228 | * @param unlock_end absolute position until where to unlock | ||
1229 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
1230 | */ | ||
1231 | int | ||
1232 | GNUNET_DISK_file_unlock (struct GNUNET_DISK_FileHandle *fh, | ||
1233 | off_t unlock_start, | ||
1234 | off_t unlock_end) | ||
1235 | { | ||
1236 | if (fh == NULL) | ||
1237 | { | ||
1238 | errno = EINVAL; | ||
1239 | return GNUNET_SYSERR; | ||
1240 | } | ||
1241 | |||
1242 | struct flock fl; | ||
1243 | |||
1244 | memset (&fl, 0, sizeof(struct flock)); | ||
1245 | fl.l_type = F_UNLCK; | ||
1246 | fl.l_whence = SEEK_SET; | ||
1247 | fl.l_start = unlock_start; | ||
1248 | fl.l_len = unlock_end; | ||
1249 | |||
1250 | return fcntl (fh->fd, F_SETLK, &fl) != 0 ? GNUNET_SYSERR : GNUNET_OK; | ||
1251 | } | ||
1252 | |||
1253 | |||
1254 | /** | ||
1255 | * Open a file. Note that the access permissions will only be | 1191 | * Open a file. Note that the access permissions will only be |
1256 | * used if a new file is created and if the underlying operating | 1192 | * used if a new file is created and if the underlying operating |
1257 | * system supports the given permissions. | 1193 | * system supports the given permissions. |