Date: Mon, 30 Jul 2007 09:23:05 GMT From: Garrett Cooper <gcooper@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 124338 for review Message-ID: <200707300923.l6U9N5nC077213@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=124338 Change 124338 by gcooper@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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200707300923.l6U9N5nC077213>