# SamFS support for Samba 3.0.28 Updated # ----------------------------------------------------------- # The home of this patch is # http://tobi.oetiker.ch/solaris/sambasamfs # # I have put together a patch that teaches samba about SAMFS offline files. # Windows Explorer will henceforth refrain from opening these files while # you browse and thus stop the constant freezing. Instead it will grace the # offline files with nice little black watch icons. # # The patch is in unified context diff format. After unpacking samba source, # run # # patch -p0 # # DISCLAIMER: After applying this patch, your robot might eat all the tapes, # your partner could leave you for a less nerdy person and your faithful dog # will probably die. Don't come whining to me! You have been warned of this # and any other calamity that might result from using the patch. Consider # yourself disclaimed! diff -ru samba-3.0.28.orig/source/include/smb.h samba-3.0.28/source/include/smb.h --- samba-3.0.28.orig/source/include/smb.h 2007-11-15 04:15:03.000000000 +0100 +++ samba-3.0.28/source/include/smb.h 2007-12-08 00:18:59.000000000 +0100 @@ -89,6 +89,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 diff -ru samba-3.0.28.orig/source/include/smb_macros.h samba-3.0.28/source/include/smb_macros.h --- samba-3.0.28.orig/source/include/smb_macros.h 2007-11-15 04:15:03.000000000 +0100 +++ samba-3.0.28/source/include/smb_macros.h 2007-12-08 00:18:59.000000000 +0100 @@ -120,6 +120,8 @@ #define MAP_HIDDEN(conn) ((conn) && lp_map_hidden(SNUM(conn))) #define MAP_SYSTEM(conn) ((conn) && lp_map_system(SNUM(conn))) #define MAP_ARCHIVE(conn) ((conn) && lp_map_archive(SNUM(conn))) +#define MAP_OFFLINE(conn) ((conn) && lp_map_offline(SNUM(conn))) +#define MAP_OFFLINESAMFS(conn) ((conn) && lp_map_offlinesamfs(SNUM(conn))) #define IS_HIDDEN_PATH(conn,path) ((conn) && is_in_path((path),(conn)->hide_list,(conn)->case_sensitive)) #define IS_VETO_PATH(conn,path) ((conn) && is_in_path((path),(conn)->veto_list,(conn)->case_sensitive)) #define IS_VETO_OPLOCK_PATH(conn,path) ((conn) && is_in_path((path),(conn)->veto_oplock_list,(conn)->case_sensitive)) diff -ru samba-3.0.28.orig/source/lib/util.c samba-3.0.28/source/lib/util.c --- samba-3.0.28.orig/source/lib/util.c 2007-11-21 04:58:01.000000000 +0100 +++ samba-3.0.28/source/lib/util.c 2007-12-08 00:18:59.000000000 +0100 @@ -468,6 +468,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); } diff -ru samba-3.0.28.orig/source/param/loadparm.c samba-3.0.28/source/param/loadparm.c --- samba-3.0.28.orig/source/param/loadparm.c 2007-11-15 04:15:04.000000000 +0100 +++ samba-3.0.28/source/param/loadparm.c 2007-12-08 00:18:59.000000000 +0100 @@ -408,6 +408,8 @@ BOOL bMap_system; BOOL bMap_hidden; BOOL bMap_archive; + BOOL bMap_offline; + BOOL bMap_offlinesamfs; BOOL bStoreDosAttributes; BOOL bDmapiSupport; BOOL bLocking; @@ -550,6 +552,8 @@ False, /* bMap_system */ False, /* bMap_hidden */ True, /* bMap_archive */ + False, /* bMap_offline */ + False, /* bMap_offlinesamfs */ False, /* bStoreDosAttributes */ False, /* bDmapiSupport */ True, /* bLocking */ @@ -1098,6 +1102,8 @@ {"veto oplock files", P_STRING, P_LOCAL, &sDefault.szVetoOplockFiles, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL }, {"map archive", P_BOOL, P_LOCAL, &sDefault.bMap_archive, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL}, {"map hidden", P_BOOL, P_LOCAL, &sDefault.bMap_hidden, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL}, + {"map offline", P_BOOL, P_LOCAL, &sDefault.bMap_offline, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL}, + {"map offlinesamfs", P_BOOL, P_LOCAL, &sDefault.bMap_offlinesamfs, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL}, {"map system", P_BOOL, P_LOCAL, &sDefault.bMap_system, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL}, {"map readonly", P_ENUM, P_LOCAL, &sDefault.iMap_readonly, NULL, enum_map_readonly, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL}, {"mangled names", P_BOOL, P_LOCAL, &sDefault.bMangledNames, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL}, @@ -2084,6 +2090,8 @@ FN_LOCAL_BOOL(lp_print_ok, bPrint_ok) 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_map_offlinesamfs, bMap_offlinesamfs) FN_LOCAL_BOOL(lp_store_dos_attributes, bStoreDosAttributes) FN_LOCAL_BOOL(lp_dmapi_support, bDmapiSupport) FN_LOCAL_PARM_BOOL(lp_locking, bLocking) diff -ru samba-3.0.28.orig/source/smbd/dosmode.c samba-3.0.28/source/smbd/dosmode.c --- samba-3.0.28.orig/source/smbd/dosmode.c 2007-11-15 04:15:04.000000000 +0100 +++ samba-3.0.28/source/smbd/dosmode.c 2007-12-08 00:18:59.000000000 +0100 @@ -172,7 +172,20 @@ if (MAP_HIDDEN(conn) && ((sbuf->st_mode & S_IXOTH) != 0)) result |= aHIDDEN; - + + if (MAP_OFFLINE(conn)) + result |= aOFFLINE; + + /* in samfs, the st_blocks member shows the number of blocks in the disk cache + * I am using 512 and not st_blksize since samfs sets the blksize to the prefered + * blksize which is more like 64k ... but the blocks on disk seem to be 512 bytes + * this will only be relevant if you configure samfs to keep a file partially + * on disk ... otherwise offline files have st_blocks == 0 anyway. + * Tobi Oetiker */ + + if (MAP_OFFLINESAMFS(conn) && (sbuf->st_size > sbuf->st_blocks * 512 )) + result |= aOFFLINE; + if (S_ISDIR(sbuf->st_mode)) result = aDIR | (result & aRONLY); @@ -192,6 +205,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")); return result;