# SamFS support for Samba 3.0.24 # ----------------------------------------------------------- # 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.24/source/include/smb.h samba-3.0.24.samfs/source/include/smb.h --- samba-3.0.24/source/include/smb.h 2007-02-04 19:59:23.000000000 +0100 +++ samba-3.0.24.samfs/source/include/smb.h 2007-03-16 12:11:33.000000000 +0100 @@ -94,6 +94,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.24/source/include/smb_macros.h samba-3.0.24.samfs/source/include/smb_macros.h --- samba-3.0.24/source/include/smb_macros.h 2006-04-20 04:29:39.000000000 +0200 +++ samba-3.0.24.samfs/source/include/smb_macros.h 2007-03-16 12:11:33.000000000 +0100 @@ -137,6 +137,8 @@ #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 MAP_OFFLINESAMFS(conn) ((conn) && lp_map_offlinesamfs((conn)->service)) #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.24/source/lib/util.c samba-3.0.24.samfs/source/lib/util.c --- samba-3.0.24/source/lib/util.c 2007-02-04 19:59:17.000000000 +0100 +++ samba-3.0.24.samfs/source/lib/util.c 2007-03-16 12:11:33.000000000 +0100 @@ -469,6 +469,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.24/source/param/loadparm.c samba-3.0.24.samfs/source/param/loadparm.c --- samba-3.0.24/source/param/loadparm.c 2007-02-04 19:59:13.000000000 +0100 +++ samba-3.0.24.samfs/source/param/loadparm.c 2007-03-16 12:12:13.000000000 +0100 @@ -403,6 +403,8 @@ BOOL bMap_system; BOOL bMap_hidden; BOOL bMap_archive; + BOOL bMap_offline; + BOOL bMap_offlinesamfs; BOOL bStoreDosAttributes; BOOL bDmapiSupport; BOOL bLocking; @@ -542,6 +544,8 @@ False, /* bMap_system */ False, /* bMap_hidden */ True, /* bMap_archive */ + False, /* bMap_offline */ + False, /* bMap_offlinesamfs */ False, /* bStoreDosAttributes */ False, /* bDmapiSupport */ True, /* bLocking */ @@ -1083,6 +1087,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}, @@ -2006,6 +2012,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_BOOL(lp_locking, bLocking) diff -ru samba-3.0.24/source/smbd/dosmode.c samba-3.0.24.samfs/source/smbd/dosmode.c --- samba-3.0.24/source/smbd/dosmode.c 2007-02-04 19:59:13.000000000 +0100 +++ samba-3.0.24.samfs/source/smbd/dosmode.c 2007-03-16 12:11:33.000000000 +0100 @@ -177,7 +177,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); @@ -197,6 +210,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; Only in samba-3.0.24.samfs/source/smbd: dosmode.c.orig