Quick diff -u for Samba_2_2 to implement forced 'offline' attribu te per share

MCCALL,DON (HP-USA,ex1) don_mccall at hp.com
Thu Mar 21 14:42:26 GMT 2002


Hi Guys,
In line with the 'offline' attribute and discussions, I put together a quick
patch on Samba_2_2 CVS to implement a simple 
map offline = true or false...
it can either be global or per share, so if you want to play around with it
and compare speeds for directory listings between the same fs with an
'offline' share and an 'online' share, you can.
I get the pretty icon that shows the file is 'offline', but interestingly
enough, I ALSO get the embedded icon that the client would have no way of
knowing without opening and reading the file for that information.  So I'm
not sure about it being any faster...
For a test I copied a .exe file with a unique embedded icon, and renamed it
on the share, and whether I looked at it via the 'map online=true' OR 'map
online=false', I still got the unique icon; only difference was on the
'offline' share, it had the little offline 'gear' superimposed on it.

Anyway, just a quick hack to let those interested play around with it...
Hope this helps,
Don

-----Original Message-----
From: root at keystone.atl.hp.com [mailto:root at keystone.atl.hp.com]
Sent: Thursday, March 21, 2002 5:03 PM
To: don_mccall at hp.com
Subject: 


Index: include/proto.h
===================================================================
RCS file: /cvsroot/samba/source/include/Attic/proto.h,v
retrieving revision 1.900.2.321
diff -u -r1.900.2.321 proto.h
--- include/proto.h	5 Mar 2002 01:17:26 -0000	1.900.2.321
+++ include/proto.h	21 Mar 2002 21:59:59 -0000
@@ -2016,6 +2016,7 @@
 BOOL lp_postscript(int );
 BOOL lp_map_hidden(int );
 BOOL lp_map_archive(int );
+BOOL lp_map_offline(int );
 BOOL lp_locking(int );
 BOOL lp_strict_locking(int );
 BOOL lp_share_modes(int );
Index: include/smb.h
===================================================================
RCS file: /cvsroot/samba/source/include/smb.h,v
retrieving revision 1.325.2.54
diff -u -r1.325.2.54 smb.h
--- include/smb.h	7 Mar 2002 04:17:23 -0000	1.325.2.54
+++ include/smb.h	21 Mar 2002 21:59:59 -0000
@@ -86,6 +86,7 @@
 #define aVOLID (1L<<3)          /* 0x08 */
 #define aDIR (1L<<4)            /* 0x10 */
 #define aARCH (1L<<5)           /* 0x20 */
+#define aOFFLINE (1L<<12)       /* 0x1000 */
 
 /* deny modes */
 #define DENY_DOS 0
@@ -1102,6 +1103,7 @@
 #define FILE_ATTRIBUTE_SPARSE 0x200L
 #define FILE_ATTRIBUTE_COMPRESSED 0x800L
 #define FILE_ATTRIBUTE_NONINDEXED 0x2000L
+#define FILE_ATTRIBUTE_OFFLINE 0x1000L 
 #define SAMBA_ATTRIBUTES_MASK 0x7F
 
 /* Flags - combined with attributes. */
Index: include/smb_macros.h
===================================================================
RCS file: /cvsroot/samba/source/include/smb_macros.h,v
retrieving revision 1.15.2.19
diff -u -r1.15.2.19 smb_macros.h
--- include/smb_macros.h	16 Jan 2002 20:27:45 -0000	1.15.2.19
+++ include/smb_macros.h	21 Mar 2002 21:59:59 -0000
@@ -103,6 +103,7 @@
 #define MAP_HIDDEN(conn)   ((conn) && lp_map_hidden((conn)->service))
 #define MAP_SYSTEM(conn)   ((conn) && lp_map_system((conn)->service))
 #define MAP_ARCHIVE(conn)   ((conn) && lp_map_archive((conn)->service))
+#define MAP_OFFLINE(conn)   ((conn) && lp_map_offline((conn)->service))
 #define IS_HIDDEN_PATH(conn,path)  ((conn) &&
is_in_path((path),(conn)->hide_list))
 #define IS_VETO_PATH(conn,path)  ((conn) &&
is_in_path((path),(conn)->veto_list))
 #define IS_VETO_OPLOCK_PATH(conn,path)  ((conn) &&
