# SamFS support for Samba 4.1.4 # ----------------------------------------------------------- # 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. # # I have only verified that the patched samba still compiles. I have not # tested that it does anything useful. I do not even have access to a samfs # setup anymore. # # 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-4.1.4/lib/param/param_functions.c samba-4.1.4.map_offline/lib/param/param_functions.c --- samba-4.1.4/lib/param/param_functions.c 2013-12-05 10:16:48.000000000 +0100 +++ samba-4.1.4.map_offline/lib/param/param_functions.c 2014-02-17 14:00:55.000000000 +0100 @@ -37,6 +37,8 @@ FN_LOCAL_BOOL(readonly, bRead_only) FN_LOCAL_BOOL(print_ok, bPrint_ok) FN_LOCAL_BOOL(map_hidden, bMap_hidden) +FN_LOCAL_BOOL(map_offline, bMap_offline) +FN_LOCAL_BOOL(map_offlinesamfs, bMap_offlinesamfs) FN_LOCAL_BOOL(map_archive, bMap_archive) FN_LOCAL_BOOL(oplocks, bOpLocks) FN_LOCAL_BOOL(strict_sync, bStrictSync) diff -ru samba-4.1.4/lib/param/param_table.c samba-4.1.4.map_offline/lib/param/param_table.c --- samba-4.1.4/lib/param/param_table.c 2013-12-05 10:16:48.000000000 +0100 +++ samba-4.1.4.map_offline/lib/param/param_table.c 2014-02-17 11:01:48.000000000 +0100 @@ -2510,6 +2510,24 @@ .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL, }, { + .label = "map offline", + .type = P_BOOL, + .p_class = P_LOCAL, + .offset = LOCAL_VAR(bMap_offline), + .special = NULL, + .enum_list = NULL, + .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL, + }, + { + .label = "map offlinesamfs", + .type = P_BOOL, + .p_class = P_LOCAL, + .offset = LOCAL_VAR(bMap_offlinesamfs), + .special = NULL, + .enum_list = NULL, + .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL, + }, + { .label = "map system", .type = P_BOOL, .p_class = P_LOCAL, Only in samba-4.1.4.map_offline/source3/build: __init__.pyc Only in samba-4.1.4.map_offline/source3/build: charset.pyc diff -ru samba-4.1.4/source3/include/proto.h samba-4.1.4.map_offline/source3/include/proto.h --- samba-4.1.4/source3/include/proto.h 2014-01-10 09:07:31.000000000 +0100 +++ samba-4.1.4.map_offline/source3/include/proto.h 2014-02-17 11:07:45.000000000 +0100 @@ -1287,6 +1287,8 @@ bool lp_print_ok(int ); bool lp_print_notify_backchannel(int ); bool lp_map_hidden(int ); +bool lp_map_offline(int ); +bool lp_map_offlinesamfs(int ); bool lp_map_archive(int ); bool lp_store_dos_attributes(int ); bool lp_dmapi_support(int ); diff -ru samba-4.1.4/source3/include/smb_macros.h samba-4.1.4.map_offline/source3/include/smb_macros.h --- samba-4.1.4/source3/include/smb_macros.h 2013-12-05 10:16:48.000000000 +0100 +++ samba-4.1.4.map_offline/source3/include/smb_macros.h 2014-02-17 13:55:45.000000000 +0100 @@ -76,6 +76,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-4.1.4/source3/param/loadparm.c samba-4.1.4.map_offline/source3/param/loadparm.c --- samba-4.1.4/source3/param/loadparm.c 2013-12-05 10:16:48.000000000 +0100 +++ samba-4.1.4.map_offline/source3/param/loadparm.c 2014-02-17 11:02:13.000000000 +0100 @@ -221,6 +221,8 @@ .bPrintNotifyBackchannel = true, .bMap_system = false, .bMap_hidden = false, + .bMap_offline = false, + .bMap_offlinesamfs = false, .bMap_archive = true, .bStoreDosAttributes = false, .bDmapiSupport = false, diff -ru samba-4.1.4/source3/smbd/dosmode.c samba-4.1.4.map_offline/source3/smbd/dosmode.c --- samba-4.1.4/source3/smbd/dosmode.c 2013-12-05 10:16:48.000000000 +0100 +++ samba-4.1.4.map_offline/source3/smbd/dosmode.c 2014-02-17 11:27:52.000000000 +0100 @@ -196,6 +196,20 @@ if (MAP_HIDDEN(conn) && ((smb_fname->st.st_ex_mode & S_IXOTH) != 0)) result |= FILE_ATTRIBUTE_HIDDEN; + + if (MAP_OFFLINE(conn)) + result |= FILE_ATTRIBUTE_OFFLINE; + + /* 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 |= FILE_ATTRIBUTE_OFFLINE; + if (S_ISDIR(smb_fname->st.st_ex_mode)) result = FILE_ATTRIBUTE_DIRECTORY | (result & FILE_ATTRIBUTE_READONLY); @@ -208,6 +222,7 @@ if (result & FILE_ATTRIBUTE_SYSTEM) DEBUG(8, ("s")); if (result & FILE_ATTRIBUTE_DIRECTORY ) DEBUG(8, ("d")); if (result & FILE_ATTRIBUTE_ARCHIVE ) DEBUG(8, ("a")); + if (result & FILE_ATTRIBUTE_OFFLINE ) DEBUG(8, ("o")); DEBUG(8,("\n")); return result;