{"id":1055,"date":"2010-08-10T00:58:19","date_gmt":"2010-08-10T06:58:19","guid":{"rendered":"http:\/\/edsionte.com\/techblog\/?p=1055"},"modified":"2010-08-10T01:31:41","modified_gmt":"2010-08-10T07:31:41","slug":"%e5%ae%9e%e7%8e%b0cp%e5%91%bd%e4%bb%a48","status":"publish","type":"post","link":"http:\/\/edsionte.com\/techblog\/archives\/1055","title":{"rendered":"\u5b9e\u73b0cp\u547d\u4ee4(8)"},"content":{"rendered":"<h2>\u95ee\u9898\u4e0d\u65ad\u7684\u6587\u4ef6\u6743\u9650!<\/h2>\n<p>\u5728\u5b9e\u73b0cp\u547d\u4ee4(6)\uff08\u4ee5\u4e0b\u7b80\u79f0cp(6)\uff09\u4e2d\u6211\u4eec\u52a0\u5165\u4e86-p\u9009\u9879\uff0c\u5373\u4f7f\u7528cp\u547d\u4ee4\u65f6\u52a0\u5165-p\u624d\u4f1a\u5c06\u6e90\u6587\u4ef6\u7684\u5c5e\u6027\u590d\u5236\u7ed9\u76ee\u7684\u6587\u4ef6\uff0c\u5426\u5219\u53ea\u62f7\u8d1d\u6587\u4ef6\u4e2d\u7684\u5185\u5bb9\u3002\u4f46\u662f\u6211\u4eec\u770b\u770b\u4e0b\u9762cp\u7684\u8fd0\u884c\u7ed3\u679c\u3002<\/p>\n<p>cp(6)\u4e2d\u4e0d\u662f\u8bf4\u53ea\u6709\u52a0-p\u624d\u4f1a\u590d\u5236\u6e90\u6587\u4ef6\u7684\u5c5e\u6027\u5417\uff1f\u600e\u4e48cao.c\u548c\u6e90\u6587\u4ef6\u7684\u5c5e\u6027\u4e00\u6a21\u4e00\u6837\uff1f<\/p>\n<pre class=\"brush:c\">gues@huangwei-desktop:~\/code\/shell_command$ ls -l ch222.c\r\n-rwxr--r-- 1 gues gues  5327 2010-08-09 20:45 ch222.c\r\ngues@huangwei-desktop:~\/code\/shell_command$ cp ch222.c cao.c\r\ngues@huangwei-desktop:~\/code\/shell_command$ ls -l cao.c\r\n-rwxr--r-- 1 gues gues 5327 2010-08-09 20:54 cao.c<\/pre>\n<p>\u4e3a\u4ec0\u4e48\u6b64\u65f6\u76ee\u7684\u6587\u4ef6\u7684\u5c5e\u6027\u53c8\u662f644\uff08cp(6)\u4e2d\u8bf4644\u662f\u65b0\u5efa\u6587\u4ef6\u7684\u9ed8\u8ba4\u5c5e\u6027\uff09\uff1f<\/p>\n<pre class=\"brush:c\">gues@huangwei-desktop:~\/code\/shell_command$ ls -l changemode.c\r\n-rw-rw-r-- 1 gues gues  5327 2010-08-09 10:31 changemode.c\r\ngues@huangwei-desktop:~\/code\/shell_command$ cp changemode.c wo.c\r\ngues@huangwei-desktop:~\/code\/shell_command$ ls -l wo.c\r\n-rw-r--r-- 1 gues gues 5327 2010-08-09 20:56 wo.c<\/pre>\n<p>\u8d77\u521d\uff0c\u5f53\u6211\u53d1\u73b0\u4e0a\u8ff0\u7ed3\u679c\u540e\uff0c\u8111\u4e2d\u6709\u6570\u4e2a\u4e3a\u4ec0\u4e48\u3002\u4e3a\u4ec0\u4e48\u590d\u5236\u6587\u4ef6\u7684\u65f6\u5019\uff0c\u6587\u4ef6\u5c5e\u6027\u4f1a\u8fd9\u4e48\u591a\u53d8\uff1f\u4e0d\u65ad\u51fa\u95ee\u9898\uff1f\u5176\u5b9e\uff0c\u662f\u56e0\u4e3a\u6211\u4eec\u5ffd\u7565\u4e86\u6587\u4ef6\u5c4f\u853d\u5b57\uff1aumask\u3002\u5728\u65b0\u5efa\u6587\u4ef6\u6216\u8005\u76ee\u5f55\u7684\u65f6\u5019\uff0c\u65b0\u6587\u4ef6\u7684\u5b9e\u9645\u5b58\u53d6\u6743\u9650\u662fmode&amp;~umask\u3002\u6bd4\u5982\u7528open\u521b\u5efa\uff08\u6216\u6253\u5f00\uff09\u6587\u4ef6\uff0c\u90a3mode\u5c31\u662fopen\u51fd\u6570\u7684\u7b2c\u4e09\u4e2a\u53c2\u6570\u3002\u65e2\u7136\u8fd9\u6837\uff0c\u90a3\u6211\u4eec\u6765\u68c0\u9a8c\u4e00\u4e0b\u4e0a\u8ff0\u547d\u4ee4\u3002\u901a\u8fc7\u8f93\u5165umask\u547d\u4ee4\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u5f53\u524d\u5c4f\u853d\u5b57\u4e3a022\u3002\u4e0e\u4e0a\u8ff0\u6e90\u6587\u4ef6\u8fdb\u884cmode&amp;~umask\u8fd0\u7b97\u540e\uff0c\u521a\u597d\u548c\u76ee\u7684\u6587\u4ef6\u7684\u5c5e\u6027\u4e00\u81f4\u3002\u90a3\u4e48\u73b0\u5728\u6211\u4eec\u7ec8\u4e8e\u627e\u5230\u95ee\u9898\u7684\u539f\u56e0\u6240\u5728\u4e86\u3002<\/p>\n<p>\u597d\u4e86\uff0c\u8ba9\u6211\u4eec\u5fd8\u6389cp(6)\u4e2d\u6240\u8bf4\u7684\u4e00\u5207\uff0c\u91cd\u65b0\u6574\u7406\u601d\u8def\uff1a<\/p>\n<p><strong>\u5728\u4f7f\u7528cp\u547d\u4ee4\u7684\u65f6\u5019\uff0c\u5f53\u76ee\u7684\u6587\u4ef6\u4e0d\u5b58\u5728\u65f6\uff0c\u4f1a\u65b0\u5efa\u4e0e\u6e90\u6587\u4ef6\u540c\u540d\u7684\u65b0\u6587\u4ef6\u3002\u8fd9\u4e2a\u65b0\u6587\u4ef6\u7684\u5b9e\u9645\u6743\u9650\u7531\uff1amode&amp;~umask\u8fd0\u7b97\u540e\u7684\u7ed3\u679c\u6765\u51b3\u5b9a\u3002\u6b64\u65f6\u7684mode\u4e3a\u6e90\u6587\u4ef6\u7684\u6743\u9650\u3002\u800c\u5f53\u76ee\u7684\u6587\u4ef6\u5b58\u5728\u65f6\uff0c\u5219\u4f1a\u4fdd\u6301\u539f\u76ee\u7684\u6587\u4ef6\u7684\u5c5e\u6027\uff0c\u9664\u975e\u5728cp\u547d\u4ee4\u4e2d\u52a0\u5165-p\u9009\u9879\u3002<\/strong><\/p>\n<p>\u597d\u4e86\uff0c\u6211\u4eec\u73b0\u5728\u641e\u6e05\u695acp\u547d\u4ee4\u5728\u4e0d\u52a0-p\u9009\u9879\u65f6\u5019\u7684\u6587\u4ef6\u6743\u9650\u95ee\u9898\uff0c\u81f3\u4e8e\u4ee3\u7801\u4fee\u6539\uff0c\u53ea\u9700\u4fee\u6539\u5c06open\u4e2d\u7684\u7b2c\u4e09\u4e2a\u53c2\u6570\u4fee\u6539\u6210\u6e90\u6587\u4ef6\u7684\u6743\u9650\u5373\u53ef\u3002\u5177\u4f53\u4ee3\u7801\u5b9e\u73b0\u5982\u4e0b\uff1a<\/p>\n<pre class=\"brush:c\">\t\/\/open the dest file\r\n\tif((fdwt=open(dest_path,O_CREAT|O_TRUNC|O_RDWR,src_buf.st_mode))==-1)\r\n\t{\r\n\t\tperror(\"open_destfile\");\r\n\t\texit(1);\r\n\t}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u95ee\u9898\u4e0d\u65ad\u7684\u6587\u4ef6\u6743\u9650! \u5728\u5b9e\u73b0cp\u547d\u4ee4(6)\uff08\u4ee5\u4e0b\u7b80\u79f0cp(6)\uff09\u4e2d\u6211\u4eec\u52a0\u5165\u4e86-p\u9009\u9879\uff0c\u5373\u4f7f\u7528cp\u547d\u4ee4\u65f6\u52a0\u5165-p [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[109,108,125,107],"class_list":{"0":"post-1055","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-linuxc","7":"tag-c","8":"tag-linux","10":"tag-107"},"views":6249,"_links":{"self":[{"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/posts\/1055","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/comments?post=1055"}],"version-history":[{"count":0,"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/posts\/1055\/revisions"}],"wp:attachment":[{"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/media?parent=1055"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/categories?post=1055"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/tags?post=1055"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}