is_in_path((path),(conn)->veto_oplock_list))
cvs server: Diffing lib
Index: lib/util.c
===================================================================
RCS file: /cvsroot/samba/source/lib/util.c,v
retrieving revision 1.287.4.43
diff -u -r1.287.4.43 util.c
--- lib/util.c	28 Feb 2002 01:52:14 -0000	1.287.4.43
+++ lib/util.c	21 Mar 2002 21:59:59 -0000
@@ -251,6 +251,7 @@
   if (mode & aHIDDEN) fstrcat(attrstr,"H");
   if (mode & aSYSTEM) fstrcat(attrstr,"S");
   if (mode & aRONLY) fstrcat(attrstr,"R");	  
+  if (mode & aOFFLINE) fstrcat(attrstr,"O");	 
 
   return(attrstr);
 }
Index: param/loadparm.c
===================================================================
RCS file: /cvsroot/samba/source/param/loadparm.c,v
retrieving revision 1.251.2.88
diff -u -r1.251.2.88 loadparm.c
--- param/loadparm.c	27 Feb 2002 20:26:01 -0000	1.251.2.88
+++ param/loadparm.c	21 Mar 2002 21:59:59 -0000
@@ -373,6 +373,7 @@
 	BOOL bMap_system;
 	BOOL bMap_hidden;
 	BOOL bMap_archive;
+	BOOL bMap_offline;
 	BOOL bLocking;
 	BOOL bStrictLocking;
 	BOOL bPosixLocking;
@@ -490,6 +491,7 @@
 	False,			/* bMap_system */
 	False,			/* bMap_hidden */
 	True,			/* bMap_archive */
+	False,			/* bMap_offline */
 	True,			/* bLocking */
 	False,			/* bStrictLocking */
 	True,			/* bPosixLocking */
@@ -916,6 +918,7 @@
 	{"map system", P_BOOL, P_LOCAL, &sDefault.bMap_system, NULL, NULL,
FLAG_SHARE | FLAG_GLOBAL},
 	{"map hidden", P_BOOL, P_LOCAL, &sDefault.bMap_hidden, NULL, NULL,
FLAG_SHARE | FLAG_GLOBAL},
 	{"map archive", P_BOOL, P_LOCAL, &sDefault.bMap_archive, NULL, NULL,
FLAG_SHARE | FLAG_GLOBAL},
+	{"map offline", P_BOOL, P_LOCAL, &sDefault.bMap_offline, NULL, NULL,
FLAG_SHARE | FLAG_GLOBAL},
 	{"mangled names", P_BOOL, P_LOCAL, &sDefault.bMangledNames, NULL,
NULL, FLAG_SHARE | FLAG_GLOBAL},
 	{"mangled map", P_STRING, P_LOCAL, &sDefault.szMangledMap, NULL,
NULL, FLAG_SHARE | FLAG_GLOBAL},
 	{"stat cache", P_BOOL, P_GLOBAL, &Globals.bStatCache, NULL, NULL,
0},
@@ -1695,6 +1698,7 @@
 FN_LOCAL_BOOL(lp_postscript, bPostscript)
 FN_LOCAL_BOOL(lp_map_hidden, bMap_hidden)
 FN_LOCAL_BOOL(lp_map_archive, bMap_archive)
+FN_LOCAL_BOOL(lp_map_offline, bMap_offline)
 FN_LOCAL_BOOL(lp_locking, bLocking)
 FN_LOCAL_BOOL(lp_strict_locking, bStrictLocking)
 FN_LOCAL_BOOL(lp_share_modes, bShareModes)
Index: smbd/dosmode.c
===================================================================
RCS file: /cvsroot/samba/source/smbd/dosmode.c,v
retrieving revision 1.14.4.10
diff -u -r1.14.4.10 dosmode.c
--- smbd/dosmode.c	5 Mar 2002 01:17:41 -0000	1.14.4.10
+++ smbd/dosmode.c	21 Mar 2002 21:59:59 -0000
@@ -133,6 +133,9 @@
 
   if (MAP_HIDDEN(conn) && ((sbuf->st_mode & S_IXOTH) != 0))
     result |= aHIDDEN;   
+
+  if (MAP_OFFLINE(conn))
+    result |= aOFFLINE;   
   
   if (S_ISDIR(sbuf->st_mode))
     result = aDIR | (result & aRONLY);
@@ -171,6 +174,7 @@
   if (result & aSYSTEM) DEBUG(8, ("s"));
   if (result & aDIR   ) DEBUG(8, ("d"));
   if (result & aARCH  ) DEBUG(8, ("a"));
+  if (result & aOFFLINE  ) DEBUG(8, ("o"));
 
   DEBUG(8,("\n"));
 




More information about the samba-technical mailing list