PERFORCE change 124338 for review

Garrett Cooper gcooper at FreeBSD.org
Mon Jul 30 09:23:06 UTC 2007


http://perforce.freebsd.org/chv.cgi?CH=124338

Change 124338 by gcooper at optimus-revised_pkgtools on 2007/07/30 09:22:33

	Adding extentions for file functions like:
	1. Checking if files exist.
	2. Safe chmod'ing (via fchmod(2))
	3. Checksum validation (MD5, SHA1, SHA256 via md5(2), sha1(2) and sha256(2), respectively).

Affected files ...

.. //depot/projects/soc2007/revised_fbsd_pkgtools/v2/lib/file/api.c#1 add
.. //depot/projects/soc2007/revised_fbsd_pkgtools/v2/lib/file/api.h#2 edit

Differences ...

==== //depot/projects/soc2007/revised_fbsd_pkgtools/v2/lib/file/api.h#2 (text+ko) ====

@@ -2,11 +2,32 @@
 
 #define __FILE_API_H
 
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <md5.h>
+#include <sha1.h>
+#include <sha256.h>
+
 typedef struct {
-    char path[FILENAME_MAX+1];
-    char checksum[MAX_CHECKSUM_LENGTH+1];
-    int exists;
-    int checksum_matches;
+    char        path[FILENAME_MAX+1];
+    char        checksum[MAX_CHECKSUM_LENGTH+1];
+    int         fd;
+    mode_t      req_mode;
 } file_info_t;
 
+typedef enum {
+    MD5,
+    SHA1,
+    SHA256
+} checksum_type_e;
+
+int             checksum_matches(const file_info_t *, const checksum_type_e);
+
+#define OPEN(PATH, OPEN_FLAGS) open(PATH, OPEN_FLAGS | O_DIRECT)
+
+int             Fexists(const file_info_t *, const int);
+int             Exists(const file_info_t *);
+int             Chmod(const file_info_t *, const int, const int);
+
 #endif


More information about the p4-projects mailing list