Deleted Added
sdiff udiff text old ( 225784 ) new ( 225830 )
full compact
1%{
2/*-
3 * Copyright (c) 2009-2010 The FreeBSD Foundation
4 * Copyright (c) 2011 Pawel Jakub Dawidek <pawel@dawidek.net>
5 * All rights reserved.
6 *
7 * This software was developed by Pawel Jakub Dawidek under sponsorship from
8 * the FreeBSD Foundation.

--- 14 unchanged lines hidden (view full) ---

23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 * $FreeBSD: head/sbin/hastd/parse.y 225830 2011-09-28 13:08:51Z pjd $
32 */
33
34#include <sys/param.h> /* MAXHOSTNAMELEN */
35#include <sys/queue.h>
36#include <sys/socket.h>
37#include <sys/sysctl.h>
38
39#include <arpa/inet.h>

--- 23 unchanged lines hidden (view full) ---

63static char depth0_listen_tcp4[HAST_ADDRSIZE];
64static char depth0_listen_tcp6[HAST_ADDRSIZE];
65static TAILQ_HEAD(, hastd_listen) depth0_listen;
66static int depth0_replication;
67static int depth0_checksum;
68static int depth0_compression;
69static int depth0_timeout;
70static char depth0_exec[PATH_MAX];
71static int depth0_metaflush;
72
73static char depth1_provname[PATH_MAX];
74static char depth1_localpath[PATH_MAX];
75static int depth1_metaflush;
76
77extern void yyrestart(FILE *);
78
79static int
80isitme(const char *name)
81{
82 char buf[MAXHOSTNAMELEN];
83 char *pos;

--- 110 unchanged lines hidden (view full) ---

194 depth0_compression = HAST_COMPRESSION_HOLE;
195 strlcpy(depth0_control, HAST_CONTROL, sizeof(depth0_control));
196 TAILQ_INIT(&depth0_listen);
197 strlcpy(depth0_listen_tcp4, HASTD_LISTEN_TCP4,
198 sizeof(depth0_listen_tcp4));
199 strlcpy(depth0_listen_tcp6, HASTD_LISTEN_TCP6,
200 sizeof(depth0_listen_tcp6));
201 depth0_exec[0] = '\0';
202 depth0_metaflush = 1;
203
204 lconfig = calloc(1, sizeof(*lconfig));
205 if (lconfig == NULL) {
206 pjdlog_error("Unable to allocate memory for configuration.");
207 if (exitonerror)
208 exit(EX_TEMPFAIL);
209 return (NULL);
210 }

--- 115 unchanged lines hidden (view full) ---

326 if (curres->hr_exec[0] == '\0') {
327 /*
328 * Exec is not set at resource-level.
329 * Use global or default setting.
330 */
331 strlcpy(curres->hr_exec, depth0_exec,
332 sizeof(curres->hr_exec));
333 }
334 if (curres->hr_metaflush == -1) {
335 /*
336 * Metaflush is not set at resource-level.
337 * Use global or default setting.
338 */
339 curres->hr_metaflush = depth0_metaflush;
340 }
341 }
342
343 return (lconfig);
344}
345
346void
347yy_config_free(struct hastd_config *config)
348{

--- 11 unchanged lines hidden (view full) ---

360 while ((res = TAILQ_FIRST(&config->hc_resources)) != NULL) {
361 TAILQ_REMOVE(&config->hc_resources, res, hr_next);
362 free(res);
363 }
364 free(config);
365}
366%}
367
368%token CONTROL LISTEN PORT REPLICATION CHECKSUM COMPRESSION METAFLUSH
369%token TIMEOUT EXEC EXTENTSIZE RESOURCE NAME LOCAL REMOTE SOURCE ON OFF
370%token FULLSYNC MEMSYNC ASYNC NONE CRC32 SHA256 HOLE LZF
371%token NUM STR OB CB
372
373%type <str> remote_str
374%type <num> replication_type
375%type <num> checksum_type
376%type <num> compression_type
377%type <num> boolean
378
379%union
380{
381 int num;
382 char *str;
383}
384
385%token <num> NUM

--- 16 unchanged lines hidden (view full) ---

