tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: fcntl(F_GETPATH) support



On 14.09.2019 23:34, Christos Zoulas wrote:
> Comments?
> 

Question. How does it handle symbolic/hardlinks?

> christos
> 
> 
> Index: kern/sys_descrip.c
> ===================================================================
> RCS file: /cvsroot/src/sys/kern/sys_descrip.c,v
> retrieving revision 1.34
> diff -u -p -u -r1.34 sys_descrip.c
> --- kern/sys_descrip.c	26 Aug 2019 10:19:08 -0000	1.34
> +++ kern/sys_descrip.c	14 Sep 2019 21:33:29 -0000
> @@ -315,6 +312,28 @@ do_fcntl_lock(int fd, int cmd, struct fl
>  	return error;
>  }
>  
> +static int
> +do_fcntl_getpath(struct lwp *l, file_t *fp, char *upath)
> +{
> +	char *kpath;
> +	int error;
> +
> +	if (fp->f_type != DTYPE_VNODE)
> +		return EOPNOTSUPP;
> +
> +	kpath = PNBUF_GET();
> +
> +	error = vnode_to_path(kpath, MAXPATHLEN, fp->f_vnode, l, l->l_proc);
> +	if (error)
> +		goto out;
> +
> +	error = copyoutstr(kpath, upath, MAXPATHLEN, NULL);
> +out:
> +	PNBUF_PUT(kpath);
> +
> +	return error;
> +}
> +	
>  /*
>   * The file control system call.
>   */
> @@ -463,6 +482,10 @@ sys_fcntl(struct lwp *l, const struct sy
>  		error = (*fp->f_ops->fo_ioctl)(fp, FIOSETOWN, &tmp);
>  		break;
>  
> +	case F_GETPATH:
> +		error = do_fcntl_getpath(l, fp, SCARG(uap, arg));
> +		break;
> +
>  	default:
>  		error = EINVAL;
>  	}
> Index: sys/fcntl.h
> ===================================================================
> RCS file: /cvsroot/src/sys/sys/fcntl.h,v
> retrieving revision 1.50
> diff -u -p -u -r1.50 fcntl.h
> --- sys/fcntl.h	20 Feb 2018 18:20:05 -0000	1.50
> +++ sys/fcntl.h	14 Sep 2019 21:33:29 -0000
> @@ -193,6 +195,7 @@
>  #define	F_DUPFD_CLOEXEC	12		/* close on exec duplicated fd */
>  #define	F_GETNOSIGPIPE	13		/* get SIGPIPE disposition */
>  #define	F_SETNOSIGPIPE	14		/* set SIGPIPE disposition */
> +#define	F_GETPATH	15		/* get pathname assosiated with file */
>  #endif
>  
>  /* file descriptor flags (F_GETFD, F_SETFD) */
> 


Attachment: signature.asc
Description: OpenPGP digital signature



Home | Main Index | Thread Index | Old Index