# adouble -> specify the format of the metadata files.
# default is "v2". netatalk 1.x used "v1".
# "osx" cannot be treated normally any longer.
+# volsizelimit -> size in MiB. Useful for TimeMachine: limits the
+# reported volume size, thus preventing TM from using
+# the whole real disk space for backup.
+# Example: "volsizelimit:1000" would limit the
+# reported disk space to 1 GB.
#
/*
- * $Id: volume.c,v 1.125 2010-04-08 05:51:16 franklahm Exp $
+ * $Id: volume.c,v 1.126 2010-04-10 08:24:54 franklahm Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
#define VOLOPT_CASEFOLD 5 /* character case mangling */
#define VOLOPT_FLAGS 6 /* various flags */
#define VOLOPT_DBPATH 7 /* path to database */
-/* Usable slots: 8 and 9 */
+#define VOLOPT_LIMITSIZE 8 /* Limit the size of the volume */
+/* Usable slot: 9 */
#define VOLOPT_VETO 10 /* list of veto filespec */
#define VOLOPT_PREEXEC 11 /* preexec command */
#define VOLOPT_ROOTPREEXEC 12 /* root preexec command */
else if (strcasecmp(val + 1, "none") == 0)
options[VOLOPT_EA_VFS].i_value = AFPVOL_EA_NONE;
+ } else if (optionok(tmp, "volsizelimit:", val)) {
+ options[VOLOPT_LIMITSIZE].i_value = (uint32_t)strtoul(val + 1, NULL, 10);
+
} else {
/* ignore unknown options */
LOG(log_debug, logtype_afpd, "ignoring unknown volume option: %s", tmp);
else
volume->v_adouble = AD_VERSION;
+ if (options[VOLOPT_LIMITSIZE].i_value)
+ volume->v_limitsize = options[VOLOPT_LIMITSIZE].i_value;
+
/* Mac to Unix conversion flags*/
volume->v_mtou_flags = 0;
if (!(volume->v_flags & AFPVOL_NOHEX))
}
#endif
- if (( rc = ustatfs_getvolspace( vol, xbfree, xbtotal,
- bsize)) != AFP_OK ) {
+ if (( rc = ustatfs_getvolspace( vol, xbfree, xbtotal, bsize)) != AFP_OK ) {
return( rc );
}
vol->v_flags = ( ~AFPVOL_GVSMASK & vol->v_flags ) | AFPVOL_USTATFS;
getvolspace_done:
+ if (vol->v_limitsize) {
+ /* FIXME: Free could be limit minus (total minus used), */
+ /* which will confuse the client less ? */
+ *xbfree = min(*xbfree, (vol->v_limitsize * 1024 * 1024));
+ *xbtotal = min(*xbtotal, (vol->v_limitsize * 1024 * 1024));
+ }
+
*bfree = min( *xbfree, maxsize);
*btotal = min( *xbtotal, maxsize);
return( AFP_OK );
/*
- * $Id: volume.h,v 1.16 2010-03-31 09:47:32 franklahm Exp $
+ * $Id: volume.h,v 1.17 2010-04-10 08:24:54 franklahm Exp $
*
* Copyright (c) 1990,1994 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
#define AFPVOL_U8MNAMELEN 255 /* AFP3 sepc */
#define AFPVOL_MACNAMELEN 27 /* AFP2 spec */
+typedef u_int64_t VolSpace;
+
struct vol {
struct vol *v_next;
u_int16_t v_vid;
char *(*ad_path)(const char *, int);
struct _cnid_db *v_cdb;
char v_stamp[ADEDLEN_PRIVSYN];
+ VolSpace v_limitsize; /* Size limit, if any, in MiB */
mode_t v_umask;
mode_t v_perm; /* default permission value OR with requested perm*/
mode_t v_dperm; /* default directories permission value OR with requested perm*/
#endif /*__svr4__*/
};
-#ifdef NO_LARGE_VOL_SUPPORT
-typedef u_int32_t VolSpace;
-#else /* NO_LARGE_VOL_SUPPORT */
-typedef u_int64_t VolSpace;
-#endif /* NO_LARGE_VOL_SUPPORT */
-
#define AFPVOL_OPEN (1<<0)
/* flags for AFS and quota 0xxx0 */