forked from osmocom/wireshark
Rename ws_stat to ws_stat64, and make it take a pointer to a ws_statb64
as an argument, along the lines of ws_fstat64, and, on Windows, make it use _wstati64, to handle 64-bit file sizes. svn path=/trunk/; revision=36547
This commit is contained in:
parent
f2008e4dd3
commit
4fdcc5c180
|
@ -557,12 +557,12 @@ static void
|
|||
read_keytab_file(const char *service_key_file)
|
||||
{
|
||||
FILE *skf;
|
||||
struct stat st;
|
||||
ws_statb64 st;
|
||||
service_key_t *sk;
|
||||
unsigned char buf[SERVICE_KEY_SIZE];
|
||||
int newline_skip = 0, count = 0;
|
||||
|
||||
if (service_key_file != NULL && ws_stat (service_key_file, &st) == 0) {
|
||||
if (service_key_file != NULL && ws_stat64 (service_key_file, &st) == 0) {
|
||||
|
||||
/* The service key file contains raw 192-bit (24 byte) 3DES keys.
|
||||
* There can be zero, one (\n), or two (\r\n) characters between
|
||||
|
|
|
@ -683,9 +683,9 @@ gboolean capture_opts_trim_iface(capture_options *capture_opts, const char *capt
|
|||
/* copied from filesystem.c */
|
||||
static int capture_opts_test_for_fifo(const char *path)
|
||||
{
|
||||
struct stat statb;
|
||||
ws_statb64 statb;
|
||||
|
||||
if (ws_stat(path, &statb) < 0)
|
||||
if (ws_stat64(path, &statb) < 0)
|
||||
return errno;
|
||||
|
||||
if (S_ISFIFO(statb.st_mode))
|
||||
|
|
|
@ -1621,7 +1621,7 @@ cap_pipe_open_live(char *pipename, struct pcap_hdr *hdr, loop_data *ld,
|
|||
char *errmsg, int errmsgl)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
struct stat pipe_stat;
|
||||
ws_statb64 pipe_stat;
|
||||
struct sockaddr_un sa;
|
||||
int sel_ret;
|
||||
int b;
|
||||
|
@ -1654,7 +1654,7 @@ cap_pipe_open_live(char *pipename, struct pcap_hdr *hdr, loop_data *ld,
|
|||
#endif /* _WIN32 */
|
||||
} else {
|
||||
#ifndef _WIN32
|
||||
if (ws_stat(pipename, &pipe_stat) < 0) {
|
||||
if (ws_stat64(pipename, &pipe_stat) < 0) {
|
||||
if (errno == ENOENT || errno == ENOTDIR)
|
||||
ld->cap_pipe_err = PIPNEXIST;
|
||||
else {
|
||||
|
|
|
@ -799,12 +799,12 @@ static void
|
|||
read_keytab_file(const char *service_key_file)
|
||||
{
|
||||
FILE *skf;
|
||||
struct stat st;
|
||||
ws_statb64 st;
|
||||
service_key_t *sk;
|
||||
unsigned char buf[SERVICE_KEY_SIZE];
|
||||
int newline_skip = 0, count = 0;
|
||||
|
||||
if (service_key_file != NULL && ws_stat (service_key_file, &st) == 0) {
|
||||
if (service_key_file != NULL && ws_stat64 (service_key_file, &st) == 0) {
|
||||
|
||||
/* The service key file contains raw 192-bit (24 byte) 3DES keys.
|
||||
* There can be zero, one (\n), or two (\r\n) characters between
|
||||
|
|
|
@ -215,9 +215,9 @@ get_dirname(char *path)
|
|||
int
|
||||
test_for_directory(const char *path)
|
||||
{
|
||||
struct stat statb;
|
||||
ws_statb64 statb;
|
||||
|
||||
if (ws_stat(path, &statb) < 0)
|
||||
if (ws_stat64(path, &statb) < 0)
|
||||
return errno;
|
||||
|
||||
if (S_ISDIR(statb.st_mode))
|
||||
|
@ -229,9 +229,9 @@ test_for_directory(const char *path)
|
|||
int
|
||||
test_for_fifo(const char *path)
|
||||
{
|
||||
struct stat statb;
|
||||
ws_statb64 statb;
|
||||
|
||||
if (ws_stat(path, &statb) < 0)
|
||||
if (ws_stat64(path, &statb) < 0)
|
||||
return errno;
|
||||
|
||||
if (S_ISFIFO(statb.st_mode))
|
||||
|
@ -1191,7 +1191,7 @@ create_persconffile_profile(const char *profilename, char **pf_dir_path_return)
|
|||
char *pf_dir_path_copy, *pf_dir_parent_path;
|
||||
size_t pf_dir_parent_path_len;
|
||||
#endif
|
||||
struct stat s_buf;
|
||||
ws_statb64 s_buf;
|
||||
int ret;
|
||||
|
||||
if (profilename) {
|
||||
|
@ -1207,7 +1207,7 @@ create_persconffile_profile(const char *profilename, char **pf_dir_path_return)
|
|||
* If not then create it.
|
||||
*/
|
||||
pf_dir_path = get_profiles_dir ();
|
||||
if (ws_stat(pf_dir_path, &s_buf) != 0 && errno == ENOENT) {
|
||||
if (ws_stat64(pf_dir_path, &s_buf) != 0 && errno == ENOENT) {
|
||||
ret = ws_mkdir(pf_dir_path, 0755);
|
||||
if (ret == -1) {
|
||||
*pf_dir_path_return = g_strdup(pf_dir_path);
|
||||
|
@ -1217,7 +1217,7 @@ create_persconffile_profile(const char *profilename, char **pf_dir_path_return)
|
|||
}
|
||||
|
||||
pf_dir_path = get_persconffile_dir(profilename);
|
||||
if (ws_stat(pf_dir_path, &s_buf) != 0 && errno == ENOENT) {
|
||||
if (ws_stat64(pf_dir_path, &s_buf) != 0 && errno == ENOENT) {
|
||||
#ifdef _WIN32
|
||||
/*
|
||||
* Does the parent directory of that directory
|
||||
|
@ -1235,7 +1235,7 @@ create_persconffile_profile(const char *profilename, char **pf_dir_path_return)
|
|||
pf_dir_parent_path_len = strlen(pf_dir_parent_path);
|
||||
if (pf_dir_parent_path_len > 0
|
||||
&& pf_dir_parent_path[pf_dir_parent_path_len - 1] != ':'
|
||||
&& ws_stat(pf_dir_parent_path, &s_buf) != 0) {
|
||||
&& ws_stat64(pf_dir_parent_path, &s_buf) != 0) {
|
||||
/*
|
||||
* No, it doesn't exist - make it first.
|
||||
*/
|
||||
|
@ -1466,7 +1466,7 @@ get_persconffile_path(const char *filename, gboolean from_profile, gboolean for_
|
|||
{
|
||||
char *path;
|
||||
#ifdef _WIN32
|
||||
struct stat s_buf;
|
||||
ws_statb64 s_buf;
|
||||
char *old_path;
|
||||
#endif
|
||||
if (do_store_persconffiles && from_profile && !g_hash_table_lookup (profile_files, filename)) {
|
||||
|
@ -1483,7 +1483,7 @@ get_persconffile_path(const char *filename, gboolean from_profile, gboolean for_
|
|||
}
|
||||
#ifdef _WIN32
|
||||
if (!for_writing) {
|
||||
if (ws_stat(path, &s_buf) != 0 && errno == ENOENT) {
|
||||
if (ws_stat64(path, &s_buf) != 0 && errno == ENOENT) {
|
||||
/*
|
||||
* OK, it's not in the personal configuration file
|
||||
* directory; is it in the ".wireshark" subdirectory
|
||||
|
@ -1492,7 +1492,7 @@ get_persconffile_path(const char *filename, gboolean from_profile, gboolean for_
|
|||
old_path = g_strdup_printf(
|
||||
"%s" G_DIR_SEPARATOR_S ".wireshark" G_DIR_SEPARATOR_S "%s",
|
||||
get_home_dir(), filename);
|
||||
if (ws_stat(old_path, &s_buf) == 0) {
|
||||
if (ws_stat64(old_path, &s_buf) == 0) {
|
||||
/*
|
||||
* OK, it exists; return it instead.
|
||||
*/
|
||||
|
@ -1697,7 +1697,7 @@ file_write_error_message(int err)
|
|||
gboolean
|
||||
file_exists(const char *fname)
|
||||
{
|
||||
struct stat file_stat;
|
||||
ws_statb64 file_stat;
|
||||
|
||||
#ifdef _WIN32
|
||||
/*
|
||||
|
@ -1707,14 +1707,14 @@ file_exists(const char *fname)
|
|||
* so this is working, but maybe not quite the way expected. ULFL
|
||||
*/
|
||||
file_stat.st_ino = 1; /* this will make things work if an error occured */
|
||||
ws_stat(fname, &file_stat);
|
||||
ws_stat64(fname, &file_stat);
|
||||
if (file_stat.st_ino == 0) {
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
#else
|
||||
if (ws_stat(fname, &file_stat) != 0 && errno == ENOENT) {
|
||||
if (ws_stat64(fname, &file_stat) != 0 && errno == ENOENT) {
|
||||
return FALSE;
|
||||
} else {
|
||||
return TRUE;
|
||||
|
@ -1764,14 +1764,14 @@ files_identical(const char *fname1, const char *fname2)
|
|||
return FALSE;
|
||||
}
|
||||
#else
|
||||
struct stat filestat1, filestat2;
|
||||
ws_statb64 filestat1, filestat2;
|
||||
|
||||
/*
|
||||
* Compare st_dev and st_ino.
|
||||
*/
|
||||
if (ws_stat(fname1, &filestat1) == -1)
|
||||
if (ws_stat64(fname1, &filestat1) == -1)
|
||||
return FALSE; /* can't get info about the first file */
|
||||
if (ws_stat(fname2, &filestat2) == -1)
|
||||
if (ws_stat64(fname2, &filestat2) == -1)
|
||||
return FALSE; /* can't get info about the second file */
|
||||
return (filestat1.st_dev == filestat2.st_dev &&
|
||||
filestat1.st_ino == filestat2.st_ino);
|
||||
|
|
|
@ -389,12 +389,12 @@ GtkWidget * capture_get_if_icon(const if_info_t* if_info _U_)
|
|||
/*
|
||||
* Look for /sys/class/net/{device}/wireless.
|
||||
*/
|
||||
struct stat statb;
|
||||
ws_statb64 statb;
|
||||
char *wireless_path;
|
||||
|
||||
wireless_path = g_strdup_printf("/sys/class/net/%s/wireless", if_info->name);
|
||||
if (wireless_path != NULL) {
|
||||
if (ws_stat(wireless_path, &statb) == 0) {
|
||||
if (ws_stat64(wireless_path, &statb) == 0) {
|
||||
g_free(wireless_path);
|
||||
return pixbuf_to_widget(network_wireless_pb_data);
|
||||
}
|
||||
|
|
|
@ -447,7 +447,7 @@ welcome_filename_link_new(const gchar *filename, GtkWidget **label)
|
|||
gsize uni_start, uni_end;
|
||||
const glong max = 60;
|
||||
int err;
|
||||
struct stat stat_buf;
|
||||
ws_statb64 stat_buf;
|
||||
GtkTooltips *tooltips;
|
||||
|
||||
|
||||
|
@ -475,7 +475,7 @@ welcome_filename_link_new(const gchar *filename, GtkWidget **label)
|
|||
* Add file size. We use binary prefixes instead of IEC because that's what
|
||||
* most OSes use.
|
||||
*/
|
||||
err = ws_stat(filename, &stat_buf);
|
||||
err = ws_stat64(filename, &stat_buf);
|
||||
if(err == 0) {
|
||||
if (stat_buf.st_size/1024/1024/1024 > 10) {
|
||||
g_string_append_printf(str, " (%" G_GINT64_MODIFIER "d GB)", (gint64) (stat_buf.st_size/1024/1024/1024));
|
||||
|
|
|
@ -247,7 +247,7 @@ static int
|
|||
raw_pipe_open(const char *pipe_name)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
struct stat pipe_stat;
|
||||
ws_statb64 pipe_stat;
|
||||
#else
|
||||
char *pncopy, *pos;
|
||||
DWORD err;
|
||||
|
@ -272,7 +272,7 @@ raw_pipe_open(const char *pipe_name)
|
|||
#endif /* _WIN32 */
|
||||
} else {
|
||||
#ifndef _WIN32
|
||||
if (ws_stat(pipe_name, &pipe_stat) < 0) {
|
||||
if (ws_stat64(pipe_name, &pipe_stat) < 0) {
|
||||
fprintf(stderr, "rawshark: The pipe %s could not be checked: %s\n",
|
||||
pipe_name, strerror(errno));
|
||||
return -1;
|
||||
|
|
|
@ -222,7 +222,7 @@ void wtap_register_open_routine(wtap_open_routine_t open_routine, gboolean has_m
|
|||
wtap* wtap_open_offline(const char *filename, int *err, char **err_info,
|
||||
gboolean do_random)
|
||||
{
|
||||
struct stat statb;
|
||||
ws_statb64 statb;
|
||||
wtap *wth;
|
||||
unsigned int i;
|
||||
gboolean use_stdin = FALSE;
|
||||
|
@ -238,7 +238,7 @@ wtap* wtap_open_offline(const char *filename, int *err, char **err_info,
|
|||
return NULL;
|
||||
}
|
||||
} else {
|
||||
if (ws_stat(filename, &statb) < 0) {
|
||||
if (ws_stat64(filename, &statb) < 0) {
|
||||
*err = errno;
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -222,8 +222,8 @@ ws_stdio_mkdir (const gchar *filename,
|
|||
* Since: 2.6
|
||||
*/
|
||||
int
|
||||
ws_stdio_stat (const gchar *filename,
|
||||
struct stat *buf)
|
||||
ws_stdio_stat64 (const gchar *filename,
|
||||
ws_statb64 *buf)
|
||||
{
|
||||
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
|
||||
int retval;
|
||||
|
@ -243,7 +243,7 @@ ws_stdio_stat (const gchar *filename,
|
|||
(!g_path_is_absolute (filename) || len > (size_t) (g_path_skip_root (filename) - filename)))
|
||||
wfilename[len] = '\0';
|
||||
|
||||
retval = _wstat (wfilename, (struct _stat *) buf);
|
||||
retval = _wstati64 (wfilename, buf);
|
||||
save_errno = errno;
|
||||
|
||||
g_free (wfilename);
|
||||
|
|
|
@ -60,7 +60,7 @@ extern FILE * ws_stdio_freopen (const gchar *filename, const gchar *mode, FILE *
|
|||
#define ws_open ws_stdio_open
|
||||
#define ws_rename ws_stdio_rename
|
||||
#define ws_mkdir ws_stdio_mkdir
|
||||
#define ws_stat ws_stdio_stat
|
||||
#define ws_stat64 ws_stdio_stat64
|
||||
#define ws_unlink ws_stdio_unlink
|
||||
#define ws_remove ws_stdio_remove
|
||||
#define ws_fopen ws_stdio_fopen
|
||||
|
@ -70,14 +70,16 @@ extern FILE * ws_stdio_freopen (const gchar *filename, const gchar *mode, FILE *
|
|||
|
||||
/* "Not Windows" or GLib < 2.6: use "old school" functions */
|
||||
#ifdef _WIN32
|
||||
#define ws_open _open
|
||||
#define ws_stat _stat
|
||||
#define ws_unlink _unlink
|
||||
/* Windows, but GLib < 2.6 */
|
||||
#define ws_open _open
|
||||
#define ws_stat64 _stati64 /* use _stati64 for 64-bit size support */
|
||||
#define ws_unlink _unlink
|
||||
#define ws_mkdir(dir,mode) _mkdir(dir)
|
||||
#else
|
||||
#define ws_open open
|
||||
#define ws_stat stat
|
||||
#define ws_unlink unlink
|
||||
#else /* _WIN32 */
|
||||
/* "Not Windows" */
|
||||
#define ws_open open
|
||||
#define ws_stat64 stat
|
||||
#define ws_unlink unlink
|
||||
#define ws_mkdir(dir,mode) mkdir(dir,mode)
|
||||
#endif /* _WIN32 */
|
||||
|
||||
|
|
Loading…
Reference in New Issue