| 405 | } |
| 406 | |
| 407 | int |
| 408 | quota_write_usage(struct quotafile *qf, struct dqblk *dqb, int id) |
| 409 | { |
| 410 | struct dqblk dqbuf; |
| 411 | int qcmd; |
| 412 | |
| 413 | if (qf->fd == -1) { |
| 414 | qcmd = QCMD(Q_SETUSE, qf->quotatype); |
| 415 | return (quotactl(qf->fsname, qcmd, id, dqb)); |
| 416 | } |
| 417 | /* |
| 418 | * Have to do read-modify-write of quota in file. |
| 419 | */ |
| 420 | if ((qf->accmode & O_RDWR) != O_RDWR) { |
| 421 | errno = EBADF; |
| 422 | return (-1); |
| 423 | } |
| 424 | if (quota_read(qf, &dqbuf, id) != 0) |
| 425 | return (-1); |
| 426 | /* |
| 427 | * Reset time limit if have a soft limit and were |
| 428 | * previously under it, but are now over it. |
| 429 | */ |
| 430 | if (dqbuf.dqb_bsoftlimit && id != 0 && |
| 431 | dqbuf.dqb_curblocks < dqbuf.dqb_bsoftlimit && |
| 432 | dqb->dqb_curblocks >= dqbuf.dqb_bsoftlimit) |
| 433 | dqbuf.dqb_btime = 0; |
| 434 | if (dqbuf.dqb_isoftlimit && id != 0 && |
| 435 | dqbuf.dqb_curinodes < dqbuf.dqb_isoftlimit && |
| 436 | dqb->dqb_curinodes >= dqbuf.dqb_isoftlimit) |
| 437 | dqbuf.dqb_itime = 0; |
| 438 | dqbuf.dqb_curinodes = dqb->dqb_curinodes; |
| 439 | dqbuf.dqb_curblocks = dqb->dqb_curblocks; |
| 440 | /* |
| 441 | * Write it back. |
| 442 | */ |
| 443 | switch (qf->wordsize) { |
| 444 | case 32: |
| 445 | return (quota_write32(qf, &dqbuf, id)); |
| 446 | case 64: |
| 447 | return (quota_write64(qf, &dqbuf, id)); |
| 448 | default: |
| 449 | errno = EINVAL; |
| 450 | return (-1); |
| 451 | } |
| 452 | /* not reached */ |
| 453 | } |
| 454 | |
| 455 | int |
| 456 | quota_write_limits(struct quotafile *qf, struct dqblk *dqb, int id) |
nothing calls this directly
no test coverage detected