# SamFS support for Samba 3.5.8 # ----------------------------------------------------------- # 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.5.8.orig/source3/include/smb.h samba-3.5.8/source3/include/smb.h --- samba-3.5.8.orig/source3/include/smb.h Sun Mar 6 13:48:05 2011 +++ samba-3.5.8/source3/include/smb.h Tue Apr 19 18:18:43 2011 @@ -93,6 +93,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.5.8.orig/source3/include/smb_macros.h samba-3.5.8/source3/include/smb_macros.h --- samba-3.5.8.orig/source3/include/smb_macros.h Sun Mar 6 13:48:05 2011 +++ samba-3.5.8/source3/include/smb_macros.h Tue Apr 19 18:19:35 2011 @@ -79,6 +79,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.5.8.orig/source3/lib/util.c samba-3.5.8/source3/lib/util.c --- samba-3.5.8.orig/source3/lib/util.c Sun Mar 6 13:48:05 2011 +++ samba-3.5.8/source3/lib/util.c Tue Apr 19 18:20:15 2011 @@ -601,6 +601,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 talloc_strdup(talloc_tos(), attrstr); } diff -ru samba-3.5.8.orig/source3/param/loadparm.c samba-3.5.8/source3/param/loadparm.c --- samba-3.5.8.orig/source3/param/loadparm.c Sun Mar 6 13:48:05 2011 +++ samba-3.5.8/source3/param/loadparm.c Tue Apr 19 18:22:19 2011 @@ -453,6 +453,8 @@ bool bMap_system; bool bMap_hidden; bool bMap_archive; + bool bMap_offline; + bool bMap_offlinesamfs; bool bStoreDosAttributes; bool bDmapiSupport; bool bLocking; @@ -597,6 +599,8 @@ False, /* bMap_system */ False, /* bMap_hidden */ True, /* bMap_archive */ + False, /* bMap_offline */ + False, /* bMap_offlinesamfs */ False, /* bStoreDosAttributes */ False, /* bDmapiSupport */ True, /* bLocking */ @@ -3052,6 +3056,22 @@ .enum_list = NULL, .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL, }, + { .label = "map offline", + .type = P_BOOL, + .p_class = P_LOCAL, + .ptr = &sDefault.bMap_offline, + .special = NULL, + .enum_list = NULL, + .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL, + }, + { .label = "map offlinesamfs", + .type = P_BOOL, + .p_class = P_LOCAL, + .ptr = &sDefault.bMap_offlinesamfs, + .special = NULL, + .enum_list = NULL, + .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL, + }, { .label = "map system", .type = P_BOOL, @@ -5667,6 +5687,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.5.8.orig/source3/smbd/dosmode.c samba-3.5.8/source3/smbd/dosmode.c --- samba-3.5.8.orig/source3/smbd/dosmode.c Sun Mar 6 13:48:05 2011 +++ samba-3.5.8/source3/smbd/dosmode.c Tue Apr 19 18:23:39 2011 @@ -198,6 +198,20 @@ if (MAP_HIDDEN(conn) && ((smb_fname->st.st_ex_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) && (smb_fname->st.st_ex_blocks == 0 )) + result |= aOFFLINE; + + if (S_ISDIR(smb_fname->st.st_ex_mode)) result = aDIR | (result & aRONLY); @@ -211,6 +225,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;