From owner-freebsd-fs@freebsd.org Fri Oct 11 09:21:57 2019 Return-Path: Delivered-To: freebsd-fs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B55D6144FA2; Fri, 11 Oct 2019 09:21:57 +0000 (UTC) (envelope-from Zhichao1.Li@dell.com) Received: from mx0b-00154904.pphosted.com (mx0b-00154904.pphosted.com [148.163.137.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 46qMsc59PHz4Fnw; Fri, 11 Oct 2019 09:21:56 +0000 (UTC) (envelope-from Zhichao1.Li@dell.com) Received: from pps.filterd (m0170398.ppops.net [127.0.0.1]) by mx0b-00154904.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x9B9AMh1000485; Fri, 11 Oct 2019 05:21:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dell.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=smtpout1; bh=yLSU1q52zL6Lo2hsxDf/UXeQm1y1XY5Uz5jEuj7bXYg=; b=HCSYckYTgP1ZptjdzzKwo7wptIwMKW6DkufxDGWWFsa2QPa/XPbTURMixOH3WIlm7B6q NCF0A2M6kwVS1xi3ZukmcUw65T1vvUkvqEEQM3pXXDrfLhS2v8BXDc/u8OynYk4e76Wr MTLoADmjnrqwdkg/sew+b/GskduCjfo4Ene2dSOPlsUNoDo+wAFUMaPT+HVeSr0FD1um S9sqhkvFswR3XQ6ATnAfU1U2emEvVypTAginCaQ8mzh2gkPljXZg8KK5Kasyla4+zvPE yLNLmUPovgm/D0l3ZjtG1V2v91K4ikFqupF86H1EaqZZO2tNVZaeG8/D/e413GUiMD5d dQ== Received: from mx0b-00154901.pphosted.com (mx0b-00154901.pphosted.com [67.231.157.37]) by mx0b-00154904.pphosted.com with ESMTP id 2vepdawbju-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Oct 2019 05:21:55 -0400 Received: from pps.filterd (m0144102.ppops.net [127.0.0.1]) by mx0b-00154901.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x9B97rHl045782; Fri, 11 Oct 2019 05:21:55 -0400 Received: from ausc60pc101.us.dell.com (ausc60pc101.us.dell.com [143.166.85.206]) by mx0b-00154901.pphosted.com with ESMTP id 2vjp498uex-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Oct 2019 05:21:55 -0400 X-LoopCount0: from 10.166.135.96 X-PREM-Routing: D-Outbound X-IronPort-AV: E=Sophos;i="5.60,349,1549951200"; d="scan'208";a="1479216523" From: To: CC: , , Subject: RE: a issue about getting a devfs node's fullpath Thread-Topic: a issue about getting a devfs node's fullpath Thread-Index: AQHVf4DyNH+n5oqc4Ea+l7PCusRzvadUsvRA///jsACAAJR8UA== Date: Fri, 11 Oct 2019 09:21:49 +0000 Message-ID: <512acd5891c94cb49bba6df379202bc6@KULX13MDC103.APAC.DELL.COM> References: <20191010153932.GO44691@kib.kiev.ua> <54b7173c96df43689de04f848ca86de6@KULX13MDC103.APAC.DELL.COM> <20191011082838.GR44691@kib.kiev.ua> In-Reply-To: <20191011082838.GR44691@kib.kiev.ua> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_17cb76b2-10b8-4fe1-93d4-2202842406cd_Enabled=True; MSIP_Label_17cb76b2-10b8-4fe1-93d4-2202842406cd_SiteId=945c199a-83a2-4e80-9f8c-5a91be5752dd; MSIP_Label_17cb76b2-10b8-4fe1-93d4-2202842406cd_Owner=Zhichao_Li1@Dell.com; MSIP_Label_17cb76b2-10b8-4fe1-93d4-2202842406cd_SetDate=2019-10-11T09:21:48.1806758Z; MSIP_Label_17cb76b2-10b8-4fe1-93d4-2202842406cd_Name=External Public; MSIP_Label_17cb76b2-10b8-4fe1-93d4-2202842406cd_Application=Microsoft Azure Information Protection; MSIP_Label_17cb76b2-10b8-4fe1-93d4-2202842406cd_Extended_MSFT_Method=Manual; aiplabel=External Public x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.93.131.111] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-10-11_06:2019-10-10,2019-10-11 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 mlxlogscore=999 phishscore=0 adultscore=0 clxscore=1015 malwarescore=0 bulkscore=0 spamscore=0 suspectscore=0 priorityscore=1501 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1910110088 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 spamscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 clxscore=1015 lowpriorityscore=0 bulkscore=0 impostorscore=0 malwarescore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1910110088 X-Rspamd-Queue-Id: 46qMsc59PHz4Fnw X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org; dkim=pass header.d=dell.com header.s=smtpout1 header.b=HCSYckYT; dmarc=pass (policy=none) header.from=dell.com; spf=pass (mx1.freebsd.org: domain of Zhichao1.Li@dell.com designates 148.163.137.20 as permitted sender) smtp.mailfrom=Zhichao1.Li@dell.com X-Spamd-Result: default: False [-6.40 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; R_DKIM_ALLOW(-0.20)[dell.com:s=smtpout1]; HAS_XOIP(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; RCVD_COUNT_FIVE(0.00)[5]; R_SPF_ALLOW(-0.20)[+ip4:148.163.137.20]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; WHITELIST_SPF_DKIM(-3.00)[dell.com:d:+,dell.com:s:+]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[dell.com:+]; DMARC_POLICY_ALLOW(-0.50)[dell.com,none]; FROM_NO_DN(0.00)[]; IP_SCORE(-0.30)[ip: (0.00), ipnet: 148.163.137.0/24(0.01), asn: 22843(-1.44), country: US(-0.05)]; FREEMAIL_TO(0.00)[gmail.com]; RCVD_IN_DNSWL_LOW(-0.10)[20.137.163.148.list.dnswl.org : 127.0.3.1]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:22843, ipnet:148.163.137.0/24, country:US]; RCVD_TLS_LAST(0.00)[]; DWL_DNSWL_NONE(0.00)[dell.com.dwl.dnswl.org : 127.0.9.0] X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Oct 2019 09:21:57 -0000 sorry my bad, your pitch works exactly, thank you so much -----Original Message----- From: Konstantin Belousov =20 Sent: Friday, October 11, 2019 4:29 PM To: Li, Zhichao1 Cc: freebsd-fs@freebsd.org; freebsd-drivers@freebsd.org; Hu, Shunchao Subject: Re: a issue about getting a devfs node's fullpath [EXTERNAL EMAIL]=20 On Fri, Oct 11, 2019 at 02:23:14AM +0000, Zhichao1.Li@dell.com wrote: > Hello > Thank you for your time > Unfortunately it does not work, how about this way? It does not work in which way ? I tried it and it worked as expected. Your patch is wrong, VOP_VPTOCNP() must return parent vnode, if any. >=20 > --- a/src/sys/fs/devfs/devfs_vnops.c > +++ b/src/sys/fs/devfs/devfs_vnops.c > @@ -293,7 +293,14 @@ devfs_vptocnp(struct vop_vptocnp_args *ap) > } > bcopy(dd->de_cdp->cdp_c.si_name, buf + i, > strlen(dd->de_cdp->cdp_c.si_name)); > - de =3D dd->de_dir; > + /* > + * when dealing with VCHR > + * the element 'si_name' already > + * holds the full path string > + * except rootdir, so just go > + * to the rootdir > + */ > + de =3D dmp->dm_rootdir; > } else if (vp->v_type =3D=3D VDIR) { > if (dd =3D=3D dmp->dm_rootdir) { > *dvp =3D vp; > @@ -307,13 +314,17 @@ devfs_vptocnp(struct vop_vptocnp_args *ap) > } > bcopy(dd->de_dirent->d_name, buf + i, > dd->de_dirent->d_namlen); > - de =3D dd; > + /* > + * when dealing with VDIR > + * get its parent > + */ > + de =3D devfs_parent_dirent(dd); > } else { > error =3D ENOENT; > goto finished; > } > *buflen =3D i; > - de =3D devfs_parent_dirent(de); > + /*no need to get another parent*/ > if (de =3D=3D NULL) { > error =3D ENOENT; > goto finished; >=20 > another thing is this func is called by many modules, I want to ensure mo= difying the func this way will not impact other modules and not bring some = bugs, would you be so kind to help me out? >=20 > thank you >=20 > -----Original Message----- > From: Konstantin Belousov > Sent: Thursday, October 10, 2019 11:40 PM > To: Li, Zhichao1 > Cc: freebsd-fs@freebsd.org; freebsd-drivers@freebsd.org; Hu, Shunchao=20 > > Subject: Re: a issue about getting a devfs node's fullpath >=20 >=20 > [EXTERNAL EMAIL] >=20 > On Thu, Oct 10, 2019 at 05:49:55AM +0000, Zhichao1.Li@dell.com wrote: > > Dear freebsd developers > > I know you're swamped, so I'll be brief. > > I am trying to get a node's full under /dev by calling the function 'vn= _fullpath', when dealing with things like '/dev/null' or '/dev/usb/1.0.1', = it works well. > > However when dealing a node under more than 2 sub directories (e.g. /de= v/bus/usb/001/002) which I made by calling 'make_dev_s' , it goes a little= bit different, I got a string "/dev/bus/usb/bus/usb/001/002" > > And I found the function 'devfs_vptocnp' gets the string wrongly=20 > > when dealing multi slashes path string, I have remark the code as follo= wed and put some comments would you please take a look, and tell me what th= e purpose this func pass the string that way? >=20 > Try this. Not tested. >=20 > diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c=20 > index 3b80c68e309..f20b466d88b 100644 > --- a/sys/fs/devfs/devfs_vnops.c > +++ b/sys/fs/devfs/devfs_vnops.c > @@ -284,38 +284,27 @@ devfs_vptocnp(struct vop_vptocnp_args *ap) > if (error !=3D 0) > return (error); > =20 > - i =3D *buflen; > + if (vp->v_type !=3D VCHR && vp->v_type !=3D VDIR) { > + error =3D ENOENT; > + goto finished; > + } > + > dd =3D vp->v_data; > + if (vp->v_type =3D=3D VDIR && dd =3D=3D dmp->dm_rootdir) { > + *dvp =3D vp; > + vref(*dvp); > + goto finished; > + } > =20 > - if (vp->v_type =3D=3D VCHR) { > - i -=3D strlen(dd->de_cdp->cdp_c.si_name); > - if (i < 0) { > - error =3D ENOMEM; > - goto finished; > - } > - bcopy(dd->de_cdp->cdp_c.si_name, buf + i, > - strlen(dd->de_cdp->cdp_c.si_name)); > - de =3D dd->de_dir; > - } else if (vp->v_type =3D=3D VDIR) { > - if (dd =3D=3D dmp->dm_rootdir) { > - *dvp =3D vp; > - vref(*dvp); > - goto finished; > - } > - i -=3D dd->de_dirent->d_namlen; > - if (i < 0) { > - error =3D ENOMEM; > - goto finished; > - } > - bcopy(dd->de_dirent->d_name, buf + i, > - dd->de_dirent->d_namlen); > - de =3D dd; > - } else { > - error =3D ENOENT; > + i =3D *buflen; > + i -=3D dd->de_dirent->d_namlen; > + if (i < 0) { > + error =3D ENOMEM; > goto finished; > } > + bcopy(dd->de_dirent->d_name, buf + i, dd->de_dirent->d_namlen); > *buflen =3D i; > - de =3D devfs_parent_dirent(de); > + de =3D devfs_parent_dirent(dd); > if (de =3D=3D NULL) { > error =3D ENOENT; > goto finished;