- Make 'flags' argument to chflags(2), fchflags(2) and lchflags(2) of type

u_long. Before this change it was of type int for syscalls, but prototypes
  in sys/stat.h and documentation for chflags(2) and fchflags(2) (but not
  for lchflags(2)) stated that it was u_long. Now some related functions
  use u_long type for flags (strtofflags(3), fflagstostr(3)).
- Make path argument of type 'const char *' for consistency.

Discussed on:	arch
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Pawel Jakub Dawidek 2013-03-21 22:44:33 +00:00
parent e808788c05
commit b4b2596b97
10 changed files with 30 additions and 30 deletions

View File

@ -117,11 +117,7 @@ main(int argc, char *argv[])
} else
fts_options = hflag ? FTS_PHYSICAL : FTS_LOGICAL;
/* XXX: Why don't chflags and lchflags have compatible prototypes? */
if (hflag)
change_flags = (int (*)(const char *, unsigned long))lchflags;
else
change_flags = chflags;
change_flags = hflag ? lchflags : chflags;
flags = *argv;
if (*flags >= '0' && *flags <= '7') {

View File

@ -337,7 +337,7 @@ err: if (unlink(to))
* on a file that we copied, i.e., that we didn't create.)
*/
errno = 0;
if (fchflags(to_fd, (u_long)sbp->st_flags))
if (fchflags(to_fd, sbp->st_flags))
if (errno != EOPNOTSUPP || sbp->st_flags != 0)
warn("%s: set flags (was: 0%07o)", to, sbp->st_flags);

View File

@ -42,11 +42,11 @@
.In sys/stat.h
.In unistd.h
.Ft int
.Fn chflags "const char *path" "u_long flags"
.Fn chflags "const char *path" "unsigned long flags"
.Ft int
.Fn lchflags "const char *path" "int flags"
.Fn lchflags "const char *path" "unsigned long flags"
.Ft int
.Fn fchflags "int fd" "u_long flags"
.Fn fchflags "int fd" "unsigned long flags"
.Sh DESCRIPTION
The file whose name
is given by

View File

@ -114,8 +114,8 @@
32 AUE_GETSOCKNAME NOPROTO { int getsockname(int fdes, caddr_t asa, \
int *alen); }
33 AUE_ACCESS NOPROTO { int access(char *path, int amode); }
34 AUE_CHFLAGS NOPROTO { int chflags(char *path, int flags); }
35 AUE_FCHFLAGS NOPROTO { int fchflags(int fd, int flags); }
34 AUE_CHFLAGS NOPROTO { int chflags(const char *path, u_long flags); }
35 AUE_FCHFLAGS NOPROTO { int fchflags(int fd, u_long flags); }
36 AUE_SYNC NOPROTO { int sync(void); }
37 AUE_KILL NOPROTO { int kill(int pid, int signum); }
38 AUE_STAT COMPAT { int freebsd32_stat(char *path, \
@ -693,7 +693,8 @@
389 AUE_NULL UNIMPL __mac_set_file
390 AUE_NULL NOPROTO { int kenv(int what, const char *name, \
char *value, int len); }
391 AUE_LCHFLAGS NOPROTO { int lchflags(const char *path, int flags); }
391 AUE_LCHFLAGS NOPROTO { int lchflags(const char *path, \
u_long flags); }
392 AUE_NULL NOPROTO { int uuidgen(struct uuid *store, \
int count); }
393 AUE_SENDFILE STD { int freebsd32_sendfile(int fd, int s, \

View File

@ -183,7 +183,7 @@ struct tmpfs_node {
uid_t tn_uid;
gid_t tn_gid;
mode_t tn_mode;
int tn_flags;
u_long tn_flags;
nlink_t tn_links;
struct timespec tn_atime;
struct timespec tn_mtime;
@ -418,7 +418,7 @@ int tmpfs_dir_getdents(struct tmpfs_node *, struct uio *, int,
int tmpfs_dir_whiteout_add(struct vnode *, struct componentname *);
void tmpfs_dir_whiteout_remove(struct vnode *, struct componentname *);
int tmpfs_reg_resize(struct vnode *, off_t, boolean_t);
int tmpfs_chflags(struct vnode *, int, struct ucred *, struct thread *);
int tmpfs_chflags(struct vnode *, u_long, struct ucred *, struct thread *);
int tmpfs_chmod(struct vnode *, mode_t, struct ucred *, struct thread *);
int tmpfs_chown(struct vnode *, uid_t, gid_t, struct ucred *,
struct thread *);

View File

@ -1355,7 +1355,8 @@ retry:
* The vnode must be locked on entry and remain locked on exit.
*/
int
tmpfs_chflags(struct vnode *vp, int flags, struct ucred *cred, struct thread *p)
tmpfs_chflags(struct vnode *vp, u_long flags, struct ucred *cred,
struct thread *p)
{
int error;
struct tmpfs_node *node;

View File

@ -115,8 +115,8 @@
struct sockaddr * __restrict asa, \
__socklen_t * __restrict alen); }
33 AUE_ACCESS STD { int access(char *path, int amode); }
34 AUE_CHFLAGS STD { int chflags(char *path, int flags); }
35 AUE_FCHFLAGS STD { int fchflags(int fd, int flags); }
34 AUE_CHFLAGS STD { int chflags(const char *path, u_long flags); }
35 AUE_FCHFLAGS STD { int fchflags(int fd, u_long flags); }
36 AUE_SYNC STD { int sync(void); }
37 AUE_KILL STD { int kill(int pid, int signum); }
38 AUE_STAT COMPAT { int stat(char *path, struct ostat *ub); }
@ -696,7 +696,8 @@
struct mac *mac_p); }
390 AUE_NULL STD { int kenv(int what, const char *name, \
char *value, int len); }
391 AUE_LCHFLAGS STD { int lchflags(const char *path, int flags); }
391 AUE_LCHFLAGS STD { int lchflags(const char *path, \
u_long flags); }
392 AUE_NULL STD { int uuidgen(struct uuid *store, \
int count); }
393 AUE_SENDFILE STD { int sendfile(int fd, int s, off_t offset, \

View File

@ -101,7 +101,7 @@ SDT_PROBE_ARGTYPE(vfs, , stat, reg, 1, "int");
static int chroot_refuse_vdir_fds(struct filedesc *fdp);
static int getutimes(const struct timeval *, enum uio_seg, struct timespec *);
static int setfflags(struct thread *td, struct vnode *, int);
static int setfflags(struct thread *td, struct vnode *, u_long);
static int setutimes(struct thread *td, struct vnode *,
const struct timespec *, int, int);
static int vn_access(struct vnode *vp, int user_flags, struct ucred *cred,
@ -2615,7 +2615,7 @@ static int
setfflags(td, vp, flags)
struct thread *td;
struct vnode *vp;
int flags;
u_long flags;
{
int error;
struct mount *mp;
@ -2657,16 +2657,16 @@ setfflags(td, vp, flags)
*/
#ifndef _SYS_SYSPROTO_H_
struct chflags_args {
char *path;
int flags;
const char *path;
u_long flags;
};
#endif
int
sys_chflags(td, uap)
struct thread *td;
register struct chflags_args /* {
char *path;
int flags;
const char *path;
u_long flags;
} */ *uap;
{
int error;
@ -2689,8 +2689,8 @@ int
sys_lchflags(td, uap)
struct thread *td;
register struct lchflags_args /* {
char *path;
int flags;
const char *path;
u_long flags;
} */ *uap;
{
int error;
@ -2713,7 +2713,7 @@ sys_lchflags(td, uap)
#ifndef _SYS_SYSPROTO_H_
struct fchflags_args {
int fd;
int flags;
u_long flags;
};
#endif
int
@ -2721,7 +2721,7 @@ sys_fchflags(td, uap)
struct thread *td;
register struct fchflags_args /* {
int fd;
int flags;
u_long flags;
} */ *uap;
{
struct file *fp;

View File

@ -306,7 +306,7 @@ int fchmodat(int, const char *, mode_t, int);
#endif
int fstat(int, struct stat *);
#if __BSD_VISIBLE
int lchflags(const char *, int);
int lchflags(const char *, unsigned long);
int lchmod(const char *, mode_t);
#endif
#if __POSIX_VISIBLE >= 200112

View File

@ -831,7 +831,8 @@ call_syscall(struct syscall_desc *scall, char *argv[])
#endif
#ifdef HAS_LCHFLAGS
case ACTION_LCHFLAGS:
rval = lchflags(STR(0), (int)str2flags(chflags_flags, STR(1)));
rval = lchflags(STR(0),
(unsigned long)str2flags(chflags_flags, STR(1)));
break;
#endif
case ACTION_TRUNCATE: