Home | History | Annotate | Line # | Download | only in util
      1 /*	$NetBSD: wrap_stat.c,v 1.2 2026/05/09 18:49:23 christos Exp $	*/
      2 
      3 /*++
      4 /* NAME
      5 /*	wrap_stat 3
      6 /* SUMMARY
      7 /*	mockable stat/lstat wrappers
      8 /* SYNOPSIS
      9 /*	#include <wrap_stat.h>
     10 /*
     11 /*	int     wrap_stat(
     12 /*	const char *path,
     13 /*	struct stat *st)
     14 /*
     15 /*	int     wrap_lstat(
     16 /*	const char *path,
     17 /*	struct stat *st)
     18 /* DESCRIPTION
     19 /*	This module is a NOOP when the NO_MOCK_WRAPPERS macro is
     20 /*	defined.
     21 /*
     22 /*	By default this module redirects stat() and lstat() calls to
     23 /*	the above listed wrapper functions that may be overridden with
     24 /*	mocks. This arrangement prevents mock stat() or lstat() functions
     25 /*	from interfering with stat() or lstat() calls made by system
     26 /*	libraries or by third-party libraries.
     27 /* LICENSE
     28 /* .ad
     29 /* .fi
     30 /*	The Secure Mailer license must be distributed with this software.
     31 /* AUTHOR(S)
     32 /*	Wietse Venema
     33 /*	porcupine.org
     34 /*--*/
     35 
     36  /*
     37   * System library.
     38   */
     39 #include <sys_defs.h>
     40 #include <sys/stat.h>
     41 
     42  /*
     43   * Utility library.
     44   */
     45 #include <wrap_stat.h>
     46 
     47 /* wrap_stat - mockable wrapper */
     48 
     49 int     wrap_stat(const char *path, struct stat *st)
     50 {
     51 #undef stat
     52     return (stat (path, st));
     53 }
     54 
     55 /* wrap_lstat - mockable wrapper */
     56 
     57 int     wrap_lstat(const char *path, struct stat *st)
     58 {
     59 #undef lstat
     60     return (lstat(path, st));
     61 }
     62