130
133
struct componentname *a_cnp;
133
struct vnode *vdp; /* vnode for directory being searched */
137
return (ufs_lookup_(ap->a_dvp, ap->a_vpp, ap->a_cnp, NULL));
141
ufs_lookup_(struct vnode *vdp, struct vnode **vpp, struct componentname *cnp,
134
144
struct inode *dp; /* inode for directory being searched */
135
145
struct buf *bp; /* a buffer of directory entries */
136
146
struct direct *ep; /* the current directory entry */
150
160
doff_t enduseful; /* pointer past last used dir slot */
151
161
u_long bmask; /* block offset mask */
152
162
int namlen, error;
153
struct vnode **vpp = ap->a_vpp;
154
struct componentname *cnp = ap->a_cnp;
155
163
struct ucred *cred = cnp->cn_cred;
156
164
int flags = cnp->cn_flags;
157
165
int nameiop = cnp->cn_nameiop;
158
166
struct thread *td = cnp->cn_thread;
165
* XXX there was a soft-update diff about this I couldn't merge.
166
* I think this was the equiv.
581
593
error = vn_vget_ino(pdp, ino, cnp->cn_lkflags, &tdp);
598
* Recheck that ".." entry in the vdp directory points
599
* to the inode we looked up before vdp lock was
602
error = ufs_lookup_(pdp, NULL, cnp, &ino1);
585
613
} else if (dp->i_number == ino) {
586
614
VREF(vdp); /* we want ourself, ie "." */
1242
ufs_dir_dd_ino(struct vnode *vp, struct ucred *cred, ino_t *dd_ino)
1244
struct dirtemplate dirbuf;
1247
if (vp->v_type != VDIR)
1249
error = vn_rdwr(UIO_READ, vp, (caddr_t)&dirbuf,
1250
sizeof (struct dirtemplate), (off_t)0, UIO_SYSSPACE,
1251
IO_NODELOCKED | IO_NOMACCHECK, cred, NOCRED, NULL, NULL);
1254
#if (BYTE_ORDER == LITTLE_ENDIAN)
1256
namlen = dirbuf.dotdot_type;
1258
namlen = dirbuf.dotdot_namlen;
1260
namlen = dirbuf.dotdot_namlen;
1262
if (namlen != 2 || dirbuf.dotdot_name[0] != '.' ||
1263
dirbuf.dotdot_name[1] != '.')
1265
*dd_ino = dirbuf.dotdot_ino;
1214
1270
* Check if source directory is in the path of the target directory.
1215
1271
* Target is supplied locked, source is unlocked.
1216
1272
* The target is always vput before returning.
1219
ufs_checkpath(source, target, cred)
1220
struct inode *source, *target;
1275
ufs_checkpath(ino_t source_ino, struct inode *target, struct ucred *cred)
1226
struct dirtemplate dirbuf;
1277
struct vnode *vp, *vp1;
1228
1281
vp = ITOV(target);
1229
if (target->i_number == source->i_number) {
1282
if (target->i_number == source_ino) {
1230
1283
error = EEXIST;
1235
if (target->i_number == rootino)
1287
if (target->i_number == ROOTINO)
1239
if (vp->v_type != VDIR) {
1243
error = vn_rdwr(UIO_READ, vp, (caddr_t)&dirbuf,
1244
sizeof (struct dirtemplate), (off_t)0, UIO_SYSSPACE,
1245
IO_NODELOCKED | IO_NOMACCHECK, cred, NOCRED, (int *)0,
1246
(struct thread *)0);
1291
error = ufs_dir_dd_ino(vp, cred, &dd_ino);
1247
1292
if (error != 0)
1249
# if (BYTE_ORDER == LITTLE_ENDIAN)
1251
namlen = dirbuf.dotdot_type;
1253
namlen = dirbuf.dotdot_namlen;
1255
namlen = dirbuf.dotdot_namlen;
1258
dirbuf.dotdot_name[0] != '.' ||
1259
dirbuf.dotdot_name[1] != '.') {
1263
if (dirbuf.dotdot_ino == source->i_number) {
1294
if (dd_ino == source_ino) {
1264
1295
error = EINVAL;
1267
if (dirbuf.dotdot_ino == rootino)
1298
if (dd_ino == ROOTINO)
1300
error = vn_vget_ino(vp, dd_ino, LK_EXCLUSIVE, &vp1);
1303
/* Recheck that ".." still points to vp1 after relock of vp */
1304
error = ufs_dir_dd_ino(vp, cred, &dd_ino);
1309
/* Redo the check of ".." if directory was reparented */
1310
if (dd_ino != VTOI(vp1)->i_number) {
1270
error = VFS_VGET(vp->v_mount, dirbuf.dotdot_ino,