This file is indexed.

/usr/include/zorp/blob.h is in libzorpll-6.0-10-dev 6.0.10.0-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/***************************************************************************
 *
 * This file is covered by a dual licence. You can choose whether you
 * want to use it according to the terms of the GNU GPL version 2, or
 * under the terms of Zorp Professional Firewall System EULA located
 * on the Zorp installation CD.
 *
 ***************************************************************************/

#ifndef ZORP_BLOB_H_INCLUDED
#define ZORP_BLOB_H_INCLUDED

#include <zorp/zorplib.h>
#include <zorp/stream.h>
#include <time.h>

#ifdef __cplusplus
extern "C" {
#endif

struct ZBlob;

/**
 * Central management of blobs.
 **/
typedef struct ZBlobSystem
{
  ZRefCount     ref_cnt;                    /**< reference counter */
  gchar         *dir;                       /**< directory to store the blobs in */
  guint64       disk_max, disk_used;        /**< maximal and current disk usage */
  gsize         mem_max, mem_used;          /**< maximal and current memory usage */
  gsize         lowat, hiwat, noswap_max;   /**< control limits - see spec */
  
  GMutex        mtx_blobsys;               /**< gadgets used for signalling request like allocation, etc. */
  GCond         cond_thread_started;
  
  GThread       *thr_management;            /**< management thread */
  GError        *thread_error;              /**< error structure for creating thr_management */
  GList         *blobs;                     /**< blobs created in this blob system */

  GAsyncQueue   *req_queue;                 /**< queue of blobs who have pending requests */
  GList         *waiting_list;              /**< list of blobs whose requests weren't approved immediately */
  gboolean      active;                     /**< false if the blobsys is 'under destruction' */
} ZBlobSystem;

/** global default instance */
extern ZBlobSystem  *z_blob_system_default;
extern const gchar* z_blob_system_default_tmpdir;   /**< directory to store the blobs in */
extern gint64 z_blob_system_default_max_disk_usage; /**< max disk usage = 1 GB */
extern gsize z_blob_system_default_max_mem_usage;   /**< max mem usage = 256 MB */
extern gsize z_blob_system_default_lowat;           /**< lowat = 96 MB */
extern gsize z_blob_system_default_hiwat;           /**< hiwat = 128 MB */
extern gsize z_blob_system_default_noswap_max;      /**< noswap_max = 16 kB */

/* constructor, ref, unref, destructor */
ZBlobSystem* z_blob_system_new(const char *dir, gint64 dmax, gsize mmax, gsize low, gsize hiw, gsize nosw);
void z_blob_system_ref(ZBlobSystem *self);
void z_blob_system_unref(ZBlobSystem *self);
/* create and destroy the default instance */
void z_blob_system_default_init(void);
void z_blob_system_default_destroy(void);


/**
 * Usage statistics for a blob.
 **/
typedef struct ZBlobStatistic
{
    gint                req_rd, req_wr, req_map;  /**< performed read, write and mapping requests */
    gint                swap_count;               /**< swapout counter */
    gint                alloc_count;              /**< alloc modification counter */
    unsigned long long  total_rd, total_wr;       /**< total bytes read and written */
    time_t              created, last_accessed;   /**< time of creation and last access */
} ZBlobStatistic;

/* initialise a blob stat - counters set to zero, timestamps to 'now' */
void z_blob_statistic_init(ZBlobStatistic *self);

/** Blob sends ZBlobRequestCode to the maintenance thread for approval or as notification. */ 
typedef enum ZBlobRequestCode
{
  Z_BLOB_REQ_NONE,                          /**< none - default value, does nothing */
  Z_BLOB_REQ_REGISTER,                      /**< new blob wants to register itself */
  Z_BLOB_REQ_UNREGISTER,                    /**< blob wants to unregister itself */
  Z_BLOB_REQ_ALLOC                          /**< blob asks for approval on modification of its allocation */
} ZBlobRequestCode;

/** The blob itself. */
typedef struct ZBlob
{
  ZRefCount         ref_cnt;                /**< reference counter */
  gint64            size, alloc_size;       /**< actual size of the blob and the allocated space */
  gboolean          is_in_file;             /**< is the blob swapped out */
  gchar             *filename;              /**< swapfile name */
  gint              fd;                     /**< swapfile descriptor */
  gchar             *data;                  /**< memory image pointer */
  ZBlobSystem       *system;                /**< blob system it belongs to */
  GMutex            mtx_lock;              /**< lock for concurrent accesses */
  ZBlobStatistic    stat;                   /**< statistics */

  GMutex            mtx_reply;             /**< mutex and conditional for waiting for reply */
  GCond             cond_reply;
  gboolean          replied;
  
  gchar             *mapped_ptr;            /**< addr and length of the mapped area */
  gsize             mapped_length;          /**< (when multiple mappings will be implemented, replace with ?GHash?) */

  /* communication with the blobsystems threadproc */
  gssize            alloc_req;              /**< communication with the blobsystems threadproc */
  gboolean          approved;               /**< communication with the blobsystems threadproc */
  gboolean          storage_locked;         /**< communication with the blobsystems threadproc */
} ZBlob;

/* constructor, ref, unref, destructor */
ZBlob *z_blob_new(ZBlobSystem *sys, gsize initial_size);
ZBlob *z_blob_ref(ZBlob *self);
void z_blob_unref(ZBlob *self);

/* swap out and get the filename - WARNING - the blob will be locked for reading (only) */
const gchar *z_blob_get_file(ZBlob *self, const gchar *user, const gchar *group, gint mode, gint timeout);
void z_blob_release_file(ZBlob *self);

/* truncate/expand a blob to a specified size */
gboolean z_blob_truncate(ZBlob *self, gint64 pos, gint timeout);

/* write and read */
gsize z_blob_add_copy(ZBlob *self, gint64 pos, const gchar *data, gsize req_datalen, gint timeout);
gsize z_blob_get_copy(ZBlob *self, gint64 pos, gchar *data, gsize req_datalen, gint timeout);

GIOStatus z_blob_read_from_stream(ZBlob *self, gint64 pos, ZStream *stream, gint64 count, gint timeout, GError **error);
GIOStatus z_blob_write_to_stream(ZBlob *self, gint64 pos, ZStream *stream, gint64 count, gint timeout, GError **error);

/* lock and unlock part of the blob and return pointer to it - WARNING - the blob will be locked for reading (only) */
gchar *z_blob_get_ptr(ZBlob *self, gint64 pos, gsize *req_datalen, gint timeout);
void z_blob_free_ptr(ZBlob *self, gchar *data);

void z_blob_storage_lock(ZBlob *self, gboolean st);

/* locking functions - needed by ZStreamBlob */
gboolean z_blob_lock(ZBlob *self, gint timeout);
void z_blob_unlock(ZBlob *self);

#ifdef __cplusplus
}
#endif

#endif