# SamFS support for Samba 3.0.20 # ----------------------------------------------------------- # 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 may eat all the tapes, # your partner may leave you for a less nerdy person and your faithful dog # could die. Don't come whining to me! You have been warned and thus # disclaimed! diff -u -r samba-3.0.20/source/include/smb.h new/source/include/smb.h --- samba-3.0.20/source/include/smb.h 2005-07-28 15:19:50.000000000 +0200 +++ new/source/include/smb.h 2005-10-18 23:15:37.880371000 +0200 @@ -90,6 +90,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 -u -r samba-3.0.20/source/include/smb_macros.h new/source/include/smb_macros.h --- samba-3.0.20/source/include/smb_macros.h 2005-07-28 15:19:50.000000000 +0200 +++ new/source/include/smb_macros.h 2005-10-18 23:15:37.880375000 +0200 @@ -133,6 +133,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 -u -r samba-3.0.20/source/lib/util.c new/source/lib/util.c --- samba-3.0.20/source/lib/util.c 2005-08-19 19:16:27.000000000 +0200 +++ new/source/lib/util.c 2005-10-18 23:15:37.880367000 +0200 @@ -438,6 +438,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 -u -r samba-3.0.20/source/param/loadparm.c new/source/param/loadparm.c --- samba-3.0.20/source/param/loadparm.c 2005-07-28 15:19:44.000000000 +0200 +++ new/source/param/loadparm.c 2005-10-18 23:15:37.810444000 +0200 @@ -398,6 +398,8 @@ BOOL bMap_system; BOOL bMap_hidden; BOOL bMap_archive; + BOOL bMap_offline; + BOOL bMap_offlinesamfs; BOOL bStoreDosAttributes; BOOL bLocking; int iStrictLocking; @@ -531,6 +533,8 @@ False, /* bMap_system */ False, /* bMap_hidden */ True, /* bMap_archive */ + False, /* bMap_offline */ + False, /* bMap_offlinesamfs */ False, /* bStoreDosAttributes */ True, /* bLocking */ True, /* iStrictLocking */ @@ -1050,6 +1054,8 @@ {"map system", P_BOOL, P_LOCAL, &sDefault.bMap_system, 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 archive", P_BOOL, P_LOCAL, &sDefault.bMap_archive, 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}, {"mangled names", P_BOOL, P_LOCAL, &sDefault.bMangledNames, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL}, {"mangled map", P_STRING, P_LOCAL, &sDefault.szMangledMap, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL | FLAG_DEPRECATED }, {"max stat cache size", P_INTEGER, P_GLOBAL, &Globals.iMaxStatCacheSize, NULL, NULL, FLAG_ADVANCED}, @@ -1948,6 +1954,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_locking, bLocking) FN_LOCAL_INTEGER(lp_strict_locking, iStrictLocking) diff -u -r samba-3.0.20/source/smbd/dosmode.c new/source/smbd/dosmode.c --- samba-3.0.20/source/smbd/dosmode.c 2005-07-28 15:19:43.000000000 +0200 +++ new/source/smbd/dosmode.c 2005-10-18 23:15:37.810418000 +0200 @@ -146,7 +146,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); @@ -166,6 +179,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;