Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/uipc_shm.c
| Show First 20 Lines • Show All 691 Lines • ▼ Show 20 Lines | #endif | ||||
| } | } | ||||
| } | } | ||||
| return (ENOENT); | return (ENOENT); | ||||
| } | } | ||||
| int | int | ||||
| kern_shm_open(struct thread *td, const char *userpath, int flags, mode_t mode, | kern_shm_open(struct thread *td, const char *userpath, int flags, mode_t mode, | ||||
| struct filecaps *fcaps) | struct filecaps *fcaps, struct file **fpp) | ||||
| { | { | ||||
| struct filedesc *fdp; | struct filedesc *fdp; | ||||
| struct shmfd *shmfd; | struct shmfd *shmfd; | ||||
| struct file *fp; | struct file *fp; | ||||
| char *path; | char *path; | ||||
| const char *pr_path; | const char *pr_path; | ||||
| size_t pr_pathlen; | size_t pr_pathlen; | ||||
| Fnv32_t fnv; | Fnv32_t fnv; | ||||
| ▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | |||||
| #endif | #endif | ||||
| } else { | } else { | ||||
| free(path, M_SHMFD); | free(path, M_SHMFD); | ||||
| error = ENOENT; | error = ENOENT; | ||||
| } | } | ||||
| } else { | } else { | ||||
| /* | /* | ||||
| * Object already exists, obtain a new | * Object already exists, obtain a new | ||||
| * reference if requested and permitted. | * reference if requested and permitted. | ||||
kib: According to style, there should be a blank line before multiline comment. | |||||
| */ | */ | ||||
| free(path, M_SHMFD); | free(path, M_SHMFD); | ||||
| if ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) | if ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) | ||||
| error = EEXIST; | error = EEXIST; | ||||
| else { | else { | ||||
| #ifdef MAC | #ifdef MAC | ||||
| error = mac_posixshm_check_open(td->td_ucred, | error = mac_posixshm_check_open(td->td_ucred, | ||||
| shmfd, FFLAGS(flags & O_ACCMODE)); | shmfd, FFLAGS(flags & O_ACCMODE)); | ||||
| Show All 15 Lines | #ifdef MAC | ||||
| error = mac_posixshm_check_truncate( | error = mac_posixshm_check_truncate( | ||||
| td->td_ucred, fp->f_cred, shmfd); | td->td_ucred, fp->f_cred, shmfd); | ||||
| if (error == 0) | if (error == 0) | ||||
| #endif | #endif | ||||
| shm_dotruncate(shmfd, 0); | shm_dotruncate(shmfd, 0); | ||||
| } | } | ||||
| if (error == 0) | if (error == 0) | ||||
| shm_hold(shmfd); | shm_hold(shmfd); | ||||
| } | } | ||||
Not Done Inline ActionsThe undocumented convention is that multiline comments only need an extra newline if they follow a statement. So, the newline is not needed here. markj: The undocumented convention is that multiline comments only need an extra newline if they… | |||||
| sx_xunlock(&shm_dict_lock); | sx_xunlock(&shm_dict_lock); | ||||
Done Inline Actions"need to be reworked"? markj: "need to be reworked"? | |||||
| if (error) { | if (error) { | ||||
| fdclose(td, fp, fd); | fdclose(td, fp, fd); | ||||
| fdrop(fp, td); | fdrop(fp, td); | ||||
| return (error); | return (error); | ||||
| } | } | ||||
| } | } | ||||
| finit(fp, FFLAGS(flags & O_ACCMODE), DTYPE_SHM, shmfd, &shm_ops); | finit(fp, FFLAGS(flags & O_ACCMODE), DTYPE_SHM, shmfd, &shm_ops); | ||||
| td->td_retval[0] = fd; | td->td_retval[0] = fd; | ||||
markjUnsubmitted Not Done Inline ActionsDoesn't this assignment belong in the callers? markj: Doesn't this assignment belong in the callers? | |||||
kevansAuthorUnsubmitted Done Inline ActionsYeah, sorry- this is actually getting reworked to be less sketchy. Callers will instead pass in an initial set of seals to apply, and the existing callers will apply F_SEAL_SEAL by default kevans: Yeah, sorry- this is actually getting reworked to be less sketchy. Callers will instead pass in… | |||||
markjUnsubmitted Not Done Inline ActionsOh, it was just a comment about the existing code. In general I would expect the td_retval assignment to appear in the sys_* layer. I think the proposed diff is fine. markj: Oh, it was just a comment about the existing code. In general I would expect the td_retval… | |||||
| /* | |||||
| * The caller is responsible for dropping the reference if they take | |||||
| * the file pointer from kern_shm_open(). | |||||
| */ | |||||
| if (fpp != NULL) | |||||
| *fpp = fp; | |||||
| else | |||||
| fdrop(fp, td); | fdrop(fp, td); | ||||
| return (0); | return (0); | ||||
| } | } | ||||
| /* System calls. */ | /* System calls. */ | ||||
| int | int | ||||
| sys_shm_open(struct thread *td, struct shm_open_args *uap) | sys_shm_open(struct thread *td, struct shm_open_args *uap) | ||||
| { | { | ||||
| return (kern_shm_open(td, uap->path, uap->flags | O_CLOEXEC, uap->mode, | return (kern_shm_open(td, uap->path, uap->flags | O_CLOEXEC, uap->mode, | ||||
| NULL)); | NULL, NULL)); | ||||
| } | } | ||||
| int | int | ||||
| sys_shm_unlink(struct thread *td, struct shm_unlink_args *uap) | sys_shm_unlink(struct thread *td, struct shm_unlink_args *uap) | ||||
| { | { | ||||
| char *path; | char *path; | ||||
| const char *pr_path; | const char *pr_path; | ||||
| size_t pr_pathlen; | size_t pr_pathlen; | ||||
| ▲ Show 20 Lines • Show All 326 Lines • Show Last 20 Lines | |||||
According to style, there should be a blank line before multiline comment.