diff --git a/include/emutli.h b/include/emutli.h index a9d3bb7..313578b 100644 --- a/include/emutli.h +++ b/include/emutli.h @@ -38,10 +38,18 @@ # include #endif +#include + typedef unsigned char uint8; typedef unsigned short int uint16; -typedef unsigned long int uint32; -/* typedef unsigned int uint32; */ +typedef uint32_t uint32; + +/* + * Host-side filesystem identity types. + * Do not use int here: st_dev/st_ino are 64-bit on modern systems. + */ +typedef dev_t mars_dev_t; +typedef ino_t mars_ino_t; #define IPX_NET_SIZE 4 #define IPX_NODE_SIZE 6 diff --git a/include/nwfile.h b/include/nwfile.h index 7d8975b..08df099 100644 --- a/include/nwfile.h +++ b/include/nwfile.h @@ -2,6 +2,7 @@ #ifndef _NWFILE_H_ #define _NWFILE_H_ #include "extpipe.h" +#include "emutli.h" typedef struct { int task; /* for which task */ @@ -65,5 +66,5 @@ extern int nw_log_logical_record(int lock_flag, int timeout, int len, uint8 *data); -extern void dump_locks(int dev, int inode, int fd, FILE *f); +extern void dump_locks(mars_dev_t dev, mars_ino_t inode, int fd, FILE *f); #endif diff --git a/include/nwshare.h b/include/nwshare.h index d6e92c2..fda209e 100644 --- a/include/nwshare.h +++ b/include/nwshare.h @@ -5,12 +5,12 @@ #ifndef _NWSHARE_H_ #define _NWSHARE_H_ 1 /* changed by: Ingmar Thiemann */ -extern int share_file(int dev, int inode, int open_mode, int action); -extern int share_lock( int dev, int inode, int fd, int action, - int lock_flag, int l_start, int l_len, int timeout ); -extern int share_unlock_all( int dev, int inode, int fd ); +extern int share_file(mars_dev_t dev, mars_ino_t inode, int open_mode, int action); +extern int share_lock(mars_dev_t dev, mars_ino_t inode, int fd, int action, + int lock_flag, int l_start, int l_len, int timeout ); +extern int share_unlock_all(mars_dev_t dev, mars_ino_t inode, int fd); -extern int share_set_file_add_rm(int lock_flag, int dev, int inode); +extern int share_set_file_add_rm(int lock_flag, mars_dev_t dev, mars_ino_t inode); extern int share_set_logrec_add_rm(int lock_flag, int timeout, int len, char *data); extern int share_handle_lock_sets(int type, int lock_flag, int timeout); diff --git a/src/connect.c b/src/connect.c index 60af2ce..c848685 100644 --- a/src/connect.c +++ b/src/connect.c @@ -62,7 +62,7 @@ static int act_umode_file=0; typedef struct { - int dev; /* unix dev */ + dev_t dev; /* unix dev */ ino_t inode; /* unix inode */ time_t timestamp; /* Zeitmarke */ uint8 *path; /* path ab Volume */ @@ -92,7 +92,7 @@ static int connect_is_init = 0; typedef struct { DIR *f; char unixname[256]; /* full unixname */ - int dev; /* Unix dev */ + dev_t dev; /* Unix dev */ ino_t inode; /* Unix Inode */ time_t timestamp; /* last allocation */ char *kpath; /* one char after unixname */ diff --git a/src/nwshare.c b/src/nwshare.c index 1b704fc..0e58415 100644 --- a/src/nwshare.c +++ b/src/nwshare.c @@ -18,6 +18,7 @@ */ #include "net.h" +#include #include "nwvolume.h" #include "nwfile.h" @@ -40,7 +41,7 @@ typedef struct _tagShareLock { } ShareLock; typedef struct _tagShareINode { - int inode; + ino_t inode; int or; /* open read */ int ow; /* open write */ int dr; /* deny read */ @@ -56,7 +57,7 @@ typedef struct _tagShareINode { } ShareINode; typedef struct _tagShareDev { - int dev; + dev_t dev; int fd_sm; /* semaphor for locking operation */ int fd_or; /* open read */ @@ -75,7 +76,7 @@ static ShareDev *first_dev = NULL; static char *path_share_lock_files=NULL; -int share_file(int dev, int inode, int open_mode, int action) +int share_file(dev_t dev, ino_t inode, int open_mode, int action) /* open_mode is the same as 'access' in file_creat_open(): * 0x001 = open for read * 0x002 = open for write @@ -98,9 +99,10 @@ int share_file(int dev, int inode, int open_mode, int action) int result = 0, act_mode = 0; struct flock flockd; char tbuf[200]; - sprintf(tbuf,"dev=0x%x,inode=%d,open_mode=0x%x,action=%d", - dev, inode, open_mode, action); - + sprintf(tbuf, + "dev=0x%" PRIxMAX ",inode=%" PRIuMAX ",open_mode=0x%x,action=%d", + (uintmax_t)dev, (uintmax_t)inode, + open_mode, action); if (open_mode==0) { XDPRINTF((1, 0, "Wrong openmode in share_file %s", tbuf)); return(-1); @@ -195,7 +197,8 @@ int share_file(int dev, int inode, int open_mode, int action) unx_xmkdir(path_share_lock_files, 0755); } else seteuid(0); - l=sprintf(buff, "%s/%x.sm", path_share_lock_files, dev); + l=sprintf(buff, "%s/%" PRIxMAX ".sm", path_share_lock_files, + (uintmax_t)dev); sd->fd_sm = open(buff, O_RDWR|O_CREAT, 0600); #if 0 buff[l-2]='c'; @@ -477,8 +480,8 @@ void catch_alarm (int sig) #define OFFSET_MAX 0x7fffffff -int share_lock( int dev, int inode, int fd, int action, - int lock_flag, int l_start, int l_len, int timeout ) +int share_lock(dev_t dev, ino_t inode, int fd, int action, + int lock_flag, int l_start, int l_len, int timeout) /* * action: * 0 = unlock @@ -498,8 +501,10 @@ int share_lock( int dev, int inode, int fd, int action, int result = 0; struct flock flockd; char tbuf[200]; - sprintf(tbuf,"dev=0x%x,inode=%d,fd=%d,action=%d,lock_flag=%d", - dev, inode, fd, action, lock_flag); + sprintf(tbuf, + "dev=0x%" PRIxMAX ",inode=%" PRIuMAX ",fd=%d,action=%d,lock_flag=%d", + (uintmax_t)dev, (uintmax_t)inode, + fd, action, lock_flag); #if 0 /* pcz: 30-Jul-01 different locking conversion from 32Bit space @@ -593,7 +598,7 @@ int share_lock( int dev, int inode, int fd, int action, return result; } -int share_unlock_all( int dev, int inode, int fd ) +int share_unlock_all(dev_t dev, ino_t inode, int fd) { ShareDev *sd; ShareINode *si; @@ -601,7 +606,9 @@ int share_unlock_all( int dev, int inode, int fd ) int result = 0; struct flock flockd; char tbuf[200]; - sprintf(tbuf,"dev=0x%x,inode=%d,fd=%d", dev, inode, fd); + sprintf(tbuf, + "dev=0x%" PRIxMAX ",inode=%" PRIuMAX ",fd=%d", + (uintmax_t)dev, (uintmax_t)inode, fd); if (!_get_inode( dev, inode, &sd, &si )) { XDPRINTF((1, 0, "Could not find share for unlock_all %s", tbuf)); @@ -626,13 +633,15 @@ int share_unlock_all( int dev, int inode, int fd ) return result; } -void dump_locks( int dev, int inode, int fd, FILE* f) +void dump_locks(dev_t dev, ino_t inode, int fd, FILE* f) { ShareDev *sd; ShareINode *si; ShareLock *psl; char tbuf[200]; - sprintf(tbuf,"dev=0x%x,inode=%d,fd=%d", dev, inode, fd); + sprintf(tbuf, + "dev=0x%" PRIxMAX ",inode=%" PRIuMAX ",fd=%d", + (uintmax_t)dev, (uintmax_t)inode, fd); if (!_get_inode( dev, inode, &sd, &si )) { XDPRINTF((1, 0, "Could not find share for unlock_all %s", tbuf)); @@ -652,8 +661,8 @@ typedef struct S_SHARESET{ int timeout; /* not used yet */ int locked; /* is entry locked */ - int dev; - int inode; + dev_t dev; + ino_t inode; int datalen; char *data; /* used for Logical Records */ @@ -703,7 +712,7 @@ static int lock_unlock_pset(SHARESET *ps, int lock_flag) return(result); } -int share_set_file_add_rm(int lock_flag, int dev, int inode) +int share_set_file_add_rm(int lock_flag, dev_t dev, ino_t inode) { if (lock_flag > -1) { SHARESET *ps = (SHARESET*)xcmalloc(sizeof(SHARESET)); diff --git a/src/trustee.c b/src/trustee.c index e592bac..8420e11 100644 --- a/src/trustee.c +++ b/src/trustee.c @@ -155,8 +155,8 @@ typedef struct { typedef struct { int volume; - int dev; - int inode; + mars_dev_t dev; + mars_ino_t inode; int idle; /* idle state */ int mode_flags; /* @@ -245,7 +245,7 @@ static void add_trustee_node(FILE_TRUSTEE_NODE *trn) } } -static FILE_TRUSTEE_NODE *find_trustee_node(int volume, int dev, int inode) +static FILE_TRUSTEE_NODE *find_trustee_node(int volume, mars_dev_t dev, mars_ino_t inode) { if (vol_trustees_were_changed(volume)) return(NULL); @@ -325,7 +325,7 @@ static void creat_trustee_path(int volume, int dev, ino_t inode, uint8 *path) } } -static int put_trustee_to_disk(int volume, int dev, ino_t inode, uint32 id, int trustee) +static int put_trustee_to_disk(int volume, dev_t dev, ino_t inode, uint32 id, int trustee) /* is always called with uid = 0 */ /* if id=0, it means inherited_mask */ { @@ -349,7 +349,7 @@ static int put_trustee_to_disk(int volume, int dev, ino_t inode, uint32 id, int return(symlink(btrustee, buf) ? -0xff : 0); } -static int get_trustee_from_disk(int volume, int dev, ino_t inode, uint32 id, int *trustee) +static int get_trustee_from_disk(int volume, dev_t dev, ino_t inode, uint32 id, int *trustee) /* * if id=0, it means inherited_mask * return 0 if 0, < 0 if error @@ -382,7 +382,7 @@ static int get_trustee_from_disk(int volume, int dev, ino_t inode, uint32 id, in return(-0xff); } -static int del_trustee_from_disk(int volume, int dev, ino_t inode, uint32 id) +static int del_trustee_from_disk(int volume, dev_t dev, ino_t inode, uint32 id) /* removes users id trustee */ { char buf[256];