402 checksum_statement
403 |
404 compression_statement
405 |
406 timeout_statement
407 |
408 exec_statement
409 |
410 metaflush_statement
411 |
412 node_statement
413 |
414 resource_statement
415 ;
416
417control_statement: CONTROL STR
418 {
419 switch (depth) {

--- 173 unchanged lines hidden (view full) ---

593 break;
594 default:
595 PJDLOG_ABORT("exec at wrong depth level");
596 }
597 free($2);
598 }
599 ;
600
601metaflush_statement: METAFLUSH boolean
602 {
603 switch (depth) {
604 case 0:
605 depth0_metaflush = $2;
606 break;
607 case 1:
608 PJDLOG_ASSERT(curres != NULL);
609 depth1_metaflush = $2;
610 break;
611 case 2:
612 if (!mynode)
613 break;
614 PJDLOG_ASSERT(curres != NULL);
615 curres->hr_metaflush = $2;
616 break;
617 default:
618 PJDLOG_ABORT("metaflush at wrong depth level");
619 }
620 }
621 ;
622
623boolean:
624 ON { $$ = 1; }
625 |
626 OFF { $$ = 0; }
627 ;
628
629node_statement: ON node_start OB node_entries CB
630 {
631 mynode = false;
632 }
633 ;
634
635node_start: STR
636 {

--- 59 unchanged lines hidden (view full) ---

696 /*
697 * Path to local provider is not set at
698 * node-level, but is set at resource-level,
699 * use it.
700 */
701 strlcpy(curres->hr_localpath, depth1_localpath,
702 sizeof(curres->hr_localpath));
703 }
704 if (curres->hr_metaflush == -1 && depth1_metaflush != -1) {
705 /*
706 * Metaflush is not set at node-level,
707 * but is set at resource-level, use it.
708 */
709 curres->hr_metaflush = depth1_metaflush;
710 }
711
712 /*
713 * If provider name is not given, use resource name
714 * as provider name.
715 */
716 if (curres->hr_provname[0] == '\0') {
717 strlcpy(curres->hr_provname, curres->hr_name,
718 sizeof(curres->hr_provname));

--- 37 unchanged lines hidden (view full) ---

756 }
757
758 /*
759 * Clear those, so we can tell if they were set at
760 * resource-level or not.
761 */
762 depth1_provname[0] = '\0';
763 depth1_localpath[0] = '\0';
764 depth1_metaflush = -1;
765 hadmynode = false;
766
767 curres = calloc(1, sizeof(*curres));
768 if (curres == NULL) {
769 pjdlog_error("Unable to allocate memory for resource.");
770 free($1);
771 return (1);
772 }

--- 10 unchanged lines hidden (view full) ---

783 curres->hr_replication = -1;
784 curres->hr_checksum = -1;
785 curres->hr_compression = -1;
786 curres->hr_timeout = -1;
787 curres->hr_exec[0] = '\0';
788 curres->hr_provname[0] = '\0';
789 curres->hr_localpath[0] = '\0';
790 curres->hr_localfd = -1;
791 curres->hr_metaflush = -1;
792 curres->hr_remoteaddr[0] = '\0';
793 curres->hr_sourceaddr[0] = '\0';
794 curres->hr_ggateunit = -1;
795 }
796 ;
797
798resource_entries:
799 |

--- 6 unchanged lines hidden (view full) ---

806 checksum_statement
807 |
808 compression_statement
809 |
810 timeout_statement
811 |
812 exec_statement
813 |
814 metaflush_statement
815 |
816 name_statement
817 |
818 local_statement
819 |
820 resource_node_statement
821 ;
822
823name_statement: NAME STR

--- 92 unchanged lines hidden (view full) ---

916resource_node_entry:
917 name_statement
918 |
919 local_statement
920 |
921 remote_statement
922 |
923 source_statement
924 |
925 metaflush_statement
926 ;
927
928remote_statement: REMOTE remote_str
929 {
930 PJDLOG_ASSERT(depth == 2);
931 if (mynode) {
932 PJDLOG_ASSERT(curres != NULL);
933 if (strlcpy(curres->hr_remoteaddr, $2,

--- 33 unchanged lines hidden ---