diff --git a/lib/libarchive/config.h b/lib/libarchive/config.h index daa84b2..1db110c 100644 --- a/lib/libarchive/config.h +++ b/lib/libarchive/config.h @@ -174,7 +174,9 @@ #define HAVE_LANGINFO_H 1 /* Define to 1 if you have the `lchflags' function. */ -/* #undef HAVE_LCHFLAGS */ +#if __DragonFly_version >= 200101 +#define HAVE_LCHFLAGS 1 +#endif /* Define to 1 if you have the `lchmod' function. */ #define HAVE_LCHMOD 1 diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc index 62432e7..085b7d2 100644 --- a/lib/libc/sys/Makefile.inc +++ b/lib/libc/sys/Makefile.inc @@ -101,7 +101,7 @@ MAN+= sched_get_priority_max.2 sched_setparam.2 \ MLINKS+=brk.2 sbrk.2 MLINKS+=caps_sys_get.2 caps_sys_wait.2 MLINKS+=chdir.2 fchdir.2 -MLINKS+=chflags.2 fchflags.2 +MLINKS+=chflags.2 fchflags.2 chflags.2 lchflags.2 MLINKS+=chmod.2 fchmod.2 chmod.2 lchmod.2 MLINKS+=chown.2 fchown.2 chown.2 lchown.2 MLINKS+=clock_gettime.2 clock_getres.2 clock_gettime.2 clock_settime.2 diff --git a/lib/libc/sys/chflags.2 b/lib/libc/sys/chflags.2 index b08c007..fbd7dcd 100644 --- a/lib/libc/sys/chflags.2 +++ b/lib/libc/sys/chflags.2 @@ -33,11 +33,12 @@ .\" $FreeBSD: src/lib/libc/sys/chflags.2,v 1.11.2.7 2001/12/14 18:34:00 ru Exp $ .\" $DragonFly: src/lib/libc/sys/chflags.2,v 1.4 2008/06/24 07:58:00 swildner Exp $ .\" -.Dd June 24, 2008 +.Dd November 10, 2008 .Dt CHFLAGS 2 .Os .Sh NAME .Nm chflags , +.Nm lchflags , .Nm fchflags .Nd set file flags .Sh LIBRARY @@ -48,6 +49,8 @@ .Ft int .Fn chflags "const char *path" "u_long flags" .Ft int +.Fn lchflags "const char *path" "u_long flags" +.Ft int .Fn fchflags "int fd" "u_long flags" .Sh DESCRIPTION The file whose name @@ -58,6 +61,16 @@ or referenced by the descriptor has its flags changed to .Fa flags . .Pp +The +.Fn lchflags +system call is like +.Fn chflags +except in the case where the named file is a symbolic link, +in which case +.Fn lchflags +will change the flags of the link itself, +rather than the file it points to. +.Pp The flags specified are formed by .Em or Ns 'ing the following values diff --git a/sys/kern/init_sysent.c b/sys/kern/init_sysent.c index 9f7e483..9d7e6a8 100644 --- a/sys/kern/init_sysent.c +++ b/sys/kern/init_sysent.c @@ -2,8 +2,8 @@ * System call switch table. * * DO NOT EDIT-- this file is automatically generated. - * $DragonFly: src/sys/kern/init_sysent.c,v 1.62 2008/06/01 19:55:30 dillon Exp $ - * created from DragonFly + * $DragonFly$ + * created from DragonFly: src/sys/kern/syscalls.master,v 1.59 2008/06/01 19:55:30 dillon Exp */ #include "opt_compat.h" @@ -426,7 +426,7 @@ struct sysent sysent[] = { { 0, (sy_call_t *)sys_nosys }, /* 388 = nosys */ { 0, (sy_call_t *)sys_nosys }, /* 389 = nosys */ { 0, (sy_call_t *)sys_nosys }, /* 390 = nosys */ - { 0, (sy_call_t *)sys_nosys }, /* 391 = nosys */ + { AS(lchflags_args), (sy_call_t *)sys_lchflags }, /* 391 = lchflags */ { AS(uuidgen_args), (sy_call_t *)sys_uuidgen }, /* 392 = uuidgen */ { AS(sendfile_args), (sy_call_t *)sys_sendfile }, /* 393 = sendfile */ { 0, (sy_call_t *)sys_nosys }, /* 394 = nosys */ diff --git a/sys/kern/syscalls.c b/sys/kern/syscalls.c index 1aa40e1..d00674b 100644 --- a/sys/kern/syscalls.c +++ b/sys/kern/syscalls.c @@ -2,8 +2,8 @@ * System call names. * * DO NOT EDIT-- this file is automatically generated. - * $DragonFly: src/sys/kern/syscalls.c,v 1.61 2008/06/01 19:55:30 dillon Exp $ - * created from DragonFly + * $DragonFly$ + * created from DragonFly: src/sys/kern/syscalls.master,v 1.59 2008/06/01 19:55:30 dillon Exp */ char *syscallnames[] = { @@ -400,7 +400,7 @@ char *syscallnames[] = { "#388", /* 388 = nosys */ "#389", /* 389 = nosys */ "#390", /* 390 = nosys */ - "#391", /* 391 = nosys */ + "lchflags", /* 391 = lchflags */ "uuidgen", /* 392 = uuidgen */ "sendfile", /* 393 = sendfile */ "#394", /* 394 = nosys */ diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master index 3b3eb35..57ffc9b 100644 --- a/sys/kern/syscalls.master +++ b/sys/kern/syscalls.master @@ -560,7 +560,7 @@ 388 UNIMPL NOHIDE nosys 389 UNIMPL NOHIDE nosys 390 UNIMPL NOHIDE nosys -391 UNIMPL NOHIDE nosys +391 STD BSD { int lchflags(char *path, int flags); } 392 STD BSD { int uuidgen(struct uuid *store, int count); } 393 STD BSD { int sendfile(int fd, int s, off_t offset, size_t nbytes, \ struct sf_hdtr *hdtr, off_t *sbytes, int flags); } diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 36c9a1d..d4bc01e 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -2584,6 +2584,36 @@ sys_chflags(struct chflags_args *uap) } /* + * lchflags(char *path, int flags) + * + * Change flags of a file given a path name, but don't follow symlinks. + */ +/* ARGSUSED */ +int +sys_lchflags(struct chflags_args *uap) +{ + struct nlookupdata nd; + struct vnode *vp; + int error; + + vp = NULL; + error = nlookup_init(&nd, uap->path, UIO_USERSPACE, 0); + /* XXX Add NLC flag indicating modifying operation? */ + if (error == 0) + error = nlookup(&nd); + if (error == 0) + error = ncp_writechk(&nd.nl_nch); + if (error == 0) + error = cache_vref(&nd.nl_nch, nd.nl_cred, &vp); + nlookup_done(&nd); + if (error == 0) { + error = setfflags(vp, uap->flags); + vrele(vp); + } + return (error); +} + +/* * fchflags_args(int fd, int flags) * * Change flags of a file given a file descriptor. diff --git a/sys/sys/param.h b/sys/sys/param.h index ea1a4c2..12bf2cd 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -61,9 +61,10 @@ * 199900 - base development version before 2.0 branch * 200000 - 2.0 branch * 200100 - base development version after 2.0 branch + * 200101 - lchflags syscall */ #undef __DragonFly_version -#define __DragonFly_version 200100 /* Master, propagated to newvers */ +#define __DragonFly_version 200101 /* Master, propagated to newvers */ #ifdef __FreeBSD__ /* diff --git a/sys/sys/syscall-hide.h b/sys/sys/syscall-hide.h index f086937..a938a27 100644 --- a/sys/sys/syscall-hide.h +++ b/sys/sys/syscall-hide.h @@ -2,8 +2,8 @@ * System call hiders. * * DO NOT EDIT-- this file is automatically generated. - * $DragonFly: src/sys/sys/syscall-hide.h,v 1.62 2008/06/01 19:55:32 dillon Exp $ - * created from DragonFly + * $DragonFly$ + * created from DragonFly: src/sys/kern/syscalls.master,v 1.59 2008/06/01 19:55:30 dillon Exp */ #ifdef COMPAT_43 @@ -279,6 +279,7 @@ HIDE_BSD(getresgid) HIDE_BSD(kqueue) HIDE_BSD(kevent) HIDE_BSD(sctp_peeloff) +HIDE_BSD(lchflags) HIDE_BSD(uuidgen) HIDE_BSD(sendfile) HIDE_BSD(varsym_set) diff --git a/sys/sys/syscall.h b/sys/sys/syscall.h index 81cb462..042f228 100644 --- a/sys/sys/syscall.h +++ b/sys/sys/syscall.h @@ -2,8 +2,8 @@ * System call numbers. * * DO NOT EDIT-- this file is automatically generated. - * $DragonFly: src/sys/sys/syscall.h,v 1.62 2008/06/01 19:55:32 dillon Exp $ - * created from DragonFly + * $DragonFly$ + * created from DragonFly: src/sys/kern/syscalls.master,v 1.59 2008/06/01 19:55:30 dillon Exp */ #define SYS_syscall 0 @@ -290,6 +290,7 @@ #define SYS_kqueue 362 #define SYS_kevent 363 #define SYS_sctp_peeloff 364 +#define SYS_lchflags 391 #define SYS_uuidgen 392 #define SYS_sendfile 393 #define SYS_varsym_set 450 diff --git a/sys/sys/syscall.mk b/sys/sys/syscall.mk index 44d84af..38c27ef 100644 --- a/sys/sys/syscall.mk +++ b/sys/sys/syscall.mk @@ -1,7 +1,7 @@ # DragonFly system call names. # DO NOT EDIT-- this file is automatically generated. -# $DragonFly: src/sys/sys/syscall.mk,v 1.62 2008/06/01 19:55:32 dillon Exp $ -# created from DragonFly +# $DragonFly$ +# created from DragonFly: src/sys/kern/syscalls.master,v 1.59 2008/06/01 19:55:30 dillon Exp MIASM = \ syscall.o \ exit.o \ @@ -231,6 +231,7 @@ MIASM = \ kqueue.o \ kevent.o \ sctp_peeloff.o \ + lchflags.o \ uuidgen.o \ sendfile.o \ varsym_set.o \ diff --git a/sys/sys/sysproto.h b/sys/sys/sysproto.h index 57049cb..8362022 100644 --- a/sys/sys/sysproto.h +++ b/sys/sys/sysproto.h @@ -2,8 +2,8 @@ * System call prototypes. * * DO NOT EDIT-- this file is automatically generated. - * $DragonFly: src/sys/sys/sysproto.h,v 1.62 2008/06/01 19:55:32 dillon Exp $ - * created from DragonFly + * $DragonFly$ + * created from DragonFly: src/sys/kern/syscalls.master,v 1.59 2008/06/01 19:55:30 dillon Exp */ #ifndef _SYS_SYSPROTO_H_ @@ -1692,6 +1692,13 @@ struct sctp_peeloff_args { int sd; char sd_[PAD_(int)]; caddr_t name; char name_[PAD_(caddr_t)]; }; +struct lchflags_args { +#ifdef _KERNEL + struct sysmsg sysmsg; +#endif + char * path; char path_[PAD_(char *)]; + int flags; char flags_[PAD_(int)]; +}; struct uuidgen_args { #ifdef _KERNEL struct sysmsg sysmsg; @@ -2683,6 +2690,7 @@ int sys_getresgid (struct getresgid_args *); int sys_kqueue (struct kqueue_args *); int sys_kevent (struct kevent_args *); int sys_sctp_peeloff (struct sctp_peeloff_args *); +int sys_lchflags (struct lchflags_args *); int sys_uuidgen (struct uuidgen_args *); int sys_sendfile (struct sendfile_args *); int sys_varsym_set (struct varsym_set_args *); diff --git a/sys/sys/sysunion.h b/sys/sys/sysunion.h index 34196aa..f546732 100644 --- a/sys/sys/sysunion.h +++ b/sys/sys/sysunion.h @@ -2,8 +2,8 @@ * Union of syscall args for messaging. * * DO NOT EDIT-- this file is automatically generated. - * $DragonFly: src/sys/sys/sysunion.h,v 1.59 2008/06/01 19:55:32 dillon Exp $ - * created from DragonFly + * $DragonFly$ + * created from DragonFly: src/sys/kern/syscalls.master,v 1.59 2008/06/01 19:55:30 dillon Exp */ union sysunion { @@ -335,6 +335,7 @@ union sysunion { struct kqueue_args kqueue; struct kevent_args kevent; struct sctp_peeloff_args sctp_peeloff; + struct lchflags_args lchflags; struct uuidgen_args uuidgen; struct sendfile_args sendfile; struct varsym_set_args varsym_set; diff --git a/usr.bin/checknr/checknr.c b/usr.bin/checknr/checknr.c index 4b37340..60a3a18 100644 --- a/usr.bin/checknr/checknr.c +++ b/usr.bin/checknr/checknr.c @@ -66,7 +66,7 @@ struct stkstr { int opno; /* number of opening bracket */ int pl; /* '+', '-', ' ' for \s, 1 for \f, 0 for .ft */ int parm; /* parm to size, font, etc */ - int lno; /* line number the thing came in in */ + int lno; /* line number the thing came in on */ } stk[MAXSTK]; int stktop; @@ -255,9 +255,11 @@ main(int argc, char **argv) cfilename = argv[i]; f = fopen(cfilename, "r"); if (f == NULL) - perror(cfilename); - else + warn("%s", cfilename); + else { process(f); + fclose(f); + } } } else { cfilename = "stdin"; diff --git a/usr.bin/chflags/chflags.1 b/usr.bin/chflags/chflags.1 index 96722db..6617c27 100644 --- a/usr.bin/chflags/chflags.1 +++ b/usr.bin/chflags/chflags.1 @@ -1,3 +1,4 @@ +.\"- .\" Copyright (c) 1989, 1990, 1993, 1994 .\" The Regents of the University of California. All rights reserved. .\" @@ -44,6 +45,7 @@ .Nd change file flags .Sh SYNOPSIS .Nm +.Op Fl h .Oo .Fl R .Op Fl H | Fl L | Fl P @@ -65,6 +67,11 @@ If the .Fl R option is specified, symbolic links on the command line are followed. (Symbolic links encountered in the tree traversal are not followed.) +.It Fl h +If the +.Ar file +is a symbolic link, +change the mode of the link itself rather than the file to which it points. .It Fl L If the .Fl R @@ -83,8 +90,8 @@ The flags are specified as an octal number or a comma separated list of keywords. The following keywords are currently defined: .Pp -.Bl -tag -offset indent -width "nouhistory" -compact -.It Ar arch +.Bl -tag -offset indent -width ".Ar nouhistory" +.It Ar arch , archived set the archived flag (super-user only) .It Ar opaque set the opaque flag (owner or super-user only) @@ -92,28 +99,20 @@ set the opaque flag (owner or super-user only) set the nodump flag (owner or super-user only) .It Ar noshistory set the system nohistory flag (super-user only) -.It Ar nouhistory +.It Ar nouhistory , nohistory set the user nohistory flag (owner or super-user only) -.It Ar sappnd +.It Ar sappnd , sappend set the system append-only flag (super-user only) -.It Ar schg +.It Ar schg , schange , simmutable set the system immutable flag (super-user only) -.It Ar sunlnk +.It Ar sunlnk , sunlink set the system undeletable flag (super-user only) -.It Ar uappnd +.It Ar uappnd , uappend set the user append-only flag (owner or super-user only) -.It Ar uchg +.It Ar uchg , uchange , uimmutable set the user immutable flag (owner or super-user only) -.It Ar uunlnk +.It Ar uunlnk , uunlink set the user undeletable flag (owner or super-user only) -.It Ar archived , sappend , schange , Xo -.Ar simmutable , uappend , uchange , uimmutable , -.Ar sunlink , uunlink -.Xc -aliases for the above -.It Ar nohistory -alias for -.Ar nouhistory .El .Pp Putting the letters @@ -130,11 +129,12 @@ clear the user immutable flag (owner or super-user only) clear the nodump flag (owner or super-user only) .El .Pp -Symbolic links do not have flags, so unless the -.Fl H +Unless the +.Fl H , +.Fl L , or -.Fl L -option is set, +.Fl h +options are given, .Nm on a symbolic link always succeeds and has no effect. The @@ -149,7 +149,7 @@ In addition, these options override each other and the command's actions are determined by the last one specified. .Pp You can use "ls -lo" to see the flags of existing files. -.Sh DIAGNOSTICS +.Sh EXIT STATUS .Ex -std .Sh SEE ALSO .Xr ls 1 , @@ -157,6 +157,23 @@ You can use "ls -lo" to see the flags of existing files. .Xr stat 2 , .Xr fts 3 , .Xr symlink 7 +.Sh BUGS +Only a limited number of utilities are +.Nm +aware. +Some of these tools include +.Xr ls 1 , +.Xr cp 1 , +.Xr find 1 , +.Xr install 1 , +.Xr dump 8 , +and +.Xr restore 8 . +In particular a tool which is not currently +.Nm +aware is the +.Xr pax 1 +utility. .Sh HISTORY The .Nm diff --git a/usr.bin/chflags/chflags.c b/usr.bin/chflags/chflags.c index 832dcc2..a190147 100644 --- a/usr.bin/chflags/chflags.c +++ b/usr.bin/chflags/chflags.c @@ -1,4 +1,4 @@ -/* +/*- * Copyright (c) 1992, 1993, 1994 * The Regents of the University of California. All rights reserved. * @@ -56,11 +56,12 @@ main(int argc, char **argv) FTSENT *p; u_long clear, set; long val; - int Hflag, Lflag, Rflag, ch, fts_options, oct, rval; + int Hflag, Lflag, Rflag, hflag, ch, fts_options, oct, rval; char *flags, *ep; + int (*change_flags)(const char *, unsigned long); - Hflag = Lflag = Rflag = 0; - while ((ch = getopt(argc, argv, "HLPR")) != -1) + Hflag = Lflag = Rflag = hflag = 0; + while ((ch = getopt(argc, argv, "HLPRh")) != -1) switch (ch) { case 'H': Hflag = 1; @@ -76,6 +77,10 @@ main(int argc, char **argv) case 'R': Rflag = 1; break; + case 'h': + hflag = 1; + break; + case '?': default: usage(); } @@ -87,6 +92,10 @@ main(int argc, char **argv) fts_options = FTS_PHYSICAL; if (Rflag) { + if (hflag) { + errx(1, "the -R and -h options " + "may not be specified together"); + } if (Hflag) fts_options |= FTS_COMFOLLOW; if (Lflag) { @@ -95,6 +104,14 @@ main(int argc, char **argv) } } +/* The lchflags syscall was added in 2.1 */ +#if __DragonFly_version >= 200101 + if (hflag) + change_flags = lchflags; + else +#endif + change_flags = chflags; + flags = *argv; if (*flags >= '0' && *flags <= '7') { errno = 0; @@ -139,17 +156,20 @@ main(int argc, char **argv) * don't point to anything and ones that we found * doing a physical walk. */ - continue; + if (!hflag) + continue; + /* FALLTHROUGH */ default: break; } if (oct) { - if (!chflags(p->fts_accpath, set)) + if (!(*change_flags)(p->fts_accpath, set)) continue; } else { p->fts_statp->st_flags |= set; p->fts_statp->st_flags &= clear; - if (!chflags(p->fts_accpath, (u_long)p->fts_statp->st_flags)) + if (!(*change_flags)(p->fts_accpath, + (u_long)p->fts_statp->st_flags)) continue; } warn("%s", p->fts_path); @@ -164,6 +184,6 @@ static void usage(void) { fprintf(stderr, - "usage: chflags [-R [-H | -L | -P]] flags file ...\n"); + "usage: chflags [-h] [-R [-H | -L | -P]] flags file ...\n"); exit(1); }