FOSSology  4.4.0
Open Source License Compliance by Open Source Software
repmmapcheck.c
Go to the documentation of this file.
1 /*
2  repmmapcheck: Check if mmap() works.
3  SPDX-FileCopyrightText: © 2007-2011 Hewlett-Packard Development Company, L.P.
4 
5  SPDX-License-Identifier: LGPL-2.1-only
6 */
12 #include <stdlib.h>
13 #include <stdio.h>
14 #include "libfossrepo.h"
15 
16 #ifdef COMMIT_HASH
17 char BuildVersion[]="Build version: " COMMIT_HASH ".\n";
18 #endif
19 
20 int main(int argc, char* argv[])
21 {
22  RepMmapStruct* M;
23 
24  if (argc != 3)
25  {
26  fprintf(stderr, "Usage: %s type filename > output\n", argv[0]);
27  exit(-1);
28  }
29 
30  M = fo_RepMmap(argv[1], argv[2]);
31  if (!M)
32  {
33  fprintf(stderr, "ERROR: failed to mmap file.\n");
34  return (-1);
35  }
36 
37  printf("Successfully mapped %ld bytes\n", (long) (M->MmapSize));
38 
39  fo_RepMunmap(M);
40  return (0);
41 } /* main() */
42 
char BuildVersion[]
Definition: buckets.c:68
RepMmapStruct * fo_RepMmap(char *Type, char *Filename)
Perform a mmap.
Definition: libfossrepo.c:786
void fo_RepMunmap(RepMmapStruct *M)
Perform a munmap.
Definition: libfossrepo.c:721
uint32_t MmapSize
Size of file mmap.
Definition: libfossrepo.h:93