MCPcopy Create free account
hub / github.com/F-Stack/f-stack / closefp_impl

Function closefp_impl

freebsd/kern/kern_descrip.c:1245–1284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1243}
1244
1245static int
1246closefp_impl(struct filedesc *fdp, int fd, struct file *fp, struct thread *td,
1247 bool audit)
1248{
1249 int error;
1250
1251 FILEDESC_XLOCK_ASSERT(fdp);
1252
1253 /*
1254 * We now hold the fp reference that used to be owned by the
1255 * descriptor array. We have to unlock the FILEDESC *AFTER*
1256 * knote_fdclose to prevent a race of the fd getting opened, a knote
1257 * added, and deleteing a knote for the new fd.
1258 */
1259 if (__predict_false(!TAILQ_EMPTY(&fdp->fd_kqlist)))
1260 knote_fdclose(td, fd);
1261
1262 /*
1263 * We need to notify mqueue if the object is of type mqueue.
1264 */
1265 if (__predict_false(fp->f_type == DTYPE_MQUEUE))
1266 mq_fdclose(td, fd, fp);
1267 FILEDESC_XUNLOCK(fdp);
1268
1269#ifdef AUDIT
1270 if (AUDITING_TD(td) && audit)
1271 audit_sysclose(td, fd, fp);
1272#endif
1273 error = closef(fp, td);
1274
1275 /*
1276 * All paths leading up to closefp() will have already removed or
1277 * replaced the fd in the filedesc table, so a restart would not
1278 * operate on the same file.
1279 */
1280 if (error == ERESTART)
1281 error = EINTR;
1282
1283 return (error);
1284}
1285
1286static int
1287closefp_hl(struct filedesc *fdp, int fd, struct file *fp, struct thread *td,

Callers 3

closefp_hlFunction · 0.85
closefpFunction · 0.85
fdescfree_fds_adapt_useFunction · 0.85

Calls 3

knote_fdcloseFunction · 0.85
audit_syscloseFunction · 0.85
closefFunction · 0.85

Tested by

no test coverage detected