[Patch v4 2/6] user need make sure "path" on mounted fs has been created

Baoquan He bhe at redhat.com
Fri Mar 28 03:08:26 UTC 2014


On 03/27/14 at 02:23pm, Vivek Goyal wrote:
> On Fri, Mar 21, 2014 at 05:55:19PM +0800, Baoquan He wrote:
 
> > +#This function compose a absolute path with the mount
> > +#point and the relative $SAVE_PATH.
> > +#target is passed in as argument, could be UUID, LABEL,
> > +#block device or even nfs server export of the form of
> > +#"my.server.com:/tmp/export"?
> > +#And possibly this could be used for both default case
> > +#as well as when dump taret is specified. When dump
> > +#target is not specified, then $target would be null.
> > +make_absolute_save_path()
> > +{
> > +    local _target=$1
> > +    local _mnt
> > +
> > +    _mnt=$(get_mntpoint_from_target $1)
> > +    echo "${_mnt}/$SAVE_PATH"
> > +}
> 
> Hmm..., Initially I was thinking that default dump target path will
> make use of make_absolute_save_path(). But in patch3 it is not being
> used. That means we don't have to expect that somebody will call 
> above with _target=NULL. We can remove that from comments above.
> 
> In fact if somebody calls it with _target=NULL, then we will pass it
> to get_mntoint_from_target(). That will return /proc for null target
> argument and you will take that and return /proc/var/crash as absolute
> path. 
> 
> So remove above comments that _target can be null. Also it would be good
> to return null if _target=null before caling get_mntpoint_from_target().

I didn't find the returned value will be /proc if null target is passed
to get_mntpoint_from_target(). Thanks for pointing this out.

However, though patch3 doesn't use this function, from the
implementation of function point of view, can we just keep the
implementation to prepare the possibility that one day someone
will need make a path with a null target? 

Then I want to change it like below, it can be used by pair of target
and save_path, also can be used with only save_path. The code matches
the name of function. How do you think about it?

make_absolute_save_path()
{                                                                                                                                                                                       
    local _target=$1
    local _mnt

    [ -n $_target ] && _mnt=$(get_mntpoint_from_target $1)
    echo "${_mnt}/$SAVE_PATH"
}

> 
> Thanks
> Vivek
> 
> > +
> > +check_save_path_fs()
> > +{
> > +    local _path=$1
> > +
> > +    if [ ! -d $_path ]; then
> > +        perror_exit "Dump path $_path does not exist."
> > +    fi
> > +}
> > +


More information about the kexec mailing list