14887Schin /*********************************************************************** 24887Schin * * 34887Schin * This software is part of the ast package * 4*12068SRoger.Faulkner@Oracle.COM * Copyright (c) 1985-2010 AT&T Intellectual Property * 54887Schin * and is licensed under the * 64887Schin * Common Public License, Version 1.0 * 78462SApril.Chin@Sun.COM * by AT&T Intellectual Property * 84887Schin * * 94887Schin * A copy of the License is available at * 104887Schin * http://www.opensource.org/licenses/cpl1.0.txt * 114887Schin * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) * 124887Schin * * 134887Schin * Information and Software Systems Research * 144887Schin * AT&T Research * 154887Schin * Florham Park NJ * 164887Schin * * 174887Schin * Glenn Fowler <gsf@research.att.com> * 184887Schin * David Korn <dgk@research.att.com> * 194887Schin * Phong Vo <kpv@research.att.com> * 204887Schin * * 214887Schin ***********************************************************************/ 224887Schin #pragma prototyped 234887Schin /* 244887Schin * Glenn Fowler 254887Schin * AT&T Bell Laboratories 264887Schin * 274887Schin * 3d fs operations 284887Schin * only active for non-shared 3d library 294887Schin */ 304887Schin 3110898Sroland.mainz@nrubsig.org #define mount ______mount 3210898Sroland.mainz@nrubsig.org 334887Schin #include <ast.h> 3410898Sroland.mainz@nrubsig.org 3510898Sroland.mainz@nrubsig.org #undef mount 3610898Sroland.mainz@nrubsig.org 374887Schin #include <fs3d.h> 384887Schin 394887Schin int 404887Schin fs3d(register int op) 414887Schin { 424887Schin register int cur; 434887Schin register char* v; 444887Schin char val[sizeof(FS3D_off) + 8]; 454887Schin 464887Schin static int fsview; 474887Schin static char on[] = FS3D_on; 484887Schin static char off[] = FS3D_off; 494887Schin 508462SApril.Chin@Sun.COM if (fsview < 0) 518462SApril.Chin@Sun.COM return 0; 524887Schin 534887Schin /* 544887Schin * get the current setting 554887Schin */ 564887Schin 578462SApril.Chin@Sun.COM if (!fsview && (!getenv("LD_PRELOAD") || mount("", "", 0, NiL))) 584887Schin goto nope; 594887Schin if (FS3D_op(op) == FS3D_OP_INIT && mount(FS3D_init, NiL, FS3D_VIEW, NiL)) 604887Schin goto nope; 614887Schin if (mount(on, val, FS3D_VIEW|FS3D_GET|FS3D_SIZE(sizeof(val)), NiL)) 624887Schin goto nope; 638462SApril.Chin@Sun.COM if (v = strchr(val, ' ')) 648462SApril.Chin@Sun.COM v++; 658462SApril.Chin@Sun.COM else 668462SApril.Chin@Sun.COM v = val; 674887Schin if (!strcmp(v, on)) 684887Schin cur = FS3D_ON; 694887Schin else if (!strncmp(v, off, sizeof(off) - 1) && v[sizeof(off)] == '=') 704887Schin cur = FS3D_LIMIT((int)strtol(v + sizeof(off) + 1, NiL, 0)); 718462SApril.Chin@Sun.COM else 728462SApril.Chin@Sun.COM cur = FS3D_OFF; 734887Schin if (cur != op) 744887Schin { 754887Schin switch (FS3D_op(op)) 764887Schin { 774887Schin case FS3D_OP_OFF: 784887Schin v = off; 794887Schin break; 804887Schin case FS3D_OP_ON: 814887Schin v = on; 824887Schin break; 834887Schin case FS3D_OP_LIMIT: 844887Schin sfsprintf(val, sizeof(val), "%s=%d", off, FS3D_arg(op)); 854887Schin v = val; 864887Schin break; 874887Schin default: 884887Schin v = 0; 894887Schin break; 904887Schin } 914887Schin if (v && mount(v, NiL, FS3D_VIEW, NiL)) 924887Schin goto nope; 934887Schin } 944887Schin fsview = 1; 958462SApril.Chin@Sun.COM return cur; 964887Schin nope: 974887Schin fsview = -1; 988462SApril.Chin@Sun.COM return 0; 994887Schin } 10010898Sroland.mainz@nrubsig.org 10110898Sroland.mainz@nrubsig.org /* 10210898Sroland.mainz@nrubsig.org * user code that includes <fs3d.h> will have mount() mapped to fs3d_mount() 10310898Sroland.mainz@nrubsig.org * this restricts the various "standard" mount prototype conflicts to this spot 10410898Sroland.mainz@nrubsig.org * this means that code that includes <fs3d.h> cannot access the real mount 10510898Sroland.mainz@nrubsig.org * (at least without some additional macro hackery 10610898Sroland.mainz@nrubsig.org */ 10710898Sroland.mainz@nrubsig.org 10810898Sroland.mainz@nrubsig.org #undef mount 10910898Sroland.mainz@nrubsig.org 11010898Sroland.mainz@nrubsig.org extern int mount(const char*, char*, int, void*); 11110898Sroland.mainz@nrubsig.org 11210898Sroland.mainz@nrubsig.org int 11310898Sroland.mainz@nrubsig.org fs3d_mount(const char* source, char* target, int flags, void* data) 11410898Sroland.mainz@nrubsig.org { 11510898Sroland.mainz@nrubsig.org return mount(source, target, flags, data); 11610898Sroland.mainz@nrubsig.org } 117