/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 1985-2011 AT&T Intellectual Property *4* and is licensed under the *5* Eclipse Public License, Version 1.0 *6* by AT&T Intellectual Property *7* *8* A copy of the License is available at *9* http://www.eclipse.org/org/documents/epl-v10.html *10* (with md5 checksum b35adb5213ca9657e911e9befb180842) *11* *12* Information and Software Systems Research *13* AT&T Research *14* Florham Park NJ *15* *16* Glenn Fowler <[email protected]> *17* David Korn <[email protected]> *18* Phong Vo <[email protected]> *19* *20***********************************************************************/21#pragma prototyped22/*23* Glenn Fowler24* AT&T Bell Laboratories25*26* 3d fs operations27* only active for non-shared 3d library28*/2930#define mount ______mount3132#include <ast.h>3334#undef mount3536#include <fs3d.h>3738int39fs3d(register int op)40{41register int cur;42register char* v;43char val[sizeof(FS3D_off) + 8];4445static int fsview;46static char on[] = FS3D_on;47static char off[] = FS3D_off;4849if (fsview < 0)50return 0;5152/*53* get the current setting54*/5556if (!fsview && (!getenv("LD_PRELOAD") || mount("", "", 0, NiL)))57goto nope;58if (FS3D_op(op) == FS3D_OP_INIT && mount(FS3D_init, NiL, FS3D_VIEW, NiL))59goto nope;60if (mount(on, val, FS3D_VIEW|FS3D_GET|FS3D_SIZE(sizeof(val)), NiL))61goto nope;62if (v = strchr(val, ' '))63v++;64else65v = val;66if (!strcmp(v, on))67cur = FS3D_ON;68else if (!strncmp(v, off, sizeof(off) - 1) && v[sizeof(off)] == '=')69cur = FS3D_LIMIT((int)strtol(v + sizeof(off) + 1, NiL, 0));70else71cur = FS3D_OFF;72if (cur != op)73{74switch (FS3D_op(op))75{76case FS3D_OP_OFF:77v = off;78break;79case FS3D_OP_ON:80v = on;81break;82case FS3D_OP_LIMIT:83sfsprintf(val, sizeof(val), "%s=%d", off, FS3D_arg(op));84v = val;85break;86default:87v = 0;88break;89}90if (v && mount(v, NiL, FS3D_VIEW, NiL))91goto nope;92}93fsview = 1;94return cur;95nope:96fsview = -1;97return 0;98}99100/*101* user code that includes <fs3d.h> will have mount() mapped to fs3d_mount()102* this restricts the various "standard" mount prototype conflicts to this spot103* this means that code that includes <fs3d.h> cannot access the real mount104* (at least without some additional macro hackery105*/106107#undef mount108109extern int mount(const char*, char*, int, void*);110111int112fs3d_mount(const char* source, char* target, int flags, void* data)113{114return mount(source, target, flags, data);115}116117118