From owner-freebsd-questions@FreeBSD.ORG Sun Jun 15 17:01:39 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8C5CE1065670 for ; Sun, 15 Jun 2008 17:01:39 +0000 (UTC) (envelope-from chuckr@telenix.org) Received: from mail8.sea5.speakeasy.net (mail8.sea5.speakeasy.net [69.17.117.10]) by mx1.freebsd.org (Postfix) with ESMTP id 6D0C58FC1D for ; Sun, 15 Jun 2008 17:01:39 +0000 (UTC) (envelope-from chuckr@telenix.org) Received: (qmail 11504 invoked from network); 15 Jun 2008 17:01:38 -0000 Received: from april.chuckr.org (HELO april.telenix.org) (chuckr@[66.92.151.30]) (envelope-sender ) by mail8.sea5.speakeasy.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP for ; 15 Jun 2008 17:01:38 -0000 Message-ID: <4855487B.5090303@telenix.org> Date: Sun, 15 Jun 2008 12:51:07 -0400 From: Chuck Robey User-Agent: Thunderbird 2.0.0.6 (X11/20071107) MIME-Version: 1.0 To: Chris Whitehouse References: <485453CE.3040908@onetel.com> <20080615014316.0723f0da@gumby.homeunix.com.> <48546AC3.5010506@onetel.com> In-Reply-To: <48546AC3.5010506@onetel.com> X-Enigmail-Version: 0.95.5 OpenPGP: id=F3DCA0E9; url=http://pgp.mit.edu Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: RW , freebsd-questions@freebsd.org Subject: Re: how to view environment variables X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Jun 2008 17:01:39 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Chris Whitehouse wrote: > RW wrote: >> On Sun, 15 Jun 2008 00:27:10 +0100 >> Chris Whitehouse wrote: >> >>> Hello, >>> >>> sysutils/fusefs-ntfs/files/README.FreeBSD refers to various >>> environment variables, eg UBLIO_BLOCKSIZE and others. How do I find >>> out what they are set to? set and printenv don't find them. I'm using >>> standard csh and FreeBSD 7.0-STABLE, fuse.ko is loaded and ntfs-3g >>> works except it seems very slow. >> >> If you didn't set them, they probably aren't set. You'll need to >> consult the fusefs-ntfs documentation (or source) to find the default >> value. > > I think this explains part of my confusion. If the variables are not set > ntfs-3g assumes some defaults (in README.FreeBSD) but doesn't set them > as environment variables. I thought ntfs-3g would actually set them. I > still don't know how to view them when I have explicitly set them, as > per previous reply to Robert Huff. > > eco# env UBLIO_BLOCKSIZE=65536 ntfs-3g /dev/ad0s1 /ad0s1 > eco# setenv |grep UBLIO > eco# I just picked up on this ... environmental variables are part of the private environment of programs. Those variables are given to any child programs. If the programs are shells, shells specialize in creating child programs, so all those environmental variables get given to the children. A filesystem doesn't create children, it just organizes the storage and presentation of disk data, so when you set a environmental variable to a filesystem, it may react to that variable if it is programmed that way, but it doesn't send it anywhere. If you want to see the variable in your shell, then you must tell the shell to set it in it's environment. For a sh-like shell, you would do something like: export UBLIO_BLOCKSIZE=65536 For a csh-like shell, use: setenv UBLIO_BLOCKSIZE 65536 (Notice that a csh-like shell DOESN'T use the "="). Your filesystem prog is being told of your variable above, but your attempt to see it is misguided. There was a way to see the information, using the e option to ps, but it was always a security problem, so it seems like that was removed from FreeBSD (it's probably controlled by a sysctl). I think it still works in most linuxes. Reading the variables is very easy to do with the "env" program, where if you give it no args, it repeats all the variables. Try it. It works for all shells, unlike your "setenv", because it's an actual program (/usr/bin/env). setenv is, for a csh-like shell, a shell built-in, not a real program. The way it goes to programs is via 3 variables given to every program. They are, in the order they're presented: 1- argc, which means the number of parameters given to the program by the shell 2- argv, a list of string pointers, to program parameters 3- envp, a list of string pointers, to name=value pairs, for all environmental variables given to each program. Those names are only the commonly used names, they may be changed completely at will, because the system only gives the info in the order I gave, and doesn't associate the info with any names. Your program needs to associate some names to the parameters so that you can manipulate them, and using these names is a good idea so as not to confuse other programmers, just don't get the idea that those names have any real magic meaning on their own. I could write a program using manny, moe, and jack as the names of the 3 items given to a program, and (beyond making things confusing) that program would work just fine. Writing a small program that annouces the arguments count, and prints all of the parameters, and all of the env. variables, makes a fine beginners first program. > > Chris > >> _______________________________________________ >> freebsd-questions@freebsd.org mailing list >> http://lists.freebsd.org/mailman/listinfo/freebsd-questions >> To unsubscribe, send any mail to >> "freebsd-questions-unsubscribe@freebsd.org" >> > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to > "freebsd-questions-unsubscribe@freebsd.org" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4 (FreeBSD) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFIVUh7z62J6PPcoOkRAp5+AKCAuGFkXoiWMzthzPqpQfR3lGPamQCdH9KI UJwnNE1c7ox5JrSwHoEzJWo= =4Oue -----END PGP SIGNATURE-----