[Getdata-commits] SF.net SVN: getdata:[929] trunk/getdata
Scientific Database Format
Brought to you by:
ketiltrout
|
From: <ket...@us...> - 2014-10-17 01:13:49
|
Revision: 929
http://sourceforge.net/p/getdata/code/929
Author: ketiltrout
Date: 2014-10-17 01:13:36 +0000 (Fri, 17 Oct 2014)
Log Message:
-----------
Ignore GD_RDONLY if creating a dirfile.
Modified Paths:
--------------
trunk/getdata/ChangeLog
trunk/getdata/NEWS
trunk/getdata/man/gd_cbopen.3
trunk/getdata/src/open.c
trunk/getdata/test/Makefile.am
trunk/getdata/test/creat_rdonly.c
Added Paths:
-----------
trunk/getdata/test/creat_rdonly_exists.c
Property Changed:
----------------
trunk/getdata/test/
Modified: trunk/getdata/ChangeLog
===================================================================
--- trunk/getdata/ChangeLog 2014-10-16 23:26:40 UTC (rev 928)
+++ trunk/getdata/ChangeLog 2014-10-17 01:13:36 UTC (rev 929)
@@ -1,3 +1,8 @@
+2014-10-16 D. V. Wiebe <g et...@ke...> svn:929
+ * src/open.c (_GD_CreateDirfile): Force GD_RDWR when creating a dirfile.
+ * test/creat_rdonly.c: Updated.
+ * test/creat_rdonly_exists.c: Added.
+
2014-10-16 D. V. Wiebe <g et...@ke...> svn:928
* bindings/make_parameters.c: Replace numeric type literals with CPP macros
for legibility.
Modified: trunk/getdata/NEWS
===================================================================
--- trunk/getdata/NEWS 2014-10-16 23:26:40 UTC (rev 928)
+++ trunk/getdata/NEWS 2014-10-17 01:13:36 UTC (rev 929)
@@ -30,6 +30,11 @@
gzip-encoded data works. See the gzip discussion in the 0.8.0 section below
for important notes.
+ * A newly-created dirfile is now always opened in read-write mode, ignoring the
+ access mode specified in the call. Previously, specifying both GD_RDONLY and
+ GD_CREAT in open calls would result in an access mode (GD_E_ACCMODE) error if
+ the dirfile didn't already exist.
+
* BUG FIX: In addition to the addition of write support mentioned above, a
number of problems with reading LZMA files has been fixed, which should
result in fewer segmentaion faults.
Modified: trunk/getdata/man/gd_cbopen.3
===================================================================
--- trunk/getdata/man/gd_cbopen.3 2014-10-16 23:26:40 UTC (rev 928)
+++ trunk/getdata/man/gd_cbopen.3 2014-10-17 01:13:36 UTC (rev 929)
@@ -118,6 +118,13 @@
An empty dirfile will be created, if one does not already exist. This will
create both the dirfile directory and an empty format specification file called
.IR format .
+If the call creates a dirfile, then the specified access mode is ignored: a
+newly-created DIRFILE is always opened with access mode
+.BR GD_RDWR ,
+even if
+.B GD_RDONLY
+had been specified.
+
The directory will have have mode
.BR S_IRWXU " | " S_IRWXG " | " S_IRWXO
(0777), modified by the caller's umask value (see
@@ -127,7 +134,6 @@
file will have mode
.BR S_IRUSR " | " S_IWUSR " | " S_IRGRP " | " S_IWGRP " | " S_IROTH " | " S_IWOTH
(0666), also modified by the caller's umask.
-
The owner of the dirfile directory and
.I format
file will be the effective user ID of the caller. Group ownership follows the
@@ -629,9 +635,7 @@
be internally flagged as invalid. Possible error values are:
.TP 8
.B GD_E_ACCMODE
-The library was asked to create or truncate a dirfile opened read-only (i.e.
-.B GD_CREAT
-or
+The library was asked to truncate a dirfile opened read-only (i.e.
.B GD_TRUNC
was specified in
.I flags
Modified: trunk/getdata/src/open.c
===================================================================
--- trunk/getdata/src/open.c 2014-10-16 23:26:40 UTC (rev 928)
+++ trunk/getdata/src/open.c 2014-10-17 01:13:36 UTC (rev 929)
@@ -301,13 +301,9 @@
if ((D->flags & GD_CREAT && (dirfd < 0 || format_error))
|| (D->flags & GD_TRUNC))
{
- /* can't create a read-only dirfile */
- if ((D->flags & GD_ACCMODE) == GD_RDONLY) {
- _GD_SetError(D, GD_E_ACCMODE, 0, NULL, 0, NULL);
- free(dirfile);
- dreturn("%p", NULL);
- return NULL;
- }
+ /* a newly created dirfile ignores the specified access mode */
+ if ((D->flags & GD_ACCMODE) == GD_RDONLY)
+ D->flags |= GD_RDWR;
/* attempt to create the dirfile directory, if not present */
if (dirfd < 0) {
Index: trunk/getdata/test
===================================================================
--- trunk/getdata/test 2014-10-16 23:26:40 UTC (rev 928)
+++ trunk/getdata/test 2014-10-17 01:13:36 UTC (rev 929)
Property changes on: trunk/getdata/test
___________________________________________________________________
Modified: svn:ignore
## -303,6 +303,7 ##
creat
creat_excl
creat_rdonly
+creat_rdonly_exists
cvlist
cvlist_array
cvlist_array0
Modified: trunk/getdata/test/Makefile.am
===================================================================
--- trunk/getdata/test/Makefile.am 2014-10-16 23:26:40 UTC (rev 928)
+++ trunk/getdata/test/Makefile.am 2014-10-17 01:13:36 UTC (rev 929)
@@ -131,7 +131,7 @@
convert_uint8_int64 convert_uint8_int8 convert_uint8_uint16 \
convert_uint8_uint32 convert_uint8_uint64
-CREAT_TESTS=creat creat_excl creat_rdonly
+CREAT_TESTS=creat creat_excl creat_rdonly creat_rdonly_exists
DEL_TESTS=del_alias del_carray del_carray_deref del_const del_const_deref \
del_const_force del_data del_data_enoent del_data_open del_derived \
Modified: trunk/getdata/test/creat_rdonly.c
===================================================================
--- trunk/getdata/test/creat_rdonly.c 2014-10-16 23:26:40 UTC (rev 928)
+++ trunk/getdata/test/creat_rdonly.c 2014-10-17 01:13:36 UTC (rev 929)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008-2011, 2013 D. V. Wiebe
+/* Copyright (C) 2008-2011, 2013, 2014 D. V. Wiebe
*
***************************************************************************
*
@@ -35,18 +35,20 @@
DIRFILE *D;
rmdirfile();
- D = gd_open(filedir, GD_RDONLY | GD_CREAT);
+ D = gd_open(filedir, GD_RDONLY | GD_CREAT | GD_VERBOSE);
e1 = gd_error(D);
- CHECKI(e1, GD_E_ACCMODE);
+ CHECKI(e1, 0);
- e2 = gd_close(D);
+ e2 = gd_add_spec(D, "test CONST UINT8 1", 0);
CHECKI(e2, 0);
+ gd_discard(D);
+
unlink_ret = unlink(format);
rmdir_ret = rmdir(filedir);
- CHECKI(unlink_ret, -1);
- CHECKI(rmdir_ret, -1);
+ CHECKI(unlink_ret, 0);
+ CHECKI(rmdir_ret, 0);
return r;
}
Added: trunk/getdata/test/creat_rdonly_exists.c
===================================================================
--- trunk/getdata/test/creat_rdonly_exists.c (rev 0)
+++ trunk/getdata/test/creat_rdonly_exists.c 2014-10-17 01:13:36 UTC (rev 929)
@@ -0,0 +1,55 @@
+/* Copyright (C) 2014 D. V. Wiebe
+ *
+ ***************************************************************************
+ *
+ * This file is part of the GetData project.
+ *
+ * GetData is free software; you can redistribute it and/or modify it 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.
+ *
+ * GetData 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 GetData; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include "test.h"
+
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+
+int main(void)
+{
+ const char *filedir = "dirfile";
+ const char *format = "dirfile/format";
+ int e1, e2, r = 0;
+ DIRFILE *D;
+
+ rmdirfile();
+ mkdir(filedir, 0777);
+ close(open(format, O_CREAT | O_EXCL | O_WRONLY, 0666));
+
+ D = gd_open(filedir, GD_RDONLY | GD_CREAT);
+ e1 = gd_error(D);
+ CHECKI(e1, 0);
+
+ gd_add_spec(D, "test CONST UINT8 1", 0);
+ e2 = gd_error(D);
+ CHECKI(e2, GD_E_ACCMODE);
+
+ gd_discard(D);
+
+ unlink(format);
+ rmdir(filedir);
+
+ return r;
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|