summaryrefslogtreecommitdiffstats
path: root/utils/mount/parse_opt.h
Commit message (Collapse)AuthorAgeFilesLines
* pdate addres for Free Software FoundationNeilBrown2011-08-291-2/+2
| | | | | | | | | | | | License texts contain multiple address for FSF, some wrong. So update them and replace COPYING file with http://www.gnu.org/licenses/gpl-2.0.txt which has a few changes to preamble and commentary. Also remove extra COPYING file from utils/statd/ Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: Add API to duplicate a mount option listChuck Lever2009-09-291-0/+1
| | | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* text-based mount command: fix return value from po_rightmost()Chuck Lever2009-02-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Recently commit 0dcb83a8 changed the po_rightmost() function to distinguish among several possible mount options by taking a table containing the alternatives, and returning the table index of the entry which is rightmost in the mount option string. If it didn't find any mount option that matches an entry from the passed-in table, it returned zero. This was the same behavior it had before, when it only checked for two options at a time. It returned PO_NEITHER_FOUND, which was zero. Since this is C, however, zero also happens to be a valid index into the passed-in array of options. Modify the po_rightmost() function to return -1 if the entry wasn't found, and fix up the callers to look for a C-style array index that starts at zero. Thanks to Steve Dickson for troubleshooting the problem. His solution was merely to bump the return value, as callers already expected an ordinal index instead of a C-style index. I prefer this equivalent but slightly more extensive change because it makes the behavior of po_rightmost() more closely match how humans understand C arrays to work. Let's address some of the confusion that caused this bug, as well as fixing the run-time behavior. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* text-based mount command: make po_rightmost() work for N optionsChuck Lever2009-01-271-7/+2
| | | | | | | | | | | Sometimes we need to choose the rightmost option among multiple different mount options. For example, we want to find the rightmost of "proto," "tcp," and "udp". Or, the rightmost of "vers," "nfsvers," "v2," and "v3". Update po_rightmost() to choose among N options instead of just two. Signed-off-by: Steve Dickson <steved@redhat.com>
* text-based mount command: add function to parse numeric mount optionsChuck Lever2008-12-171-0/+3
| | | | | | | | Introduce a function that is especially for parsing keyword mount options that take a numeric value. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Clean up: add the traditional pre-processor safety check in headers underChuck Lever2008-07-151-0/+5
| | | | | | | | | | utils/mount to prevent them from being included multiple times. For headers that already have this, use a more unique macro name to reduce the probability that some other header may use the same macro. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* text-based mount.nfs: Fix po_rightmost() enum return valuesChuck Lever2007-10-121-12/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Neil observed that po_rightmost() now returns enum values from both enum { PO_NOT_FOUND = 0, PO_FOUND = 1, } and enum { PO_KEY2_RIGHTMOST = 1, PO_KEY1_RIGHTMOST = -1, } It would be cleaner to use a single enum for po_rightmost()'s return value. We take the next logical step and create specific types for the return values in order to ensure we don't mix the enum values, and to document explicitly what return values callers can expect. This could have been a simpler patch, but I think the end result is a cleaner overall parser API. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
* text-based mount.nfs: add a few useful parser return codesChuck Lever2007-10-111-0/+5
| | | | | | | | I forgot to add symbolic return codes for po_rightmost(). Add return codes for PO_KEY1_RIGHTMOST and PO_KEY2_RIGHTMOST. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
* text-based mount.nfs: parse option strings into listsChuck Lever2007-09-291-0/+46
Adapt a parsing trick used by Python. Parse mount option strings into an abstract data type so we don't have to copy and/or tokenize the whole option string multiple times while trying to manipulate the mount options. Then, just before calling the mount(2) system call, convert the object back into a C string. One major advantage of this approach is that we can copy the final version of the mount options into /etc/mtab when we're done, instead of copying in the original mount options that the user specified. Any fallback from NFS v3 to NFS v2 or TCP to UDP that was done by mount.nfs will be reflected in /etc/mtab. This patch adds methods for creating and manipulating mount option data objects. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>