]> arthur.barton.de Git - netatalk.git/commitdiff
New volume option volsizelimit for limitting TM backup size. From Data Robotics
authorfranklahm <franklahm>
Sat, 10 Apr 2010 08:24:54 +0000 (08:24 +0000)
committerfranklahm <franklahm>
Sat, 10 Apr 2010 08:24:54 +0000 (08:24 +0000)
NEWS
config/AppleVolumes.default.tmpl
etc/afpd/volume.c
include/atalk/volume.h
man/man5/AppleVolumes.default.5.tmpl

diff --git a/NEWS b/NEWS
index b25014ab9707bbc180516a54bd836cf95af42a37..027ef145dc84dffa62132bfafca99dac8711e9b1 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,9 @@
+Changes in 2.1-release
+======================
+
+* NEW: afpd: new volume option "volsizelimit" for limitting reported volume
+       size. Useful for limitting TM backup size.
+
 Changes in 2.1-beta2
 ====================
 * NEW: afpd: static generated AFP signature stored in afp_signature.conf,
index 5aa9a0c801e2d1c993981fd2a1a97f91e0a6a64a..4a9ada5919b4bcc0980cf10cfbc28c34afa44d2c 100644 (file)
 # 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.
 
 
 #
index 1a7380a86fc3f58bf0a2610939c723fc36e06e1b..786c58093c6fd9041ad39f12df6d7fa1981051db 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $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.
@@ -92,7 +92,8 @@ static void             free_extmap(void);
 #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 */
@@ -523,6 +524,9 @@ static void volset(struct vol_option *options, struct vol_option *save,
         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);
@@ -741,6 +745,9 @@ static int creatvol(AFPObj *obj, struct passwd *pwd,
         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))
@@ -1352,8 +1359,7 @@ static int getvolspace(struct vol *vol,
     }
 #endif
 
-    if (( rc = ustatfs_getvolspace( vol, xbfree, xbtotal,
-                                    bsize)) != AFP_OK ) {
+    if (( rc = ustatfs_getvolspace( vol, xbfree, xbtotal, bsize)) != AFP_OK ) {
         return( rc );
     }
 
@@ -1371,6 +1377,13 @@ static int getvolspace(struct vol *vol,
     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 );
index 6d2bccc6584cf5d2ab941440df7a2f4b3a09f867..f1b2084b0c9fb6ebf47e01103fc898d20f110741 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $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.
@@ -20,6 +20,8 @@
 #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;
@@ -43,6 +45,7 @@ struct vol {
     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*/
@@ -94,12 +97,6 @@ struct vol {
 #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 */
index e1c49ec58d9bc6c8ab219817101b69e270a886c1..967af699fc703a4d19ee3da9ed893fe557fe7369 100644 (file)
@@ -81,6 +81,11 @@ be treated normally any longer\&. Its only aim was to temporarely share eg\&. FA
 .RE
 .RE
 .PP
+volsizelimit:\fIsize in MiB\fR
+.RS 4
+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\&.
+.RE
+.PP
 allow:\fI[users/groups]\fR
 .RS 4
 The allow option allows the users and groups that access a share to be specified\&. Users and groups are specified, delimited by commas\&. Groups are designated by a @ prefix\&. Example: allow:user1,user2,@group