patch-2.0.27 linux/include/linux/smb.h

Next file: linux/include/linux/smb_fs.h
Previous file: linux/include/linux/mm.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.0.26/linux/include/linux/smb.h linux/include/linux/smb.h
@@ -28,26 +28,53 @@
 typedef unsigned long dword;
 #endif
 
-/*
- * Set/Get values in SMB-byte order
- */
-#define ARCH i386
-#if (ARCH == i386)
-#define BVAL(p,off)      (*((byte  *)(((void *)p)+off)))
-#define WVAL(p,off)      (*((word  *)(((void *)p)+off)))
-#define DVAL(p,off)      (*((dword *)(((void *)p)+off)))
-#define BSET(p,off,new)  (*((byte  *)(((void *)p)+off))=(new))
-#define WSET(p,off,new)  (*((word  *)(((void *)p)+off))=(new))
-#define DSET(p,off,new)  (*((dword *)(((void *)p)+off))=(new))
+/* The following macros have been taken directly from Samba. Thanks,
+   Andrew! */
 
-/* where to find the base of the SMB packet proper */
-#define smb_base(buf) ((byte *)(((byte *)(buf))+4))
+#undef CAREFUL_ALIGNMENT
+
+/* we know that the 386 can handle misalignment and has the "right" 
+   byteorder */
+#if defined(__i386__)
+#define CAREFUL_ALIGNMENT 0
+#endif
+
+#ifndef CAREFUL_ALIGNMENT
+#define CAREFUL_ALIGNMENT 1
+#endif
 
+#define BVAL(buf,pos) (((u8 *)(buf))[pos])
+#define PVAL(buf,pos) ((unsigned)BVAL(buf,pos))
+#define BSET(buf,pos,val) (BVAL(buf,pos) = (val))
+
+
+#if CAREFUL_ALIGNMENT
+#define WVAL(buf,pos) (PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8)
+#define DVAL(buf,pos) (WVAL(buf,pos)|WVAL(buf,(pos)+2)<<16)
+
+#define SSVALX(buf,pos,val) (BVAL(buf,pos)=(val)&0xFF,BVAL(buf,pos+1)=(val)>>8)
+#define SIVALX(buf,pos,val) (SSVALX(buf,pos,val&0xFFFF),SSVALX(buf,pos+2,val>>16))
+#define WSET(buf,pos,val) { word __val = (val); \
+	SSVALX((buf),(pos),((word)(__val))); }
+#define DSET(buf,pos,val) { dword __val = (val); \
+	SIVALX((buf),(pos),((dword)(__val))); }
 #else
-#error "Currently only on 386, sorry"
+/* this handles things for architectures like the 386 that can handle
+   alignment errors */
+/*
+   WARNING: This section is dependent on the length of word and dword
+   being correct 
+*/
+#define WVAL(buf,pos) (*(word *)((char *)(buf) + (pos)))
+#define DVAL(buf,pos) (*(dword *)((char *)(buf) + (pos)))
+#define WSET(buf,pos,val) WVAL(buf,pos)=((word)(val))
+#define DSET(buf,pos,val) DVAL(buf,pos)=((dword)(val))
 #endif
 
 
+/* where to find the base of the SMB packet proper */
+#define smb_base(buf) ((byte *)(((byte *)(buf))+4))
+
 #define LANMAN1
 #define LANMAN2
 #define NT1
@@ -87,19 +114,28 @@
  * Contains all relevant data on a SMB networked file.
  */
 struct smb_dirent {
+
+	unsigned long	f_ino;
+	umode_t		f_mode;
+	nlink_t		f_nlink;
+	uid_t		f_uid;
+	gid_t		f_gid;
+	kdev_t		f_rdev;
+	off_t		f_size;
+	time_t		f_atime;
+	time_t		f_mtime;
+	time_t		f_ctime;
+	unsigned long	f_blksize;
+	unsigned long	f_blocks;
+	
         int             opened; /* is it open on the fileserver? */
 	word            fileid;	/* What id to handle a file with? */
 	word            attr;	/* Attribute fields, DOS value */
 
-        time_t atime, mtime,    /* Times, as seen by the server, normalized */
-               ctime;           /* to UTC. The ugly conversion happens in */
-                                /* proc.c */
-
-	unsigned long   size;	/* File size. */
 	unsigned short  access;	/* Access bits. */
         unsigned long   f_pos;	/* File position. (For readdir.) */
-	char*           path;   /* Complete path, MS-DOS notation, with '\' */
-	int             len;	/* Namelength. */
+	unsigned char   name[SMB_MAXNAMELEN+1];
+	int             len;	/* namelength */
 };
 
 #endif  /* __KERNEL__ */

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov