[pacman-dev] Bug in libalpm: sizeof(off_t)
Jeremy Heiner
scalaprotractor at gmail.com
Fri Nov 22 07:37:31 EST 2013
On Thu, Nov 21, 2013 at 3:52 PM, Allan McRae <allan at archlinux.org> wrote:
> Nope - documenting is the only real way to deal with this. For example:
>
> http://www.gnupg.org/documentation/manuals/gpgme/Largefile-Support-_0028LFS_0029.html
How about the approach outlined in the attachment? It passes 'make
check' and performs correctly when a libalpm client app goofs up.
-------------- next part --------------
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index e9b0feb..eab10de 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -1326,7 +1326,8 @@ typedef enum _alpm_errno_t {
ALPM_ERR_LIBARCHIVE,
ALPM_ERR_LIBCURL,
ALPM_ERR_EXTERNAL_DOWNLOAD,
- ALPM_ERR_GPGME
+ ALPM_ERR_GPGME,
+ ALPM_ERR_NOT_LARGEFILE
} alpm_errno_t;
/** Returns the current error code from the handle. */
@@ -1338,8 +1339,13 @@ const char *alpm_strerror(alpm_errno_t err);
/* End of alpm_api_errors */
/** @} */
-alpm_handle_t *alpm_initialize(const char *root, const char *dbpath,
- alpm_errno_t *err);
+#define alpm_initialize(root,dbpath,err) \
+ alpm_initialize_check_largefile(root, dbpath, err, sizeof(off_t))
+
+/** (This would be a good place to document the largefile issue) */
+alpm_handle_t *alpm_initialize_check_largefile(const char *root,
+ const char *dbpath, alpm_errno_t *err, size_t sizeof_off_t);
+
int alpm_release(alpm_handle_t *handle);
enum alpm_caps {
diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c
index 878c38b..a96e69c 100644
--- a/lib/libalpm/alpm.c
+++ b/lib/libalpm/alpm.c
@@ -37,6 +37,9 @@
* @{
*/
+/* leave alpm_initialize in the .so for backwards compatibility */
+#undef alpm_initialize
+
/** Initializes the library.
* Creates handle, connects to database and creates lockfile.
* This must be called before any other functions are called.
@@ -87,6 +90,16 @@ cleanup:
return NULL;
}
+alpm_handle_t SYMEXPORT *alpm_initialize_check_largefile(const char *root,
+ const char *dbpath, alpm_errno_t *err, size_t sizeof_off_t)
+{
+ if (sizeof(off_t) != sizeof_off_t) {
+ if (err) *err = ALPM_ERR_NOT_LARGEFILE;
+ return NULL;
+ }
+ return alpm_initialize(root, dbpath, err);
+}
+
/** Release the library.
* Disconnects from the database, removes handle and lockfile
* This should be the last alpm call you make.
More information about the pacman-dev
mailing list